Skip to content

scene_pipelines.ingestion.scene.admin.lab

Admin helper: ensure a Lab catalog row exists.

lab_meta_payload

lab_meta_payload(row: dict[str, Any]) -> dict[str, str]

Non-key Lab fields. Missing names hash as empty strings.

ensure_lab

ensure_lab(lab: DjRow[Lab], *, deployment: DjRow[Deployment] | None = None, if_exists: DuplicatePolicy = REJECT) -> DjKey[Lab]

Insert a lab row and stamp the deployment that registered it.

Runs atomically; joins the caller's transaction when one is open.

Parameters:

Name Type Description Default
lab DjRow[Lab]

Full lab insert dict (lab_id, optional lab_name, …).

required
deployment DjRow[Deployment] | None

Optional deployment row. If omitted, built from SCENE_DEPLOYMENT_ID / SCENE_DEPLOYMENT_LABEL.

None
if_exists DuplicatePolicy

Policy when lab_id is already stored; see DuplicatePolicy.

REJECT

Returns:

Type Description
DjKey[Lab]

Lab primary key {lab_id: ...}.

Raises:

Type Description
ValueError

If deployment is omitted and SCENE_DEPLOYMENT_ID is unset, or if_exists rejects the existing row.