stanza.routines
Module Contents
Classes
Functions
Data
logger
_routine_registry
API
Value: getLogger(...)
Value: None
Context object passed to routine functions containing resources and results.
Initialization
Initialize context with resource and results registries.
Decorator to register a function as a routine.
The decorated function receives:
- ctx: RoutineContext with ctx.resources and ctx.results
- **params: Merged config and user parameters
Usage: @routine def my_sweep(ctx, gate, voltages, measure_contact): device = ctx.resources.device return device.sweep_1d(gate, voltages, measure_contact)
@routine(name=“custom_name”) def analyze_sweep(ctx, **params):
Access previous sweep data
sweep_data = ctx.results.get(“my_sweep”) if sweep_data: voltages, currents = sweep_data
Do analysis…
return analysis_result
Get all registered routines.
Clear all registred routines
Simple runner that executes decorated routine functions with resources and configs.
Resources can be provided in two ways:
- Pass initialized resources directly via
resources
parameter - Pass configuration objects via
configs
parameter (runner instantiates resources)
When using the configs
parameter, a DataLogger is automatically created and registered
with name=“logger” for convenient logging within routines.
Examples:
With initialized resources
device = Device(name=“device”, …) logger = DataLogger(name=“logger”, …) runner = RoutineRunner(resources=[device, logger])
With configs (runner creates device + logger automatically)
device_config = DeviceConfig(…) runner = RoutineRunner(configs=[device_config])
Now ctx.resources.device and ctx.resources.logger are available
Initialization
Initialize runner with resources or configs.
Parameters:
Parameters:
- resources: List of resource objects with .name attribute (Device, DataLogger, etc.)
- configs: List of configuration objects (DeviceConfig, etc.) to instantiate resources from
Raises:
ValueError: If neither resources nor configs provided, or if both provided
Instantiate resources from configuration objects.
Parameters:
List of configuration objects (e.g., DeviceConfig)
Returns:
List of instantiated resource objects
Extract routine parameters from configuration objects (recursive).
Parameters:
List of configuration objects (e.g., DeviceConfig)
Returns:
Dictionary mapping routine names to their parameters
Recursively extract parameters from routine config and its nested routines.
Parameters:
The routine configuration to extract from
Dictionary to store extracted parameters
Execute a registered routine.
Parameters:
Name of the routine to run
Returns:
Result of the routine
Execute all routines from config in order.
Parameters:
If specified, run only nested routines under this parent.
Returns:
Dictionary mapping routine names to their results
Recursively run a routine and its nested routines.
Parameters:
The routine configuration to execute
Dictionary to store results
Get stored result from a routine.
List all registered routines.
List all stored results.