How donkkis/modelconductor works
1. What this repo is
ModelConductor is a Python co-simulation/orchestration library for “digital twin” style experiments. The core architecture is not a web app; it is a runtime that connects an incoming measurement source to a simulation or ML model and coordinates them in an online loop.
2. Primary runtime boundary
The main boundary is between external measurements and model execution. The repository is built around taking data that arrives over time, polling or receiving it, transforming it into model inputs, and pushing model outputs back into the experiment flow.
3. Experiment orchestration layer
modelconductor/experiment.py is the central coordinator. The README shows OnlineOneToOneExperiment, which suggests the orchestrator manages:
- route setup between a source and a target model
- runtime/stop-time control
- optional logging to CSV
- execution of the online loop in a background thread
4. Measurement ingestion subsystem
modelconductor/measurementhandler.py contains the inbound data side. The documented class IncomingMeasurementPoller reads from a database URI at a polling interval, so the measurement boundary is a persistent store rather than direct stream plumbing. In the example, SQLite is used as the measurement buffer, but the abstraction is “poll database for new rows.”
5. Model execution subsystem
modelconductor/modelhandler.py is the model-side abstraction. The README explicitly says the framework supports:
- FMU models
- sklearn machine learning models
The example uses FMUModelHandler, which implies the handler encapsulates model lifecycle, stepping, and mapping between input/control keys and output/target keys.
6. Data mapping and schema conventions
The model interface is key-based rather than strongly typed by domain object. The README shows:
- input_keys
- control_keys
- target_keys
- timestamp_key
This means the architecture depends on a field mapping layer between raw measurements and model variables, with time as a first-class coordination signal.
7. Execution flow
The documented flow is:
- an external writer appends measurement rows to a DB table
- IncomingMeasurementPoller polls that DB
- OnlineOneToOneExperiment routes the data into the model handler
- the model advances in steps and emits outputs
- outputs can be logged to CSV
This is an online, threaded, producer/consumer-style pipeline rather than batch processing.
8. Persistence and example environment
The examples under modelconductor/examples show the expected integration environment:
- CoupledClutches.fmu for the FMU simulation
- CSV files for input/output data
- Jupyter notebooks for experimentation and demonstration
This indicates the repo is meant for prototyping and reproducible simulation setups, not for a deployed production service.
9. Utilities and shared concerns
exceptions.py and utils.py likely hold shared error types and helper functions used across handlers and experiments. These are supporting modules, not major architectural pillars, but they define cross-cutting behavior such as validation, conversion, and failure handling.
10. Server layer
modelconductor/server.py suggests there is an optional service boundary, likely for exposing the framework over a network or enabling remote control. However, the README does not document it as the primary path; the main architecture is library-centric, with direct Python orchestration as the standard usage model.
11. Testing and training support
modelconductor/tests.py, test_utils.py, and testresources/train.py show that the repo includes test fixtures and a small training resource for model-related workflows. The presence of a train.py under test resources reinforces that sklearn-style model support is part of the supported surface area.
12. Diagram takeaway
A good architecture diagram should show:
- an external data source writing measurements into a DB
- a polling measurement handler reading that DB
- an experiment controller coordinating the loop
- a model handler executing an FMU or sklearn model
- optional logging/output persistence
- example notebooks and sample FMUs/CSV files as non-runtime assets supporting experimentation
Main entry points: experiment.py Experiment · modelhandler.py Model handler · examples Examples · measurementhandler.py Poller
Components 17
Core runtime
Online orchestration and execution boundary.
- Experiment · Coordinates the online loop, routing, timing, and threaded execution for co-simulation.
modelconductor/experiment.py - Routing · Maps measurement fields into model inputs, control signals, and timestamps.
modelconductor/experiment.py - Runtime control · Controls run/stop timing and step progression for the online experiment.
modelconductor/experiment.py - Server · Optional network-facing entry point for exposing the library over a service boundary.
modelconductor/server.py - Utils · Cross-cutting helper functions used across the package.
modelconductor/utils.py - Exceptions · Package-level exception types for validation and failure handling.
modelconductor/exceptions.py
I/O boundaries
Incoming measurements and output logging.
Model support
Supported model abstractions and lifecycle handling.
- Model handler · Unified interface for stepping and managing supported model backends.
modelconductor/modelhandler.py - FMU model · Handler path for FMU-based co-simulation models.
modelconductor/modelhandler.py - Sklearn model · Handler path for machine-learning model execution.
modelconductor/modelhandler.py - Model outputs · Emitted model results that feed back into the experiment flow and logs.
Examples and assets
Sample experiments and bundled resources.
- Examples · Notebook-driven demonstration setup for the online co-simulation workflow.
modelconductor/examples - CoupledClutches.fmu · Bundled FMU used by the example experiment.
modelconductor/examples/CoupledClutches.fmu - Input CSV · Example input table used by the notebook workflow.
modelconductor/examples/CoupledClutches_in_sh.csv - Output CSV · Example output capture generated by the experiment.
modelconductor/examples/out.csv
Connections 21
- Measurement DB → Poller: rows polled · External measurements are written to a database and then read by the poller.
- Poller → Experiment: measurements · New measurements are handed into the online experiment loop.
- Experiment → Routing: map fields · The orchestrator maps raw measurement keys into model variables.
- Experiment → Runtime control: control loop · Experiment timing and stop conditions govern the online execution loop.
- Routing → Model handler: inputs · Mapped inputs and control values are passed to the model layer.
- Runtime control → Model handler: step · Runtime control triggers stepping and advancement of the model.
- Model handler → FMU model: backend · One supported execution path is FMU-based simulation.
- Model handler → Sklearn model: backend · Another supported execution path is sklearn model inference or prediction.
- FMU model → Model outputs: emit · FMU execution produces outputs for the online loop.
- Sklearn model → Model outputs: emit · Sklearn execution produces outputs for the online loop.
- Model outputs → Experiment: feedback · Model outputs flow back into the orchestrated experiment flow.
- Experiment → CSV log: optional log · Outputs can be persisted to CSV for later inspection.
- Examples → Experiment: demonstrates · The notebooks show how to assemble and run the online experiment.
- Examples → CoupledClutches.fmu: uses · Example notebooks use the bundled FMU sample.
- Examples → Input CSV: uses · Example notebooks use sample input CSV data.
- Examples → Output CSV: produces · Example notebooks show output capture.
- Server → Experiment: exposes · Optional service boundary can wrap or expose experiment control.
- Utils → Poller: helpers · Shared helpers support measurement handling.
- Utils → Model handler: helpers · Shared helpers support model-side conversion and validation.
- Exceptions → Experiment: errors · Experiment-level failures use shared exception types.
- Exceptions → Model handler: errors · Model lifecycle and mapping failures use shared exception types.