ResourceSchema

A concrete resource instance created from a ResourceTemplateSchema.

Usage

Source

ResourceSchema()

Resources are the primary trackable entities in RECAP. They can represent physical objects (plates, samples), digital artifacts (data files), or logical items (computed results). Every resource carries:

  • An identity (~recap.schemas.common.CommonFields.id, name).
  • A reference to the template it was created from.
  • A hierarchy of child resources (auto-created from the template).
  • Property groups populated with live ~recap.schemas.attribute.AttributeValueSchema values.

Accessing and updating properties::

well = plate.children["A01"]
well.properties.content.volume.value   # 10.0
well.properties.content.volume = 8.5   # mutates in-place

Attributes: name: Display name of this resource instance. template: The ResourceTemplateSchema this instance was created from. parent: Lightweight reference to the parent resource, or None for top-level resources. Excluded from serialisation. children: Mapping of child name → child ResourceSchema. properties: A dynamically-generated Pydantic model whose fields are the property group slugs, each holding a PropertySchema.

Methods

Name Description
build_property_model() Convert the raw properties dict into a dynamic Pydantic model.

build_property_model()

Convert the raw properties dict into a dynamic Pydantic model.

Usage

Source

build_property_model()

After the initial parse, properties is a mapping of group slug → PropertySchema. This validator replaces it with a dynamically-created Pydantic model so that groups can be accessed as normal attributes (resource.properties.dimensions).

Idempotent: if properties is already a ~pydantic.BaseModel the validator returns immediately.