Skip to main content

TRAC Model Runtime for Python

TRAC D.A.P. is a next-generation data and analytics platform for use in highly regulated environments

The TRAC model runtime provides all the APIs needed to write models for the TRAC platform. It includes an implementation of the runtime library that can be used as a development sandbox, so you can run and debug TRAC models right away from your favourite IDE or notebook. A number of tools are included to make it easy to plug in development data and configuration. When your models are ready they can be loaded into a real instance of TRAC for testing and eventual deployment.

Documentation for the TRAC platform is available on our website at tracdap.finos.org.

Requirements

The TRAC runtime for Python has these requirements:

  • Python: 3.7 up to 3.11.x
  • Pandas: 1.2 up to 1.5.x
  • PySpark 2.4.x, or 3.0 up to 3.3.x

Not every combination of versions will work, e.g. PySpark 3 requires Python 3.8.

Installing the runtime

The TRAC runtime package can be installed directly from PyPI:

pip install tracdap-runtime

The TRAC runtime depends on Pandas and PySpark, so these libraries will be pulled in as dependencies. If you want to target particular versions, install them explicitly first.

Writing a model

Once the runtime is installed you can write your first TRAC model! Start by inheriting the TracModel base class, your IDE should be able to generate stubs for you:

import tracdap.rt.api as trac

class SampleModel(trac.TracModel):

    def define_parameters(self) -> tp.Dict[str, trac.ModelParameter]:
        pass

    def define_inputs(self) -> tp.Dict[str, trac.ModelInputSchema]:
        pass

    def define_outputs(self) -> tp.Dict[str, trac.ModelOutputSchema]:
        pass

    def run_model(self, ctx: trac.TracContext):
        pass

You can fill in the three define_* methods to declare any parameters, inputs and outputs your model is going to need, then start writing your model code in run_model.

To learn about modelling with TRAC D.A.P. and what is possible, check out the modelling tutorials available in our online documentation. The tutorials are based on example models in the TRAC GitHub repository. We run these examples as part of our CI, so they will always be in sync with the corresponding version of the runtime library.

Building the runtime from source

This is not normally necessary for model development, but if you want to do it here are the commands.

cd tracdap-runtime/python

# Configure a Python environment

python -m venv ./venv
venv\Scripts\activate              # For Windows platforms
. venv/bin/activate                # For macOS or Linux
pip install -r requirements.txt

# Build the Python package files

python ./build_runtime.py --target dist

The package files will appear under build/dist

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracdap-runtime-0.5.19.tar.gz (126.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracdap_runtime-0.5.19-py3-none-any.whl (180.8 kB view details)

Uploaded Python 3

File details

Details for the file tracdap-runtime-0.5.19.tar.gz.

File metadata

  • Download URL: tracdap-runtime-0.5.19.tar.gz
  • Upload date:
  • Size: 126.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tracdap-runtime-0.5.19.tar.gz
Algorithm Hash digest
SHA256 9ed71889211cfc8be95431858339b785ae06707ae89f7ece0d9c086820ea0e77
MD5 f4323d68283f5788f600d00ce5a62f0e
BLAKE2b-256 aea526979ee89804a6e3b7f7d4ebc4909e5c59f7eff5336e4b1eb8534e7009ff

See more details on using hashes here.

File details

Details for the file tracdap_runtime-0.5.19-py3-none-any.whl.

File metadata

File hashes

Hashes for tracdap_runtime-0.5.19-py3-none-any.whl
Algorithm Hash digest
SHA256 ab3faf4790b5a530f5a60c47b275b788be1e28ca9dad3d0a72d0a97fafcac608
MD5 fac938340754eaa270e54a7289d955bf
BLAKE2b-256 b831467b5e799e2299ca5aa2dbf17c07874ee95d99d5f7ea1e265b4c1640617f

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page