viam.module
Submodules
Classes
Package Contents
- class viam.module.Module(address: str, *, log_level: int = logging.INFO)[source]
- parent: viam.robot.client.RobotClient | None = None
- server: viam.rpc.server.Server
- classmethod from_args() typing_extensions.Self [source]
Create a new Module with the args provided in the command line. The first argument after the command must be the socket path. If the second argument after the command is “–log-level=debug”, the Module’s logger will be DEBUG level. Otherwise, it will be INFO level. See LogLevel documentation in the RDK for more information on how to start modules with a “log-level” commandline argument.
- Raises:
Exception – If there is no socket path provided in the command line argument
- Returns:
a new Module instance
- Return type:
- classmethod run_with_models(*models: viam.resource.base.ResourceBase)[source]
- Async:
Module entrypoint that takes a list of ResourceBase implementations. In most cases you’ll want to use run_from_registry instead (see below).
- classmethod run_from_registry()[source]
- Async:
Module entrypoint that automatically includes all the resources you’ve created in your program.
Example:
- if __name__ == ‘__main__’:
asyncio.run(Module.run_from_registry())
Full example at examples/easy_resource/main.py.
- set_ready(ready: bool)[source]
Set the module’s ready state. The module automatically sets to READY on load. Setting to False can be useful in instances where the module is not instantly ready (for example waiting on hardware)
- Parameters:
ready (bool) – Whether the module is ready
- async add_resource(request: viam.proto.module.AddResourceRequest)[source]
- async reconfigure_resource(request: viam.proto.module.ReconfigureResourceRequest)[source]
- async remove_resource(request: viam.proto.module.RemoveResourceRequest)[source]
- async ready(request: viam.proto.module.ReadyRequest) viam.proto.module.ReadyResponse [source]
- add_model_from_registry(subtype: viam.resource.types.Subtype, model: viam.resource.types.Model)[source]
Add a pre-registered model to this Module
- async validate_config(request: viam.proto.module.ValidateConfigRequest) viam.proto.module.ValidateConfigResponse [source]