Imports
In SPX SDK docs, “imports” covers the mechanisms used to bring Python code into a running SPX configuration.
Use imports when YAML alone is not enough:
loading custom Python classes from local
.pyfiles (quick prototyping, tests),binding Python object properties/methods to SPX attributes,
or wiring lifecycle methods (
start/run/stop) into a model definition.
Two common patterns
Registry-based components (recommended for libraries)
Package your extension code as a Python module and register classes via the SDK registry. This is the most maintainable path for reusable actions/components.
See: Registry.
File-based imports with
python_file/import
Use the python_file component (alias: import) to load classes from repo-local files and bind them into the runtime.
See: PythonFile.
Minimal example (YAML)
python_file:
extensions/my_block.py:
class: MyBlock
attributes:
temperature_c:
property: temperature_c
methods:
run:
method: tick
args: [1]Notes:
Prefer repo-relative paths checked into your project for reproducible builds.
The path must exist inside the SPX Server process (in Docker, mount the folder into the container).
args/kwargsinmethodscan reference runtime values via attribute refs like$attr(value).
Last updated

