The oedisi package exposes the component framework used to describe and
compile co-simulations. The reference below is generated from the package’s
own docstrings and Pydantic models. For the data models exchanged between
components see Data types; for the CLI see the
command-line interface.
Component framework¶
Module: oedisi.componentframework.system_configuration
WiringDiagram (class)¶
Cosimulation configuration. This may end up wrapped in another interface.
Parameters
----------
name :
Name of the simulation.
components :
List of components in the simulation.
links :
List of links connecting component ports.
shared_helics_config :
Optional shared federate configuration applied to all components.
Per-component values (name, core_name) are derived automatically.Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | |
components | list[Component] | required | |
links | list[Link] | required | |
shared_helics_config | SharedFederateConfig | None | None |
Component (class)¶
A component configuration in WiringDiagram.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | |
type | str | required | |
host | str | None | None | |
container_port | int | None | None | |
image | str | '' | |
parameters | dict[str, Any] | required | |
helics_config_override | SharedFederateConfig | None | None |
Link (class)¶
Connection between component ports in wiring diagram.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
source | str | required | |
source_port | str | required | |
target | str | required | |
target_port | str | required |
Port (class)¶
Port identifier for creating links between components.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | |
port_name | str | required |
AnnotatedType (class)¶
Represent the type on component static input, dynamic input, and dynamic output.
Currently not checked in any type checker.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
type | str | required | |
description | str | None | None | |
unit | str | None | None | |
port_id | str | None | None |
ComponentStruct (class)¶
Component with its associated links for multi-container configuration.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
component | Component | required | |
links | list[Link] | required |
ComponentType (class)¶
Abstract type for component configuration.
The components define the main restrictions on how components
can be configured. In the simplest case, the basic_copmonent function
constructs a type from a ComponentDescription which just write files.
There are no restrictions, so for example, one possibility is for the component type
to interact with a web service.
First, the class is initialized for each component using the name, parameters, and target directory. The federate name in HELICS should be the name initialized here.
Then the dynamic_inputs and dynamic_outputs are used to check types and verify
the links used between components. These can depend on the initialziation parameters.
The dynamic_outputs should be initialized under the prefix name/.
Next, generate_input_mapping is then called with a mapping
of the variable names to the HELICS subscription keys. The individual
federate should then use these names to subscribe at the right location.
This can also be used for endpoint targets less often.
Finally, the execute_function property defines the command to run the component.
ComponentCapabilities (class)¶
Component capability declarations for build-time validation.
Parameters
----------
version :
Capabilities schema version.
broker_config :
Whether this component supports receiving federate_config in static_inputs.json.
If True, the component can be used with WiringDiagram.shared_helics_config.Fields
| Field | Type | Default | Description |
|---|---|---|---|
version | str | '1.0' | |
broker_config | bool | False |
Federate (class)¶
Federate configuration for HELICS CLI runner.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
directory | str | required | |
hostname | str | 'localhost' | |
name | str | required | |
exec | str | required |
RunnerConfig (class)¶
HELICS running config for the full simulation.
Examples
--------
Save to JSON
>>> with open(filename, "w") as f:
... json.dump(config.model_dump(mode="json"), f)
Run Simulation
`$ helics run --path=filename`Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | |
federates | list[Federate] | required |
generate_runner_config (function)¶
generate_runner_config(wiring_diagram: WiringDiagram, component_types: dict[str, type[ComponentType]], compatibility_checker=_bad_compatability_checker, target_directory='.')Create HELICS run configuration from wiring diagram and component types.
Parameters
----------
wiring_diagram : WiringDiagram
Configuration describing components, parameters, and links between them
component_types : Dict[str, Type[ComponentType]]
Dictionary for the wiring diagram component types
to Python component types
compatibility_checker: function of two types to a bool
Each link uses the compatability_checker to ensure the link types are
compatible.
Returns
-------
RunnerConfig
Configuration which can be used to run the cosimulation
Raises
------
Can raise any exception from component type initializationinitialize_federates (function)¶
initialize_federates(wiring_diagram: WiringDiagram, component_types: dict[str, type[ComponentType]], compatability_checker, target_directory='.') -> list[Federate]Initialize all the federates.
Extracts config and sends it to each Component in an initalization step,
then finds all dynamic inputs and outputs and sends input mappings.
Parameters
----------
wiring_diagram
component_types : dictionary of component type names to ComponentType class
compatibility_checker : function from types to bool
Check if source type is compatible with target_type
target_directory : str | Path = "."
Directory where all components should be initialized.
Returns
-------
List of `Federate` run configuration
Raises
------
ComponentType classes may return errors on configuration.Basic components¶
Module: oedisi.componentframework.basic_component
ComponentDescription (class)¶
Component description for simple ComponentType.
Parameters
----------
directory :
where code is stored relative to where this is run
execute_function :
command to execute component
static_inputs :
List of types for the parameter
dynamic_inputs :
List of input types. Typically subscriptions.
dynamic_outputs :
List of output types. Typically publications.
capabilities :
Component capability declarations for build-time validation.Fields
| Field | Type | Default | Description |
|---|---|---|---|
directory | str | required | |
execute_function | str | required | |
static_inputs | list[AnnotatedType] | required | |
dynamic_inputs | list[AnnotatedType] | required | |
dynamic_outputs | list[AnnotatedType] | required | |
capabilities | ComponentCapabilities | PydanticUndefined |
component_from_json (function)¶
component_from_json(filepath, type_checker)Load component description from JSON file and create component type.
Parameters
----------
filepath : str | Path
type_checker : function taking the type and value and returning a boolean
Returns
-------
BasicComponent classbasic_component (function)¶
basic_component(comp_desc: ComponentDescription, type_checker)Create a new component type from component definition data.
Parameters
----------
comp_desc : ComponentDescription
Simplified component representation usually from a JSON file
type_checker : function taking the type and value and returning a boolean
Returns
-------
BasicComponent(system_configuration.ComponentType) :
ComponentType from the descriptionFederate configuration¶
Module: oedisi.types.helics_config
HELICSFederateConfig (class)¶
Full HELICS federate configuration.
This is what federates receive in static_inputs.json, containing various HELICS
configuration at the top-level (name, core_type, broker, etc). Subtype this in your
applications for custom configuration.
Parameters
----------
name :
Federate name (derived from Component.name).
core_type :
HELICS core type (e.g., "zmq", "tcp", "inproc").
core_name :
Core name for this federate (derived per-component).
core_init :
Core initialization string.
broker :
Broker connection configuration.
Examples
--------
>>> config = HELICSFederateConfig(
... name="state_estimator",
... core_type="zmq",
... broker=HELICSBrokerConfig(port=23404)
... )
>>> config.to_json()
'{"name": "state_estimator", "coreType": "zmq", ...}'Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | |
core_type | str | None | None | |
core_name | str | None | None | |
core_init | str | None | None | |
broker | HELICSBrokerConfig | None | None |
HELICSBrokerConfig (class)¶
HELICS broker connection parameters.
Parameters
----------
host :
Broker hostname or IP address.
port :
Broker port number.
key :
Broker key for authentication.
auto :
Whether to automatically configure broker connection.
initstring :
Additional initialization string for broker connection.Fields
| Field | Type | Default | Description |
|---|---|---|---|
host | str | None | None | |
port | int | None | None | |
key | str | None | None | |
auto | bool | None | None | |
initstring | str | None | None |
SharedFederateConfig (class)¶
Shared federate settings at the WiringDiagram level.
This contains settings that are shared across all federates in a simulation.
Does NOT include name/core_name (those are per-component). Users
are expected to write this as part of the wiring_diagram.json,
and invidual federates get passed `config.to_federate_config()`.
Parameters
----------
core_type :
HELICS core type (e.g., "zmq", "tcp", "inproc").
core_init :
Core initialization string.
broker :
Broker connection configuration.
Examples
--------
>>> shared = SharedFederateConfig(
... core_type="zmq",
... broker=HELICSBrokerConfig(port=23404)
... )
>>> config = shared.to_federate_config("my_federate")
>>> config.name
'my_federate'Fields
| Field | Type | Default | Description |
|---|---|---|---|
core_type | str | None | None | |
core_init | str | None | None | |
broker | HELICSBrokerConfig | None | None |