ochra.common.spaces

lab

class ochra.common.spaces.lab.Lab

Bases: object

Represents a laboratory containing stations and robots.

This class provides methods to retrieve and manage stations and robots within the laboratory environment.

get_robot(robot)

Retrieve a specific robot from the lab.

Parameters:

robot (str | type | UUID) – The name, type, or UUID of the robot.

Returns:

The retrieved robot.

Return type:

Type[Robot]

get_robots()

Retrieve all robots in the lab.

Returns:

A list of robots in the lab.

Return type:

List[Type[Robot]]

get_station(station_name)

Retrieve a specific station from the lab.

Parameters:

station_name (str) – The name of the station.

Returns:

The retrieved station.

Return type:

Station

get_stations()

Retrieve all stations in the lab.

Returns:

A list of stations in the lab.

Return type:

List[Station]

location

pydantic model ochra.common.spaces.location.Location

Bases: DataModel

Represents a physical location within a laboratory environment.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field additional_metadata: Dict[str, Any] [Optional]

Supplementary metadata or contextual information about the location.

field lab: str [Required]

Name of the laboratory.

field landmarks: List[str] [Optional]

Distinctive features or markers to help identify the location.

field place: str = ''

Precise spot within the room (e.g., bench, shelf, cabinet).

field room: str = ''

Specific room or area within the laboratory.

station

pydantic model ochra.common.spaces.station.Station

Bases: DataModel

Represents a laboratory station containing devices, robots, and inventory.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field devices: List[Type[Device]] [Optional]

Devices associated with the station.

field inventory: Inventory = None

Inventory associated with the station.

field location: Location [Required]

Physical location of the station.

field locked: UUID | None = None

Session ID of the user who has locked the station, if any.

field name: str [Required]

Station name.

field operation_record: List[Operation] [Optional]

History of operations performed.

field status: ActivityStatus = ActivityStatus.IDLE

Current operational status (default: IDLE).

field type: StationType [Required]

Station category/type.

get_device(device_identifier)

Retrieve a device from the station.

Parameters:

device_identifier (str | UUID) – The device name or its unique identifier.

Returns:

The retrieved device.

Return type:

Type[Device]

get_robot(robot_identifier)

Retrieve a robot from the station.

Parameters:

robot_identifier (str | UUID) – The robot name or its unique identifier.

Returns:

The retrieved robot.

Return type:

Type[Robot]

lock(session_id)

Lock the station for the given session.

Parameters:

session_id (UUID) – The session ID requesting the lock.

Raises:

Exception – If the station is already locked by another session.

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None

unlock(session_id)

Unlock the station for the given session.

Parameters:

session_id (UUID) – The session ID requesting the unlock.

Raises:

Exception – If the session does not hold the lock and is not ADMIN.