Data management, coupling and execution for MDO problems
Project description
mdo-engine
mdo-engine provides data management, coupling between arbitrary sources (such as files, databases, python packages, etc.) and execution ordering. It is the framework on which dtocean-core is built.
Part of the DTOcean suite of tools.
Installation
pip install mdo-engine
Usage
Example
An example of using mdo-engine to read data from a DataWell SPT file interface, store the data using Simulation and DataPool objects, and then retrieve the data using its specified data structure.
All the setup for this example is in the mdo_engine.test module of the source code.
The example SPT file can be found in the mdo_engine/tests/data directory.
First, look for interfaces that are subclasses of FileInterface in the mdo_engine.test.interfaces module:
>>> from mdo_engine.control.sockets import NamedSocket
>>> import mdo_engine.test.interfaces as interfaces
>>> interfacer = NamedSocket("FileInterface")
>>> interfacer.discover_interfaces(interfaces)
>>> interfacer.get_interface_names()
{'Datawell SPT File': 'SPTInterface'}
Load the SPTInterface interface and see what file types it can load:
>>> file_interface = interfacer.get_interface_object('SPTInterface')
>>> file_interface.get_valid_extensions()
['.spt']
See which variables the interface can provide:
>>> output_variables = file_interface.get_outputs()
>>> output_variables
['site:wave:dir',
'site:wave:spread',
'site:wave:skewness',
'site:wave:kurtosis',
'site:wave:freqs',
'site:wave:PSD1D',
'site:wave:Hm0',
'site:wave:Tz']
Get the data from the test SPT file:
>>> file_interface.set_file_path(test_spectrum_30min.spt)
>>> file_interface.connect()
Create a data catalogue and read the defined structures and meta data for each variable:
>>> from mdo_engine.control.data import DataValidation
>>> from mdo_engine.entity.data import DataCatalog
>>> catalog = DataCatalog()
>>> validation = DataValidation(meta_cls=data.MyMetaData)
>>> validation.update_data_catalog_from_definitions(catalog,
data)
Check which variables in the interface are defined in the data catalogue:
>>> valid_variables = validation.get_valid_variables(catalog, output_variables)
>>> valid_variables
['site:wave:dir', 'site:wave:PSD1D', 'site:wave:freqs']
Collect the raw data for the valid variables:
>>> raw_data = []
>>> for variable in valid_variables:
>>> raw_data.append(file_interface.get_data(variable))
Create DataPool, Simulation and Loader objects and store the collected data:
>>> from mdo_engine.control.data import DataStorage
>>> from mdo_engine.control.simulation import Loader
>>> from mdo_engine.entity import Simulation
>>> from mdo_engine.entity.data import DataPool
>>> pool = DataPool()
>>> simulation = Simulation("Hello World!")
>>> data_store = DataStorage(data)
>>> loader = Loader(data_store)
>>> loader.add_datastate(pool,
... simulation,
... None,
... catalog,
... valid_variables,
... raw_data)
Retrieved variables are now pandas Series objects, as defined in the data catalogue:
>>> freqs = loader.get_data_value(pool,
... simulation,
... 'site:wave:freqs')
>>> type(freqs)
pandas.core.series.Series
Development
Development of mdo-engine uses the Poetry dependency manager. Poetry must be installed and available on the command line.
To install:
poetry install
Tests
A test suite is provided with the source code that uses pytest.
Install the testing dependencies:
poetry install --with test
Database integration tests are available upon the installation of the DTOcean database. Once the database is installed and running, additional options must be provided to the pytest command, with meanings as follows:
| Option | Meaning |
|---|---|
| --postgresql-password | The password of the root database user |
| --postgresql-path | The path to the database setup files |
The database tests use the
pytest-postgresql plugin to
generate temporary test databases that mirror the DTOcean database schema and
tables. Any additional option provided by pytest-postgresql plugin can also be
applied to the DTOcean tests (for instance, if the default port is not 5432, it
can be set with the --postgresql-port option).
Run the tests:
poetry run pytest
To include the database tests (with example values):
poetry run pytest --postgresql-password="example" --postgresql-path="/path/to/the/database/setup/files"
Code quality can also be audited using the ruff and pyright tools. Install the dependencies:
poetry install --with audit
Run the audit:
poetry run ruff
poetry run pyright src
The above tests can be run across all compatible Python versions using tox and tox-uv. To install:
poetry install --with tox
To run without the database tests:
poetry run tox
To include the database tests (with example values):
poetry run tox -- --postgresql-password="example" --postgresql-path="/path/to/the/database/setup/files"
Contributing
Please see the dtocean GitHub repository for contributing guidelines.
Credits
This package was initially created as part of the EU DTOcean project by Mathew Topper at TECNALIA.
It is now maintained by Mathew Topper at Data Only Greater.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdo_engine-3.0.0.tar.gz.
File metadata
- Download URL: mdo_engine-3.0.0.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e195ea538b81584f16ba4b493d97fa334acc082038bc22563e15a39634e2b0d4
|
|
| MD5 |
d236d834cb7b0f16c2b9fb582106e5f1
|
|
| BLAKE2b-256 |
1ec4582360e77e79e1b29fb9f35cc353b07f8c7818701d7447314a3ce2fe8fec
|
Provenance
The following attestation bundles were made for mdo_engine-3.0.0.tar.gz:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdo_engine-3.0.0.tar.gz -
Subject digest:
e195ea538b81584f16ba4b493d97fa334acc082038bc22563e15a39634e2b0d4 - Sigstore transparency entry: 1076413586
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mdo_engine-3.0.0-py3-none-any.whl.
File metadata
- Download URL: mdo_engine-3.0.0-py3-none-any.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fae838e21dd2278c23a421999e2f74e1c1bc68a4cc3739e07e4b4a47b81b3f35
|
|
| MD5 |
7ae730ffc6a8e3e1d5f4e879c7f4bd12
|
|
| BLAKE2b-256 |
c37e2843cf50ccc17c82682c2a1f4d9604654d7d9de3fd0229c18c9b48edc0c1
|
Provenance
The following attestation bundles were made for mdo_engine-3.0.0-py3-none-any.whl:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdo_engine-3.0.0-py3-none-any.whl -
Subject digest:
fae838e21dd2278c23a421999e2f74e1c1bc68a4cc3739e07e4b4a47b81b3f35 - Sigstore transparency entry: 1076413629
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Trigger Event:
push
-
Statement type: