ochra.common.utils package

enum

class ochra.common.utils.enum.ActivityStatus(*values)

Bases: IntEnum

An enumeration representing different activity statuses for devices and stations.

BUSY = 1

Represents a busy state.

ERROR = -1

Represents an error state.

IDLE = 0

Represents an idle state.

class ochra.common.utils.enum.MobileRobotState(*values)

Bases: IntEnum

An enumeration representing different states of a mobile robot.

AVAILABLE = 0

Robot is available for operation.

CHARGING = 3

Robot is charging its battery.

ERROR = -1

Represents an error state.

MANIPULATING = 1

Robot is manipulating an object.

NAVIGATING = 2

Robot is navigating through the environment.

class ochra.common.utils.enum.OperationStatus(*values)

Bases: IntEnum

An enumeration representing different statuses of an operation.

ASSIGNED = 1

Operation has been assigned to a device or station.

COMPLETED = 3

Operation has been completed.

CREATED = 0

Operation has been created.

IN_PROGRESS = 2

Operation is currently in progress.

class ochra.common.utils.enum.PatchType(*values)

Bases: IntEnum

An enumeration representing different types of patches for modifying data structures.

DICT_DELETE = 7

Represents a delete operation for dictionaries.

DICT_INSERT = 6

Represents an insert operation for dictionaries.

LIST_APPEND = 2

Represents an append operation for lists.

LIST_DELETE = 5

Represents a delete operation for lists.

LIST_INSERT = 4

Represents an insert operation for lists.

LIST_POP = 3

Represents a pop operation for lists.

SET = 1

Represents a set operation.

class ochra.common.utils.enum.PhysicalState(*values)

Bases: IntEnum

An enumeration representing different physical states of matter.

GAS = 2

Represents a gas physical state

LIQUID = 1

Represents a liquid physical state

SOLID = 0

Represents a solid physical state

UNKNOWN = -1

Represents an unknown physical state

class ochra.common.utils.enum.ResultDataStatus(*values)

Bases: IntEnum

An enumeration representing different statuses of result data.

AVAILABLE = 1

Result data is available.

UNAVAILABLE = -1

Result data is unavailable yet.

UPLOADING = 0

Result data is currently uploading.

class ochra.common.utils.enum.StationType(*values)

Bases: IntEnum

An enumeration representing different types of stations.

MOBILE_ROBOT_STATION = 2

Represents a mobile robot station

STORAGE_STATION = 0

Represents a storage station that does not have any devices

WORK_STATION = 1

Represents a work station

logging_config

ochra.common.utils.logging_config.get_console_handler(formatter, level=20)

Get the console handler configuration.

Parameters:
  • formatter (str) – The formatter to use.

  • level (int, optional) – The logging level. Defaults to logging.INFO.

Returns:

The console handler configuration.

Return type:

dict

ochra.common.utils.logging_config.get_detailed_format()

Get the detailed log message format.

ochra.common.utils.logging_config.get_logger_config(handlers, level=20, propagate=False)

Get the logger configuration.

Parameters:
  • handlers (List[str]) – The list of handlers to use.

  • level (int, optional) – The logging level. Defaults to logging.INFO.

  • propagate (bool, optional) – Whether to propagate the log messages. Defaults to False.

Return type:

Dict

ochra.common.utils.logging_config.get_rotating_file_handler(formatter, file_path, level=10)

Get the rotating file handler configuration.

Parameters:
  • formatter (str) – The formatter to use.

  • file_path (str) – The path to the log file.

  • level (int, optional) – The logging level. Defaults to logging.DEBUG.

Returns:

The rotating file handler configuration.

Return type:

dict

ochra.common.utils.logging_config.get_smtp_handler(formatter, mailhost, fromaddr, toaddrs, subject, credentials=None, secure=(), level=10)

Get the SMTP handler configuration.

Parameters:
  • formatter (str) – The formatter to use.

  • mailhost (str) – The mail server host.

  • fromaddr (str) – The sender’s email address.

  • toaddrs (List[str]) – The recipient email addresses.

  • subject (str) – The email subject.

  • credentials (Tuple[str, str] | None, optional) – The SMTP server credentials. Defaults to None.

  • secure (Tuple, optional) – The secure connection parameters. Defaults to ().

  • level (int, optional) – The logging level. Defaults to logging.DEBUG.

Returns:

The SMTP handler configuration.

Return type:

dict

ochra.common.utils.logging_config.get_standard_format()

Get the standard log message format.

misc

ochra.common.utils.misc.convert_to_data_model(a_dict)

Convert a dict to a DataModel.

Parameters:

a_dict (Dict) – The dict to convert.

Returns:

The converted DataModel.

Return type:

DataModel

ochra.common.utils.misc.is_data_model(obj)

Check if an dict is a DataModel.

Parameters:

obj (Any) – The object to check.

Returns:

True if the object is a DataModel, False otherwise.

Return type:

bool

ochra.common.utils.misc.is_valid_uuid(string)

Check if a string is a valid UUID.

Parameters:

string (str) – The string to check.

Returns:

True if the string is a valid UUID, False otherwise.

Return type:

bool

mixins

class ochra.common.utils.mixins.RestProxyMixin

Bases: object

Mixin that changes class behavior such that its properties are accessed via REST API calls to a lab engine. This proxies both getters and setters.

When used in a class, it replaces field getters and setters (except ‘id’ and ‘cls’) with property accessors that interact with the backend through LabConnection. This ensures property access is always synchronized with the remote data source.

classmethod from_id(object_id)

Create an instance of the class by fetching data from the REST API using the provided object ID.

Parameters:

object_id (UUID) – The unique identifier for the model instance.

Returns:

An instance of the class populated with data from the REST API.

class ochra.common.utils.mixins.RestProxyMixinReadOnly(*args, **kwargs)

Bases: object

Mixin that changes class behavior such that its properties are accessed via REST API calls to a lab engine. This proxies only getters.

When used in a class, it replaces field getters (except ‘id’ and ‘cls’) with property accessors that interact with the backend through LabConnection. This ensures property access is always synchronized with the remote data source.

classmethod from_id(object_id)

Create an instance of the class by fetching data from the REST API using the provided object ID.

Parameters:

object_id (UUID) – The unique identifier for the model instance.

Returns:

An instance of the class populated with data from the REST API.

singleton_meta

class ochra.common.utils.singleton_meta.SingletonMeta

Bases: type

Thread-safe Singleton metaclass.

Ensures that only one instance of a class exists, even in multi-threaded environments.