> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.conductorquantum.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conductorquantum.com/_mcp/server.

# stanza.utils



## Module Contents

### Functions

| Name | Description |
|------|-------------|
| [`substitute_parameters`](#stanzautilssubstitute_parameters) | Substitute parameters in a template string. |
| [`get_config_resource`](#stanzautilsget_config_resource) | Get config file content |
| [`load_device_config`](#stanzautilsload_device_config) | Load a device configuration YAML file. |
| [`generate_channel_configs`](#stanzautilsgenerate_channel_configs) | Generate ChannelConfigs for the device. |
| [`device_from_config`](#stanzautilsdevice_from_config) | Create a device from a DeviceConfig object. |
| [`device_from_yaml`](#stanzautilsdevice_from_yaml) | Load a device from a YAML configuration file. |

### API

```python
stanza.utils.substitute_parameters(
    template: str, substitutions: dict[str, typing.Any]
) -> str
```

Substitute parameters in a template string.

**Parameters:**

<ParamField path="template" type="str">
  The template string to substitute parameters in.
</ParamField>

<ParamField path="substitutions" type="dict[str, typing.Any]">
  A dictionary of substitutions to make.
</ParamField>

**Returns:**

The substituted string.


```python
stanza.utils.get_config_resource(
    config_path: str | pathlib.Path, encoding: str = 'utf-8'
) -> str
```

Get config file content

**Parameters:**

<ParamField path="config_path" type="str | pathlib.Path">
  The path to the config file.
</ParamField>

<ParamField path="encoding" type="str" default="'utf-8'">
  The encoding of the config file.
</ParamField>

**Returns:**

The config file content.


```python
stanza.utils.load_device_config(
    config_path: str | pathlib.Path, is_stanza_config: bool = False
) -> stanza.models.DeviceConfig
```

Load a device configuration YAML file.

**Parameters:**

<ParamField path="is_stanza_config" type="bool" default="False">
  Whether the config is a stanza config.
</ParamField>

**Returns:**

The device configuration.

**Raises:**

ValueError: If the file cannot be loaded.


```python
stanza.utils.generate_channel_configs(device_config: stanza.models.DeviceConfig) -> dict[str, stanza.base.channels.ChannelConfig]
```

Generate ChannelConfigs for the device.

**Parameters:**

<ParamField path="device_config" type="stanza.models.DeviceConfig">
  The device configuration.
</ParamField>

**Returns:**

A dictionary mapping of gate/contact name to ChannelConfigs.


```python
stanza.utils.device_from_config(
    device_config: stanza.models.DeviceConfig, **driver_kwargs: typing.Any
) -> stanza.device.Device
```

Create a device from a DeviceConfig object.

**Parameters:**

<ParamField path="device_config" type="stanza.models.DeviceConfig">
  The device configuration object.
</ParamField>

**Returns:**

A configured Device instance with instantiated instruments.

**Raises:**

ValueError: If required driver field is missing or instruments cannot be instantiated.


```python
stanza.utils.device_from_yaml(
    config_path: str | pathlib.Path,
    is_stanza_config: bool = False,
    **driver_kwargs: typing.Any
) -> stanza.device.Device
```

Load a device from a YAML configuration file.

**Parameters:**

<ParamField path="config_path" type="str | pathlib.Path">
  Path to the device configuration YAML file.
</ParamField>

<ParamField path="is_stanza_config" type="bool" default="False">
  Whether the config is a stanza config.
</ParamField>

**Returns:**

A configured Device instance with instantiated instruments.

**Raises:**

ValueError: If required driver field is missing or instruments cannot be instantiated.