unitelabs.sdk
unitelabs/sdk/__init__.py
Packages
Attributes
- __version__= version('unitelabs_sdk')
- __all__= [ "unitelabs.sdk.client.client.AsyncApiClient", "unitelabs.sdk.automate.audit.Audit", "unitelabs.sdk.client.client.Client", "unitelabs.sdk.automate.context.Context", "unitelabs.sdk.automate.context.ExecutionContext", "unitelabs.sdk.automate.audit.Operation", "unitelabs.sdk.automate.context.RuntimeContext", "unitelabs.sdk.client.client.SyncApiClient", "unitelabs.sdk.automate.context.get_context", "unitelabs.sdk.automate.logging.get_logger", "unitelabs.sdk.automate.decorators.phase", "unitelabs.sdk.automate.decorators.step", "unitelabs.sdk.automate.decorators.workflow" ]
Classes
Audit
classTrack records of all entities and the operations performed on them.
Methods
@classmethod
context(cls, context : dict) -> NoneSet the overall context to the given object.
contextdict@classmethod
emit(- cls,
- actor : str,
- operation : Operation,
- inputs : dict,
- outputs : dict,
- version : str,
- event_type : typing.Literal['lineage', 'audit', 'identification', 'measurement'] | str,
- extras : dict | None
Register a new operation. Emits a no-op when called outside an active context so lineage failures never break a running workflow. When `prefect.runtime` is available, the active task and flow run identifiers are attached to the event.
actorstrThe device or service performing the operation.operationThe operation being performed.inputsdictEntities consumed by the operation.outputsdictEntities produced by the operation.versionstr = '1.0.0'Schema version for the event payload.event_typetyping.Literal['lineage', 'audit', 'identification', 'measurement'] | str = 'lineage'Stream discriminator. Standard values are `"lineage"`, `"audit"`, `"identification"`, `"measurement"`. Workflow authors may extend with custom values; downstream consumers branch on this field to route events. Defaults to `"lineage"`.extrasdict | None = NoneOptional per-event metadata (e.g., volume, channel, run mode).
Context
classManages the active ExecutionContext across workflow boundaries.
Methods
@classmethod
@contextlib.contextmanager
provide(cls, context : RuntimeContext) -> collections.abc.Generator[None, None, None]Activate context for the duration of the block.
contextThe `ExecutionContext` to make active.collections.abc.Generator[None, None, None]@classmethod
@contextlib.asynccontextmanager
get_or_load(cls, path : pathlib.Path) -> collections.abc.AsyncGenerator[RuntimeContext, None]Yield the active context, loading from disk if none is set. Saves context state on exit for Prefect flow-boundary persistence.
pathpathlib.Path = _DEFAULT_PATHFilesystem path for context persistence.collections.abc.AsyncGenerator[RuntimeContext, None]@classmethod
load(cls, path : pathlib.Path) -> RuntimeContextLoad the context from the given location.
pathpathlib.Path = _DEFAULT_PATH@classmethod
save(cls, path : pathlib.Path) -> NoneSave the context to the given location.
pathpathlib.Path = _DEFAULT_PATH
ExecutionContext
classHolds serializable workflow execution state.
- Bases
- typing.Generic[T]
Methods
@classmethod
deserialize(cls, data : bytes) -> typing.SelfReconstruct context from serialized bytes.
databytesJSON-encoded bytes from serialize().typing.SelfA new ExecutionContext with the deserialized state.serialize(self) -> bytesSerialize context state to a versioned JSON envelope. State keys are written at the top level alongside `schema_version`. Consumers read events directly via `payload["events"]`, metadata via `payload["run_id"]`, etc. — no nested unwrapping needed.
bytesUTF-8 encoded JSON bytes of the versioned envelope.
Attributes
- state= initial_state or {}
Operation
classAn operation performed on an entity.
- Bases
- enum.Enum
Attributes
- ASPIRATE= 'aspirate'
- DISPENSE= 'dispense'
- PICK_UP_TIP= 'pick_up_tip'
- PUT_DOWN_TIP= 'put_down_tip'
- DISCARD_TIP= 'discard_tip'
- MOVE_LABWARE= 'move_labware'
- LOAD_LABWARE= 'load_labware'
- UNLOAD_LABWARE= 'unload_labware'
RuntimeContext
classExecution context available within a running workflow.
- Bases
- ExecutionContext[T]
Methods
Attributes
- _clientAsyncApiClient | None = None
- devicesdict = {}
- clientAsyncApiClient = NoneA client instance for direct communication with the UniteLabs API.
AsyncApiClient
classAsynchronous API client for UniteLabs services.
- MRO
- └─── WorkflowsAsyncClient
- └──── SubscriptionsAsyncClient
- └───── ActionsAsyncClient
- └────── ModulesAsyncClient
- └─────── DevicesAsyncClient
- └──────── ServicesAsyncClient
- └───────── AsyncApiClient
Client
classDeprecated: Use AsyncApiClient instead.
- MRO
- └─── WorkflowsAsyncClient
- └──── SubscriptionsAsyncClient
- └───── ActionsAsyncClient
- └────── ModulesAsyncClient
- └─────── DevicesAsyncClient
- └──────── ServicesAsyncClient
- └───────── AsyncApiClient
- └────────── Client
Methods
__init__(self, *args, **kwargs) -> None*args= ()**kwargs= {}
SyncApiClient
classSynchronous API client for UniteLabs services.
- MRO
- └─── SecretsSyncClient
- └──── WorkflowsSyncClient
- └───── ActionsSyncClient
- └────── ModulesSyncClient
- └─────── DevicesSyncClient
- └──────── ServicesSyncClient
- └───────── SyncApiClient