unitelabs.labware.resource

Packages

Attributes

  • Name
    __all__
    Type
    Value

    = [ "Resource", "MissingError", "OccupiedError", "Labware", "Instrument", "ResourceSchema", "ChildrenField", "JsonSchema" ]

    Description

Classes

  • Instrument

    Specialist equipment to perform work with it, e.g. spectrometer or incubator.

    MRO
    Decorators
    dataclasses.dataclass

    Methods

    • __init__(self, tags : dict) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        tags
        Type
        dict
        Default
        Description

    • __post_init__(self, *_kwargs) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        *_kwargs
        Type
        Default
        = ()
        Description

    • __init_subclass__(cls) -> None

      Parameters

      • Name
        cls
        Type
        Default
        Description

    • assign_to(self, parent : Group) -> None

      Set the parent of this resource to the given group.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        parent
        Type
        Group
        Default
        Description

        The group to which this resource is assigned to.

    • @deprecation.deprecated(deprecated_in='0.1.20', removed_in='0.2.0', current_version=__version__, details='Use `rotate_by` instead.')

      rotate(self, angle : int) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

    • rotate_by(self, angle : int) -> None

      Rotate clockwise by the given angle in degrees. Use negative numbers for counter clockwise rotation.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • rotate_to(self, angle : int) -> None

      Rotate to the given absolute angle in degrees.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • find(self, identifier : str) -> Resource

      Find a resource by its identifier.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The resource's identifier to search for.

      Response

      Type
      Resource
      Description

      The resource with the corresponding identifier.

      Exceptions

      Type
      TypeError
      Description
      If the identifier is a non string value.
      Type
      MissingResourceError
      Description
      If the resource could not be found.
    • __contains__(self, item : typing.Any) -> bool

      Check whether a resource is assigned to this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        item
        Type
        typing.Any
        Default
        Description

        The resource to search for.

      Response

      Type
      bool
      Description

      True if the resource could be found, False otherwise.

    • copy(self, **changes) -> typing_extensions.Self

      Return a copy of this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        **changes
        Type
        Default
        = {}
        Description

        Replace fields with values from `changes`.

      Response

      Type
      typing_extensions.Self
      Description

      A copy of this resource.

    • serialize(self) -> JsonSchema

      Serialize this resource as a JSON-like dictionary.

      Response

      Type
      JsonSchema
      Description

      The JSON-like dictionary with the resource's data.

    • @classmethod

      deserialize(cls, identifier : str, schema : JsonSchema) -> typing_extensions.Self

      Deserialize a JSON-like dictionary to a resource.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The identifier of the resource to deserialize.

      • Name
        schema
        Type
        JsonSchema
        Default
        Description

        The JSON-like dictionary with the resource's data.

      Response

      Type
      typing_extensions.Self
      Description

      The newly created resource.

    • @classmethod

      subclass_by_name(cls, name : str) -> typing.Optional[type[Resource]]

      Recursively find a resource subclass with the given name.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        name
        Type
        str
        Default
        Description

        The name of the class to find.

      Response

      Type
      typing.Optional[type[Resource]]
      Description

      The class with the given name, or `None` if no such class exists.

      Exceptions

      Type
      TypeError
      Description
      If the name is not a valid class name.

    Attributes

    • Name
      tags
      Type
      dict
      Value

      = dataclasses.field(default_factory=dict)

      Description

    • Name
      identifier
      Type
      str
      Value

      = dataclasses.field(default_factory=lambda: str(uuid.uuid4().hex[:8]))

      Description

    • Name
      rotation
      Type
      int
      Value

      = 0

      Description

    • Name
      dimensions
      Type
      Vector
      Value

      = dataclasses.field(default_factory=Vector)

      Description

    • Name
      location
      Type
      typing.Optional[Vector]
      Value

      = None

      Description

    • Name
      Schema
      Type
      type[marshmallow.Schema]
      Value

      = marshmallow.Schema

      Description

    • Name
      name
      Type
      str
      Value

      = None

      Description

      A human readable name to identify resources.

    • Name
      absolute_location
      Type
      Vector
      Value

      = None

      Description

      The absolute location of this resource.

    • Name
      width
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the x-axis.

    • Name
      depth
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the y-axis.

    • Name
      height
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the z-axis.

    • Name
      center
      Type
      Vector
      Value

      = None

      Description

      The center base of this resource.

  • Labware

    All the equipment used in many different types of laboratory.

    Decorators
    dataclasses.dataclass

    Methods

    • __init__(self, tags : dict) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        tags
        Type
        dict
        Default
        Description

        Key and value pairs that act as metadata for organizing your labware.

    • __post_init__(self, *_kwargs) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        *_kwargs
        Type
        Default
        = ()
        Description

    • __init_subclass__(cls) -> None

      Parameters

      • Name
        cls
        Type
        Default
        Description

    • assign_to(self, parent : Group) -> None

      Set the parent of this resource to the given group.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        parent
        Type
        Group
        Default
        Description

        The group to which this resource is assigned to.

    • @deprecation.deprecated(deprecated_in='0.1.20', removed_in='0.2.0', current_version=__version__, details='Use `rotate_by` instead.')

      rotate(self, angle : int) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

    • rotate_by(self, angle : int) -> None

      Rotate clockwise by the given angle in degrees. Use negative numbers for counter clockwise rotation.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • rotate_to(self, angle : int) -> None

      Rotate to the given absolute angle in degrees.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • find(self, identifier : str) -> Resource

      Find a resource by its identifier.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The resource's identifier to search for.

      Response

      Type
      Resource
      Description

      The resource with the corresponding identifier.

      Exceptions

      Type
      TypeError
      Description
      If the identifier is a non string value.
      Type
      MissingResourceError
      Description
      If the resource could not be found.
    • __contains__(self, item : typing.Any) -> bool

      Check whether a resource is assigned to this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        item
        Type
        typing.Any
        Default
        Description

        The resource to search for.

      Response

      Type
      bool
      Description

      True if the resource could be found, False otherwise.

    • copy(self, **changes) -> typing_extensions.Self

      Return a copy of this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        **changes
        Type
        Default
        = {}
        Description

        Replace fields with values from `changes`.

      Response

      Type
      typing_extensions.Self
      Description

      A copy of this resource.

    • serialize(self) -> JsonSchema

      Serialize this resource as a JSON-like dictionary.

      Response

      Type
      JsonSchema
      Description

      The JSON-like dictionary with the resource's data.

    • @classmethod

      deserialize(cls, identifier : str, schema : JsonSchema) -> typing_extensions.Self

      Deserialize a JSON-like dictionary to a resource.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The identifier of the resource to deserialize.

      • Name
        schema
        Type
        JsonSchema
        Default
        Description

        The JSON-like dictionary with the resource's data.

      Response

      Type
      typing_extensions.Self
      Description

      The newly created resource.

    • @classmethod

      subclass_by_name(cls, name : str) -> typing.Optional[type[Resource]]

      Recursively find a resource subclass with the given name.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        name
        Type
        str
        Default
        Description

        The name of the class to find.

      Response

      Type
      typing.Optional[type[Resource]]
      Description

      The class with the given name, or `None` if no such class exists.

      Exceptions

      Type
      TypeError
      Description
      If the name is not a valid class name.

    Attributes

    • Name
      tags
      Type
      dict
      Value

      = dataclasses.field(default_factory=dict)

      Description

    • Name
      identifier
      Type
      str
      Value

      = dataclasses.field(default_factory=lambda: str(uuid.uuid4().hex[:8]))

      Description

    • Name
      rotation
      Type
      int
      Value

      = 0

      Description

    • Name
      dimensions
      Type
      Vector
      Value

      = dataclasses.field(default_factory=Vector)

      Description

    • Name
      location
      Type
      typing.Optional[Vector]
      Value

      = None

      Description

    • Name
      Schema
      Type
      type[marshmallow.Schema]
      Value

      = marshmallow.Schema

      Description

    • Name
      name
      Type
      str
      Value

      = None

      Description

      A human readable name to identify resources.

    • Name
      absolute_location
      Type
      Vector
      Value

      = None

      Description

      The absolute location of this resource.

    • Name
      width
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the x-axis.

    • Name
      depth
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the y-axis.

    • Name
      height
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the z-axis.

    • Name
      center
      Type
      Vector
      Value

      = None

      Description

      The center base of this resource.

  • MissingError

    Raised when a resource was expected but none was found.

    Bases
    RuntimeError
  • OccupiedError

    Raised when a resource is already filling the spot.

    Bases
    RuntimeError
  • Resource

    Base class for labware resources.

    Bases
    abc.ABC
    Decorators
    marshmallow_dataclass.dataclass(base_schema=ResourceSchema)

    Methods

    • __post_init__(self, *_kwargs) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        *_kwargs
        Type
        Default
        = ()
        Description

    • __init_subclass__(cls) -> None

      Parameters

      • Name
        cls
        Type
        Default
        Description

    • assign_to(self, parent : Group) -> None

      Set the parent of this resource to the given group.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        parent
        Type
        Group
        Default
        Description

        The group to which this resource is assigned to.

    • @deprecation.deprecated(deprecated_in='0.1.20', removed_in='0.2.0', current_version=__version__, details='Use `rotate_by` instead.')

      rotate(self, angle : int) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

    • rotate_by(self, angle : int) -> None

      Rotate clockwise by the given angle in degrees. Use negative numbers for counter clockwise rotation.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • rotate_to(self, angle : int) -> None

      Rotate to the given absolute angle in degrees.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        angle
        Type
        int
        Default
        Description

        The angle in degrees to rotate the resource. Must be a multiple of 90°.

    • find(self, identifier : str) -> Resource

      Find a resource by its identifier.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The resource's identifier to search for.

      Response

      Type
      Resource
      Description

      The resource with the corresponding identifier.

      Exceptions

      Type
      TypeError
      Description
      If the identifier is a non string value.
      Type
      MissingResourceError
      Description
      If the resource could not be found.
    • __contains__(self, item : typing.Any) -> bool

      Check whether a resource is assigned to this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        item
        Type
        typing.Any
        Default
        Description

        The resource to search for.

      Response

      Type
      bool
      Description

      True if the resource could be found, False otherwise.

    • copy(self, **changes) -> typing_extensions.Self

      Return a copy of this resource.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        **changes
        Type
        Default
        = {}
        Description

        Replace fields with values from `changes`.

      Response

      Type
      typing_extensions.Self
      Description

      A copy of this resource.

    • serialize(self) -> JsonSchema

      Serialize this resource as a JSON-like dictionary.

      Response

      Type
      JsonSchema
      Description

      The JSON-like dictionary with the resource's data.

    • @classmethod

      deserialize(cls, identifier : str, schema : JsonSchema) -> typing_extensions.Self

      Deserialize a JSON-like dictionary to a resource.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        identifier
        Type
        str
        Default
        Description

        The identifier of the resource to deserialize.

      • Name
        schema
        Type
        JsonSchema
        Default
        Description

        The JSON-like dictionary with the resource's data.

      Response

      Type
      typing_extensions.Self
      Description

      The newly created resource.

    • @classmethod

      subclass_by_name(cls, name : str) -> typing.Optional[type[Resource]]

      Recursively find a resource subclass with the given name.

      Parameters

      • Name
        cls
        Type
        Default
        Description

      • Name
        name
        Type
        str
        Default
        Description

        The name of the class to find.

      Response

      Type
      typing.Optional[type[Resource]]
      Description

      The class with the given name, or `None` if no such class exists.

      Exceptions

      Type
      TypeError
      Description
      If the name is not a valid class name.

    Attributes

    • Name
      identifier
      Type
      str
      Value

      = dataclasses.field(default_factory=lambda: str(uuid.uuid4().hex[:8]))

      Description

    • Name
      rotation
      Type
      int
      Value

      = 0

      Description

    • Name
      dimensions
      Type
      Vector
      Value

      = dataclasses.field(default_factory=Vector)

      Description

    • Name
      location
      Type
      typing.Optional[Vector]
      Value

      = None

      Description

    • Name
      Schema
      Type
      type[marshmallow.Schema]
      Value

      = marshmallow.Schema

      Description

    • Name
      name
      Type
      str
      Value

      = None

      Description

      A human readable name to identify resources.

    • Name
      absolute_location
      Type
      Vector
      Value

      = None

      Description

      The absolute location of this resource.

    • Name
      width
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the x-axis.

    • Name
      depth
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the y-axis.

    • Name
      height
      Type
      decimal.Decimal
      Value

      = None

      Description

      The size of the resource along the z-axis.

    • Name
      center
      Type
      Vector
      Value

      = None

      Description

      The center base of this resource.

  • ChildrenField

    Bases
    marshmallow.fields.Pluck

    Methods

    • _deserialize(
        self,
        value,
        attr,
        data,
        partial,
        **kwargs
      ) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        value
        Type
        Default
        Description

      • Name
        attr
        Type
        Default
        Description

      • Name
        data
        Type
        Default
        Description

      • Name
        partial
        Type
        Default
        = None
        Description

      • Name
        **kwargs
        Type
        Default
        = {}
        Description

  • JsonSchema

    The structure used when serializing resources.

    Bases
    typing.TypedDict

    Attributes

    • Name
      root
      Type
      str
      Value

      = None

      Description

    • Name
      resources
      Type
      dict[str, dict[str, typing.Any]]
      Value

      = None

      Description

  • ResourceSchema

    Bases
    marshmallow.Schema

    Attributes

    • Name
      TYPE_MAPPING
      Type
      Value

      = {Decimal: DecimalField}

      Description

    • Name
      identifier
      Type
      Value

      = marshmallow.fields.String()

      Description

    • Name
      type
      Type
      Value

      = marshmallow.fields.Function(lambda obj: obj.__class__.__name__, dump_only=True)

      Description

    • Name
      parent
      Type
      Value

      = marshmallow.fields.Pluck(lambda: ResourceSchema(), 'identifier', dump_only=True, allow_none=True)

      Description

Copyright © 2024