Declarations .md

Declare features, schemas, record types, sheets, and records.

Features

class lamindb_setup.evolve.FeatureType(name, *, type=None, space_uid=None)

Declare a type that groups related features.

Parameters:
  • name (str) – Type name within its parent type and space.

  • type (FeatureType | None, default: None) – Optional parent feature type.

  • space_uid (SpaceUID | None, default: None) – Target space; otherwise use the plan’s default.

property uid: Promise[FeatureUID, Self]

Get a promise for the UID of the materialized feature type.

get(ctx)

Read-only lookup of the materialized feature type.

Return type:

Feature | None

stage(ctx)

Build the unsaved LaminDB Feature for this feature type.

Return type:

Feature

class lamindb_setup.evolve.Feature(name, *, dtype, type=None, synonyms=None, unit=None, description=None, nullable=None, default_value=None, coerce=None, space_uid=None)

Declare a feature and its validation settings.

Creating a feature inside a running plan registers it without saving it. Use LaminDType(float), for example, to declare numeric measurements.

Parameters:
  • name (str) – Feature name within its type and space.

  • dtype (LaminDType[TypeVar(T)] | ResolvedDType) – A LaminDType or resolved dtype specification.

  • type (FeatureType | None, default: None) – Optional feature type.

  • synonyms (list[str] | None, default: None) – Alternative names.

  • unit (str | None, default: None) – Unit of measurement.

  • description (str | None, default: None) – Human-readable description.

  • nullable (bool | None, default: None) – Whether values may be null. None leaves the setting unspecified.

  • default_value (Any | None, default: None) – Default used during validation.

  • coerce (bool | None, default: None) – Whether validation may coerce values to the dtype.

  • space_uid (SpaceUID | None, default: None) – Target space; otherwise use the plan’s default.

property uid: Promise[FeatureUID, Self]

Get a promise for the UID of the materialized feature.

get(ctx)

Read-only lookup of the materialized feature.

Return type:

Feature | None

stage(ctx)

Build the unsaved LaminDB Feature for this feature.

Return type:

Feature

Schemas

class lamindb_setup.evolve.SchemaType(name, *, description=None, type=None, space_uid=None)

Declare a type that groups related schemas.

A schema type classifies schemas; it does not define validation rules. Use type for a parent type and space_uid to select its space.

property uid: Promise[SchemaUID, Self]

Get a promise for the UID of the materialized schema type.

get(ctx)

Read-only lookup of the materialized schema type.

Return type:

Schema | None

stage(ctx)

Build the unsaved LaminDB Schema for this schema type.

Return type:

Schema

class lamindb_setup.evolve.Schema(name=None, *, features, index=None, optionals=None, description=None, type=None, otype=None, slots=None, formats=None, itype=None, dtype=None, flexible=None, coerce=None, minimal_set=True, ordered_set=False, maximal_set=False, space_uid=None)

Declare validation rules for a dataset or a sheet’s records.

Parameters:
  • name (str | None, default: None) – Schema name within its type and space.

  • features (list[Feature]) – Member features; pass an empty list for a composite or dynamic schema.

  • index (Feature | None, default: None) – Feature that identifies rows. It cannot be optional.

  • optionals (list[Feature] | None, default: None) – Members that may be absent, using objects from features.

  • description (str | None, default: None) – Human-readable description.

  • type (SchemaType | None, default: None) – Optional schema type.

  • otype (Literal['DataFrame', 'AnnData', 'MuData', 'SpatialData'] | None, default: None) – Dataset object type for a composite schema.

  • slots (dict[str, lamindb.Schema] | None, default: None) – Child schemas keyed by dataset component, such as obs and var.

  • formats (dict[str, dict[str, Any]] | None, default: None) – Storage-format constraints checked during curation.

  • itype (type[SQLRecord] | DeferredAttribute | None, default: None) – Registry or registry field for dynamic members.

  • dtype (LaminDType | None, default: None) – Shared dtype for dynamic members.

  • flexible (bool | None, default: None) – Include additional features of the same itype in validation and annotation.

  • coerce (bool | None, default: None) – Whether validation may coerce values to the dtype.

  • minimal_set (bool, default: True) – Require all non-optional members.

  • ordered_set (bool, default: False) – Require the declared member order.

  • maximal_set (bool, default: False) – Reject members outside the schema.

  • space_uid (SpaceUID | None, default: None) – Target space; otherwise use the plan’s default.

property itype: Any

The schema’s itype, re-resolved against the connected instance.

property dtype: Any

The schema’s dtype, re-resolved against the connected instance.

property uid: Promise[SchemaUID, Self]

Get a promise for the UID of the materialized schema.

get(ctx)

Read-only lookup of the materialized schema.

Named schemas are matched by name; unnamed schemas are matched only when a uid is recorded in the lock (or pinned by another instance’s lock), since LaminDB addresses them by content hash and dedups them on save.

Return type:

Schema | None

stage(ctx)

Build the unsaved LaminDB Schema for this schema.

Return type:

Schema

Records and sheets

class lamindb_setup.evolve.RecordType(name, *, description=None, type=None, space_uid=None, single_space_uid=None, exclude_children_from_plans=False)

Declare a type that classifies records (is_type=True).

Use type for a parent type and space_uid for the type’s own space. single_space_uid restricts its records to one space. To also constrain their feature values, declare a Sheet.

property uid: Promise[RecordUID, Self]

Get a promise for the UID of the materialized record type.

get(ctx)

Read-only lookup of the materialized record type.

Return type:

Record | None

stage(ctx)

Build the unsaved LaminDB Record for this record type.

Return type:

Record

class lamindb_setup.evolve.Sheet(name, *, schema, description=None, type=None, space_uid=None, single_space_uid=None, is_experiment_sheet=False, exclude_children_from_plans=False)

Declare a record type whose records must satisfy schema.

The schema must be a Schema, not a schema type. Its index, if set, must have dtype str because index values are stored in Record.name. Other settings follow RecordType.

stage(ctx)

Build the unsaved LaminDB Record for this sheet, with its schema.

Return type:

Record

class lamindb_setup.evolve.Record(name=None, *, type=None, features=None, description=None, reference=None, reference_type=None, space_uid=None)

Seed a named record, optionally with a type and feature values.

features maps feature declarations or names to values. Existing records are left unchanged when the plan is reapplied, and removing a declaration does not delete the record. Declare an explicit data migration to update or remove it.

property uid: Promise[RecordUID, Self]

Get a promise for the UID of the materialized record.

get(ctx)

Read-only lookup of the materialized record.

Records are seeded. The lookup tries the UID from this instance’s lock or another instance’s lock, then matches by name and parent type. Finalizing the plan checks that a name was provided.

Return type:

Record | None

stage(ctx)

Build the unsaved LaminDB Record for this record.

Return type:

Record