labthings_fastapi.server
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 LabThings-FastAPI tutorial for examples of how to set up a ThingServer.
Submodules
Attributes
Functions
|
Convert a string reference to an object. |
|
Create a ThingServer from a configuration dictionary. |
Package Contents
- labthings_fastapi.server.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:qualnamewherequalnameis the fully qualified name of the object within the module. This is the same format used by entrypoints` insetup.pyfiles.- Parameters:
object_reference – a string referencing a Python object to import.
- Returns:
the Python object.
- Raises:
ImportError – if the referenced object cannot be found or imported.
- labthings_fastapi.server.ThingDescription
- labthings_fastapi.server._thing_servers: weakref.WeakSet[labthings_fastapi.server.ThingServer]
- labthings_fastapi.server.PATH_REGEX
- labthings_fastapi.server.server_from_config(config: dict) ThingServer
Create a ThingServer from a configuration dictionary.
This function creates a
ThingServerand adds a number ofThinginstances from a configuration dictionary.- Parameters:
config – A dictionary, in the format used by Configuration files
- Returns:
A
ThingServerwith instances of the specifiedThingsubclasses attached. The server will not be started by this function.- Raises:
ImportError – if a Thing could not be loaded from the specified object reference.