scene_pipelines.core.registry
DataJoint schema registry with lazy-by-default activation.
Schemas created via SchemaRegistry.make_schema stay unbound unless
AUTO_ACTIVATE is set. Bind later with activate / activate_all, or
call activate_schema for any dj.Schema with an explicit suffix.
Foreign keys (-> Lab) resolve through the names imported in the module that
defines the table, as usual in DataJoint. The registry deliberately does not
inject extra names: shared tables must reference the shared tables, and labs
extend them by referencing them from their own schemas.
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
|
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 |