Skip to content

Traits

The item models in datalab are assembled from traits: small mixin models that each contribute a related group of fields. Rather than every item type redeclaring who owns it or which collections it belongs to, it inherits the corresponding trait.

CollectionReference

Bases: BaseModel

A reference to a collection, used for inlining collection info within other models.

Config:

  • extra: allow
  • populate_by_name: True

immutable_id

immutable_id: PyObjectId

The immutable ID of the collection.

model_config

model_config = ConfigDict(extra='allow', populate_by_name=True)

HasLocation

Bases: BaseModel

location

location: str | None = None

The place where the item is located.

HasOwner

Bases: BaseModel

Trait mixin for models that record who created them and which groups can access them.

creator_ids

creator_ids: list[PyObjectId] = []

The database IDs of the user(s) who created the item.

creators

creators: list[Person] | None = None

Inlined info for the people associated with this item.

group_ids

group_ids: list[PyObjectId] = []

The database IDs of the group(s) that have read-access to this item.

groups

groups: list[Group] | None = None

Inlined info for the groups with access to this item.

HasRevisionControl

Bases: BaseModel

Trait mixin for models that track a revision history of their own state.

revision

revision: int = 1

The revision number of the entry.

revisions

revisions: dict[int, Any] | None = None

An optional mapping from old revision numbers to the model state at that revision.

version

version: int = 1

The version number used by the version control system for tracking snapshots.

HasSubstanceInfo

Bases: BaseModel

Trait mixin for models that have substance information.

CAS

CAS: str | None = None

The CAS Registry Number for the substance described by this entry.

GHS_codes

GHS_codes: str | None = None

A string describing any GHS hazard codes associated with this item. See pubchem.ncbi.nlm.nih.gov/ghs/ for code definitions.

chemform

chemform: str | None = None

A string representation of the chemical formula or composition associated with this sample.

The representation is relatively free-form; clients are expected parse and interpret HTML markup for subscripts and accept unicode characters for greek letters.

inchi

inchi: str | None = None

An International Chemical Identifier (InChI) string representation of chemicals/molecules associated with this sample.

inchi_key

inchi_key: str | None = None

A unique key derived from the InChI.

molar_mass

molar_mass: float | None = None

Mass per formula unit, in g/mol.

smiles

smiles: str | None = None

A SMILES string representation of the chemical structure associated with this sample.

HasSynthesisInfo

Bases: BaseModel

Trait mixin for models that have synthesis information.

synthesis_constituents

synthesis_constituents: list[Constituent] = []

A list of references to constituent materials giving the amount and relevant inlined details of consituent items.

synthesis_description

synthesis_description: str | None = None

Free-text details of the procedure applied to synthesise the sample

HasTags

Bases: BaseModel

Trait mixin for models that can be annotated with tags.

Note: this mixin only provides the stored tags field and its coercion. Inlining current tag names for display (and dropping references to deleted tags) is a read-time concern handled by pydatalab.mongo.resolve_tags_for_docs, which each entity's read path must call explicitly on the docs it returns.

tags

tags: list[EntryReference]

Tags applied to this entry: references to tags entries (by immutable_id).

IsCollectable

Bases: BaseModel

Trait mixin for models that can be added to collections.

collections

collections: list[CollectionReference]

Inlined info for the collections associated with this item.