diff --git a/pydatalab/pydatalab/models/equipment.py b/pydatalab/pydatalab/models/equipment.py index 83f3edf48..13ffdca16 100644 --- a/pydatalab/pydatalab/models/equipment.py +++ b/pydatalab/pydatalab/models/equipment.py @@ -3,6 +3,9 @@ from pydantic import Field from pydatalab.models.items import Item +from pydatalab.models.utils import ( + EquipmentStatus, +) class Equipment(Item): @@ -21,3 +24,6 @@ class Equipment(Item): contact: Optional[str] """Contact information for equipment (e.g., email address or phone number).""" + + status: EquipmentStatus = Field(default=EquipmentStatus.WORKING) + """The status of the equipment, indicating its current state.""" diff --git a/pydatalab/pydatalab/models/items.py b/pydatalab/pydatalab/models/items.py index 4195f1ce6..e06cf735f 100644 --- a/pydatalab/pydatalab/models/items.py +++ b/pydatalab/pydatalab/models/items.py @@ -16,6 +16,7 @@ IsoformatDateTime, PyObjectId, Refcode, + ItemStatus, ) @@ -45,6 +46,9 @@ class Item(Entry, HasOwner, HasRevisionControl, IsCollectable, HasBlocks, abc.AB file_ObjectIds: List[PyObjectId] = Field([]) """Links to object IDs of files stored within the database.""" + status: ItemStatus = Field(default=ItemStatus.PLANNED) + """The status of the item, indicating its current state.""" + @validator("refcode", pre=True, always=True) def refcode_validator(cls, v): """Generate a refcode if not provided.""" @@ -54,6 +58,7 @@ def refcode_validator(cls, v): id = None prefix, id = v.split(":") if prefix is None or id is None: - raise ValueError(f"refcode missing prefix or ID {id=}, {prefix=} from {v=}") + raise ValueError( + f"refcode missing prefix or ID {id=}, {prefix=} from {v=}") return v diff --git a/pydatalab/pydatalab/models/utils.py b/pydatalab/pydatalab/models/utils.py index 9755a8925..bb71d7381 100644 --- a/pydatalab/pydatalab/models/utils.py +++ b/pydatalab/pydatalab/models/utils.py @@ -25,6 +25,25 @@ class ItemType(str, Enum): STARTING_MATERIALS = "starting_materials" +class ItemStatus(str, Enum): + """An enumeration of the status of items""" + + PLANNED = "planned" + ACTIVE = "active" + COMPLETED = "completed" + FAILED = "failed" + + +class EquipmentStatus(str, Enum): + """An enumeration of the status of equipments""" + + WORKING = "working" + BROKEN = "broken" + BEING_FIXED = "being_fixed" + DEFUNCT = "defunct" + NOT_BEING_FIXED = "not_being_fixed" + + class KnownType(str, Enum): """An enumeration of the types of entry known by this implementation, should be made dynamic in the future.""" @@ -106,7 +125,8 @@ def __get_validators__(self): def validate(self, v): q = self.Q(v) if not q.check(self._dimensions): - raise ValueError("Value {v} must have dimensions of mass, not {v.dimensions}") + raise ValueError( + "Value {v} must have dimensions of mass, not {v.dimensions}") return q @classmethod