Base Node Module helper classes.
Classes¶
AbstractNode(node_definition: madsci.common.types.node_types.NodeDefinition | None = None, node_config: madsci.common.types.node_types.NodeConfig | None = None)Base Node implementation, protocol agnostic, all node class definitions should inherit from or be based on this.
Note that this class is abstract: it is intended to be inherited from, not used directly.
Initialize the node class.
Ancestors (in MRO)¶
madsci.client.client_mixin.MadsciClientMixin
Descendants¶
madsci.node_module.rest_node_module.RestNode
Class variables¶
REQUIRED_CLIENTS: ClassVar[list[str]]:action_handlers: ClassVar[dict[str, callable]]- The handlers for the actions that the node supports.
action_history: ClassVar[dict[str, list[madsci.common.types.action_types.ActionResult]]]- The history of the actions that the node has performed.
config: ClassVar[madsci.common.types.node_types.NodeConfig]- The node configuration.
config_model: ClassVar[type[madsci.common.types.node_types.NodeConfig]]- The node config model class. This is the class that will be used to instantiate self.config.
logger: ClassVar[madsci.client.event_client.EventClient]- The event logger for this node
module_version: ClassVar[str]- The version of the module. Should match the version in the node definition.
node_definition: ClassVar[madsci.common.types.node_types.NodeDefinition]- The node definition.
node_state: ClassVar[dict[str, Any]]- The state of the node.
node_status: ClassVar[madsci.common.types.node_types.NodeStatus]- The status of the node.
supported_capabilities: ClassVar[madsci.common.types.node_types.NodeClientCapabilities]- The default supported capabilities of this node module class.
Methods¶
create_and_upload_file_datapoint(self, file_path: str | pathlib.Path, label: str | None = None) ‑> strCreate a FileDataPoint and upload it to the data manager.
Args: file_path: Path to the file to store label: Optional label for the datapoint
Returns: The ULID string ID of the uploaded datapoint
create_and_upload_value_datapoint(self, value: Any, label: str | None = None) ‑> strCreate a ValueDataPoint and upload it to the data manager.
Args: value: JSON-serializable value to store label: Optional label for the datapoint
Returns: The ULID string ID of the uploaded datapoint
get_action_history(self, action_id: str | None = None) ‑> dict[str, list[madsci.common.types.action_types.ActionResult]]Get the action history for the node or a specific action run.
get_action_result(self, action_id: str) ‑> madsci.common.types.action_types.ActionResultGet the most up-to-date result of an action on the node.
get_action_status(self, action_id: str) ‑> madsci.common.types.action_types.ActionStatusGet the status of an action on the node.
get_info(self) ‑> madsci.common.types.node_types.NodeInfoGet information about the node.
get_log(self) ‑> dict[str, madsci.common.types.event_types.Event]Return the log of the node
get_state(self) ‑> dict[str, typing.Any]Get the state of the node.
get_status(self) ‑> madsci.common.types.node_types.NodeStatusGet the status of the node.
lock(self) ‑> boolAdmin command to lock the node.
run_action(self, action_request: madsci.common.types.action_types.ActionRequest) ‑> madsci.common.types.action_types.ActionResultRun an action on the node.
run_admin_command(self, admin_command: madsci.common.types.admin_command_types.AdminCommands) ‑> madsci.common.types.admin_command_types.AdminCommandResponseRun the specified administrative command on the node.
set_config(self, new_config: dict[str, typing.Any]) ‑> madsci.common.types.node_types.NodeSetConfigResponseSet configuration values of the node.
shutdown_handler(self) ‑> NoneCalled to shut down the node. Should be used to clean up any resources.
start_node(self) ‑> NoneCalled once to start the node.
startup_handler(self) ‑> NoneCalled to (re)initialize the node. Should be used to open connections to devices or initialize any other resources.
state_handler(self) ‑> NoneCalled periodically to update the node state. Should set
self.node_statestatus_handler(self) ‑> NoneCalled periodically to update the node status. Should set
self.node_statusunlock(self) ‑> boolAdmin command to unlock the node.
upload_datapoint(self, datapoint: madsci.common.types.datapoint_types.DataPoint) ‑> strUpload a datapoint to the data manager and return its ID.
Args: datapoint: DataPoint object to upload
Returns: The ULID string ID of the uploaded datapoint
Raises: Exception: If upload fails
upload_datapoints(self, datapoints: list[madsci.common.types.datapoint_types.DataPoint]) ‑> list[str]Upload multiple datapoints to the data manager and return their IDs.
Args: datapoints: List of DataPoint objects to upload
Returns: List of ULID string IDs of the uploaded datapoints
Raises: Exception: If any upload fails