feat(observatory): add portable calculation profiles
This commit is contained in:
@@ -350,7 +350,7 @@ def test_session_router_exposes_immutable_lab_provenance(tmp_path: Path) -> None
|
||||
assert_no_local_paths((item, detail), repository)
|
||||
|
||||
|
||||
def test_session_router_rolls_capability_projections_out_only_in_v2(
|
||||
def test_session_router_versions_capability_and_calculation_profile_projections(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
repository = tmp_path / "repo"
|
||||
@@ -390,7 +390,21 @@ def test_session_router_rolls_capability_projections_out_only_in_v2(
|
||||
"method": lab_method(),
|
||||
},
|
||||
)
|
||||
router = build_session_router(store)
|
||||
calculation_profile = {
|
||||
"schema_version": "missioncore.observatory-calculation-profile/v1",
|
||||
"setup_id": "lab-v1-ravnoves004tree-final",
|
||||
"display_name": "LAB V1 · EoMT Cityscapes Large 1024 + DDRNet-39",
|
||||
"origin": "existing-result",
|
||||
"definition_id": None,
|
||||
"definition_version": None,
|
||||
"definition_sha256": None,
|
||||
}
|
||||
router = build_session_router(
|
||||
store,
|
||||
lab_calculation_profile_resolver=lambda summary: (
|
||||
calculation_profile if summary.session_id == canonical.session_id else None
|
||||
),
|
||||
)
|
||||
list_route = endpoint(router, "/api/v1/observation-sessions", "GET")
|
||||
|
||||
default_items = list_route(limit=20, cursor=None, scope="all")["items"]
|
||||
@@ -415,11 +429,30 @@ def test_session_router_rolls_capability_projections_out_only_in_v2(
|
||||
assert set(by_id) == {legacy.session_id, canonical.session_id}
|
||||
assert by_id[legacy.session_id]["lab"]["replay_capability"] is None
|
||||
assert by_id[canonical.session_id]["lab"]["replay_capability"] == capability.as_dict()
|
||||
assert "calculation_profile" not in by_id[legacy.session_id]["lab"]
|
||||
assert "calculation_profile" not in by_id[canonical.session_id]["lab"]
|
||||
|
||||
v3_labs = list_route(
|
||||
limit=20,
|
||||
cursor=None,
|
||||
scope="laboratory",
|
||||
lab_contract="v3",
|
||||
)["items"]
|
||||
v3_by_id = {item["id"]: item for item in v3_labs}
|
||||
assert v3_by_id[legacy.session_id]["lab"]["calculation_profile"] is None
|
||||
assert (
|
||||
v3_by_id[canonical.session_id]["lab"]["calculation_profile"]
|
||||
== calculation_profile
|
||||
)
|
||||
assert (
|
||||
v3_by_id[canonical.session_id]["lab"]["replay_capability"]
|
||||
== capability.as_dict()
|
||||
)
|
||||
|
||||
application = FastAPI()
|
||||
application.include_router(router)
|
||||
assert TestClient(application).get(
|
||||
"/api/v1/observation-sessions?lab_contract=v3"
|
||||
"/api/v1/observation-sessions?lab_contract=v4"
|
||||
).status_code == 422
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user