scene_pipelines.core
Shared core helpers (config + registry / versioning / hash / types).
WriteRole
Settings
dataclass
SchemaRegistry
Track schemas created via make_schema and bind them on demand.
Lazy by default: make_schema returns an unbound dj.Schema but
remembers the logical suffix (and create_tables) so activate /
activate_all can bind without re-stating the name. When
AUTO_ACTIVATE is set, make_schema binds immediately.
Entries are keyed by suffix: a suffix is registered once, so a lab schema
cannot silently reuse a shared one (e.g. "mouse"). Reuse a registered
schema with get; inspect all with the schemas property.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Label for this registry instance (e.g. |
schemas
property
Snapshot map of suffix → dj.Schema (mutations do not affect the registry).
make_schema
Create a DataJoint schema, unbound unless AUTO_ACTIVATE is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
Logical name without prefix (e.g. |
required |
create_tables
|
bool | None
|
Forwarded when activating; |
None
|
Returns:
| Type | Description |
|---|---|
Schema
|
A |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
activate
activate(suffix: str, *, create_tables: bool | None = None, connection: Any | None = None) -> Schema
Bind a registered schema by suffix using activate_schema.
Any dependency schemas are activated first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
Logical name without prefix (e.g. |
required |
create_tables
|
bool | None
|
Forwarded to |
None
|
connection
|
Any | None
|
Optional DataJoint connection forwarded to activate. |
None
|
Returns:
| Type | Description |
|---|---|
Schema
|
The registered |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
RuntimeError
|
If a table is referenced from an unactivated schema. The schema is left unbound. |
activate_all
Activate every registered schema that is still unbound.
Skips schemas that already have a database set. Per-schema
create_tables from make_schema is used unless overridden here.
Dependcency schemas are activated first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
create_tables
|
bool | None
|
Shared create-tables flag. When omitted, each entry uses the value stored at registration. |
None
|
connection
|
Any | None
|
Optional DataJoint connection forwarded to each
|
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a referenced schema could not be bound first; see
|
SchemaVersionError
Bases: RuntimeError
DB schema definition version does not match installed code.
sync_authority_of
sync_authority_of(table: type) -> SyncAuthority
Return the table's sync authority: its marker, its master's, or ORIGIN.
write_role_of
Return the table's write role, or None when INSERT is unrestricted.
load_settings
load_settings() -> Settings
Resolve settings from the environment. Pure: no mutation, no caching.
atomic
Open a transaction, or join the one already open (DataJoint cannot nest).
lookup_key
lookup_key(table: type[Manual], restriction: DjKey) -> DjKey | None
Return the primary key of the row matching restriction, or None.
restriction should cover a unique index (e.g. lab_id + a code), so
at most one row matches.
activate_schema
activate_schema(schema: Schema, suffix: str, *, create_tables: bool = True, connection: Any | None = None) -> Schema
Run DataJoint Schema.activate() with {DJ_SCHEMA_PREFIX}{suffix}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Schema
|
Unbound (or rebound) |
required |
suffix
|
str
|
Logical schema name without prefix (e.g. |
required |
create_tables
|
bool
|
Forwarded to |
True
|
connection
|
Any | None
|
Optional DataJoint connection forwarded to |
None
|
Returns:
| Type | Description |
|---|---|
Schema
|
The same |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |