Skip to content

scene_pipelines.ingestion.scene.admin

Admin catalog writes (Lab, Project, …).

Pipeline roles should SELECT these tables only; use these helpers with an admin DB role. Lab and Project are marked WriteRole.ADMIN.

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.

ensure_project

ensure_project(project: DjRow[Project], *, deployment: DjRow[Deployment] | None = None, if_exists: DuplicatePolicy = REJECT) -> DjKey[Project]

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

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

Parameters:

Name Type Description Default
project DjRow[Project]

Full project insert dict (project_name, optional project_title, …).

required
deployment DjRow[Deployment] | None

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

None
if_exists DuplicatePolicy

Policy when project_name is already stored; see DuplicatePolicy.

REJECT

Returns:

Type Description
DjKey[Project]

Project primary key {project_name: ...}.

Raises:

Type Description
ValueError

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