labthings_fastapi.server ======================== .. py:module:: labthings_fastapi.server .. autoapi-nested-parse:: Code supporting the LabThings server. LabThings wraps the `fastapi.FastAPI` application in a `.ThingServer`, which provides the tools to serve and manage `.Thing` instances. See the :ref:`tutorial` for examples of how to set up a `.ThingServer`. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/labthings_fastapi/server/fallback/index Attributes ---------- .. autoapisummary:: labthings_fastapi.server.ThingDescription labthings_fastapi.server._thing_servers labthings_fastapi.server.PATH_REGEX Functions --------- .. autoapisummary:: labthings_fastapi.server.object_reference_to_object labthings_fastapi.server.server_from_config Package Contents ---------------- .. py:function:: object_reference_to_object(object_reference: str) -> Any Convert a string reference to an object. This is taken from: https://packaging.python.org/en/latest/specifications/entry-points/ The format of the string is `module_name:qualname` where `qualname` is the fully qualified name of the object within the module. This is the same format used by entrypoints` in `setup.py` files. :param object_reference: a string referencing a Python object to import. :return: the Python object. :raise ImportError: if the referenced object cannot be found or imported. .. py:data:: ThingDescription .. py:data:: _thing_servers :type: weakref.WeakSet[labthings_fastapi.server.ThingServer] .. py:data:: PATH_REGEX .. py:function:: server_from_config(config: dict) -> ThingServer Create a ThingServer from a configuration dictionary. This function creates a `.ThingServer` and adds a number of `.Thing` instances from a configuration dictionary. :param config: A dictionary, in the format used by :ref:`config_files` :return: A `.ThingServer` with instances of the specified `.Thing` subclasses attached. The server will not be started by this function. :raise ImportError: if a Thing could not be loaded from the specified object reference.