Skip to main content

Twinn-ml-interface

PyPI Latest Release Downloads License Code style: black

Twinn-ml-interface is a Python package for data contracts between machine learning code and infrastructure. This contract ensures smooth onboarding of machine learning models onto the Twinn-ml-platform by Royal HaskoningDHV.

Author: Royal HaskoningDHV

Installation

The easiest way to install this package is using pip:

pip install twinn-ml-interface

Model Interface

Purpose

The Model Interface defines the required methods and attributes that any ML model needs to have in order to run in the Royal HaskoningDHV Twinn-ml infrastructure.

Testing compliance of your model with the data contract

Instance of the Model Interface

Once all the attributes and methods from the Protocol ModelInterfaceV4 are implemented, including the correct type-hints / annotations, we can check if a model is compliant with the interface by doing an isinstance check with ModelInterfaceV4. You can find a base test in twinn_ml_interface/interface/model_test.py. The Darrow-Poc is an example of a model that follows the ModelInterfaceV4.

Mock Executors

The executor class takes care of running the model either for training or predictions in the Twinn-ml infrastructure. Here, we implemented a mock executor to emulate that behaviour to some extent, which hopefully makes it a little clearer in what context the model class will be used. Any model compliant with the ModelInterface should be able to train and predict using the ExecutorMock that can be found in twinn_ml_interface/mocks/mocks.py. The Darrow-Poc is an example of a model that follows ModelInterfaceV4 and can run using the ExecutorMock.

The steps and methods that the infrastructure and the mock executor run during training are:

  1. Read config:
    • get_target_template()
    • get_train_window_finder_config_template()
  2. Initialize the model
    • initialize()
  3. Given the configuration for the train window finder in the previous steps, validate possible windows:
    • validate_input_data()
  4. Read the data configuration to download all the needed data in a window selected by the previous step:
    • get_data_config_template()
  5. Transform the input data as needed:
    • preprocess()
  6. Train:
    • train()
  7. Store the model:
    • dump()

When the training is finished, the model can be used for predicting. The prediction steps are:

  1. Retrieve the model from storage and load it:
    • load()
  2. Fetch the data needed for prediction based on either:
    • base_features - if present
    • get_data_config_template() - otherwise
  3. Predict:
    • predict()
  4. Load configuration to post predictions:
    • get_result_template()

Example of the Model Interface

Darrow Poc

The Darrow-Poc is an example of a model that follows ModelInterfaceV4. It contains more detailed explanations of the data model, interface methods and the onboarding process.

Metadata

Release files for twinn-ml-interface 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twinn-ml-interface 0.7.1
File Size Uploaded
twinn_ml_interface-0.7.1.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twinn-ml-interface 0.7.1
File Interpreter ABI Platform
twinn_ml_interface-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / twinn_ml_interface-0.7.1.tar.gz

Download URL twinn_ml_interface-0.7.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f47c6585199a89b5518bf12a2f58ce3fc6a2690b02eb1aea0969ea77d6b48a2c
BLAKE2b-256 checksum
How to use checksums
10ad01eb6c14deb55ccc72377cbd73adfc8e9a6be45f2c5dcb758863698c1b9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / twinn_ml_interface-0.7.1-py3-none-any.whl

Download URL twinn_ml_interface-0.7.1-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60ca115731f0aa7a78c9f79c369717436008bd14b1a4c0bd3e8a4a40ea30fb88
BLAKE2b-256 checksum
How to use checksums
628677937354f0a2e3b04796bb180a448d8f38e69a9235faf1b30db14e26f426
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page