Agent Command Interpreters
Command interpreters implement the control logic for QN functions managed by an Agent. Each interpreter registers its callback function for a specific RPC command.
When a Controller makes a QN function call by invoking the corresponding RPC on an agent, the callback handles the function execution. Each interpreter is initialized with HAL instances that provide real-time device driver access, allowing the interpreter to control real-time hardware.
Abstract Interfaces
Interpreter Base
- class quantnet_agent.hal.HAL.Interpreter(hal)[source]
Abstract base class for the Agent Interpreter module.
Example:
i = Interpreter(hal)
- Parameters:
hal – HAL object created by
node.
Core Interpreter
- class quantnet_agent.hal.HAL.CoreInterpreter(node)[source]
Abstract base class for the built-in Agent Interpreter module (e.g.,
scheduler).Example:
i = CoreInterpreter(node)
- Parameters:
node –
nodeobject created bynode.
- abstractmethod get_commands()[source]
Returns a dictionary of RPC handlers for a built-in interpreter to register with the RPC server in the controller. The dictionary keys are the names of RPC endpoints, and the values are lists composed of an RPC handler pointer and a schema model corresponding to the RPC.
Example:
def get_commands(self): commands = { "scheduler.getSchedule": [self.get_schedule, "quantnet_mq.schema.models.scheduler.getSchedule"] } return commands
Command Interpreter
- class quantnet_agent.hal.HAL.CMDInterpreter(hal)[source]
Abstract base class for the Agent command Interpreter module (e.g., Link calibration module
calibration).Example:
i = CMDInterpreter(hal)
- Parameters:
hal – HAL object created by
node.
- abstractmethod get_commands()[source]
Returns a dictionary of RPC handlers for a command interpreter to register with the RPC server in the controller. The dictionary keys are the names of RPC endpoints, and the values are lists composed of an RPC handler pointer and a schema model corresponding to the RPC.
Example:
def get_commands(self): commands = { "calibration.calibration": [self.measure, "quantnet_mq.schema.models.calibration.calibration"] } return commands
Scheduleable Interpreter
- class quantnet_agent.hal.HAL.ScheduleableInterpreter(hal)[source]
Abstract base class for a schedulable Agent command Interpreter module (e.g.,
ExperimentFramework).Example:
i = ScheduleableInterpreter(hal)
- Parameters:
hal – HAL object created by
node.
- abstractmethod get_commands()[source]
Returns a dictionary of RPC handlers for a schedulable command interpreter to register with the RPC server in the controller. The dictionary keys are the names of RPC endpoints, and the values are lists composed of an RPC handler pointer and a schema model corresponding to the RPC.
Example:
def get_commands(self): commands = { "experiment.getState": [self.get_state, "quantnet_mq.schema.models.experiment.getState"] } return commands
- abstractmethod get_schedulable_commands()[source]
Returns a dictionary of RPC handlers for a schedulable command interpreter to register with the RPC server in the two-level scheduler. The RPC endpoints returned by this function are used by the agent scheduler instead of the agent node, enabling the scheduler to allocate a handler to an available timeslot when requested by the global scheduler.
Keys in the dictionary are the names of the RPC endpoints, and the values are lists composed of an RPC handler pointer, a schema model corresponding to the RPC, and a schema model for the response.
Example:
def get_schedulable_commands(self): commands = { "experiment.submit": [ self.submit, "quantnet_mq.schema.models.experiment.submit", experiment.submitResponse, ] } return commands
Local Task Interpreter
- class quantnet_agent.hal.HAL.LocalTaskInterpreter(hal)[source]
Abstract base class for a local Agent command Interpreter module (e.g., local device calibration).
Example:
i = LocalTaskInterpreter(hal)
- Parameters:
hal – HAL object created by
node.