Skip to content

reference_config

Access to the bundled example instrument configuration.

Ships a small, valid reference configuration inside the installed package so that docstring examples, the example scripts, and end users can obtain a working configuration without a repository checkout. The configuration contains a micro-dispenser (dispenser) and a pipettor component; its network addresses are placeholders and must be replaced before connecting to hardware.

example_config_path()

Return a traversable path to the bundled example configuration JSON.

Returns:

Name Type Description
Traversable Any

Importable-resource path to example-config.json. Use

Any

its .open() / .read_text() methods; it may not be a real

Any

filesystem path when the package is installed as a zip.

Examples:

1
2
3
>>> from fluid_control import example_config_path
>>> example_config_path().name
'example-config.json'
Source code in src/fluid_control/reference_config.py
def example_config_path() -> Any:
    """
    Return a traversable path to the bundled example configuration JSON.

    Returns:
        Traversable: Importable-resource path to ``example-config.json``. Use
        its ``.open()`` / ``.read_text()`` methods; it may not be a real
        filesystem path when the package is installed as a zip.

    Examples:
        >>> from fluid_control import example_config_path
        >>> example_config_path().name
        'example-config.json'

    """
    return files("fluid_control").joinpath(_EXAMPLE_CONFIG_RESOURCE)

load_example_config()

1
2
3
4
5
Load and return the bundled example instrument configuration as a dict.

The returned mapping is the full instrument configuration and can be passed
directly to a device constructor. Select a component with ``component_id``
(``"micro-dispenser"`` or ``"pipettor"``).

Returns:

Name Type Description
dict dict[str, Any]

The parsed example instrument configuration.

Examples:

1
2
3
>>> from fluid_control import Dispenser, load_example_config
>>> config = load_example_config()
>>> dispenser = Dispenser(config=config, component_id="micro-dispenser")
Source code in src/fluid_control/reference_config.py
def load_example_config() -> dict[str, Any]:
    """
        Load and return the bundled example instrument configuration as a dict.

        The returned mapping is the full instrument configuration and can be passed
        directly to a device constructor. Select a component with ``component_id``
        (``"micro-dispenser"`` or ``"pipettor"``).

    Returns:
        dict: The parsed example instrument configuration.

    Examples:
        >>> from fluid_control import Dispenser, load_example_config
        >>> config = load_example_config()
        >>> dispenser = Dispenser(config=config, component_id="micro-dispenser")

    """
    with example_config_path().open("r", encoding="utf-8") as fh:
        return json.load(fh)