Metadata-Version: 2.4
Name: tracdap-runtime
Version: 0.9.0rc3
Summary: Runtime package for building models on the TRAC Data & Analytics Platform
Home-page: https://tracdap.finos.org/
Author: Martin Traverse
Author-email: martin@fintrac.co.uk
License: Apache-2.0
Project-URL: Documentation, https://tracdap.readthedocs.io/
Project-URL: Source Code, https://github.com/finos/tracdap
Project-URL: Bug Tracker, https://github.com/finos/tracdap/issues
Platform: any
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: <3.14,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: protobuf==6.31.1
Requires-Dist: pyarrow==21.0.0
Requires-Dist: pyyaml==6.0.2
Requires-Dist: dulwich==0.23.2
Requires-Dist: requests==2.32.4
Provides-Extra: grpc
Requires-Dist: grpcio==1.74.0; extra == "grpc"
Requires-Dist: grpcio-status==1.74.0; extra == "grpc"
Provides-Extra: pandas
Requires-Dist: pandas<2.3.0,>=1.2.0; extra == "pandas"
Requires-Dist: numpy<2.3.0,>=1.20; extra == "pandas"
Provides-Extra: polars
Requires-Dist: polars<2.0.0,>=1.0.0; extra == "polars"
Provides-Extra: pyspark
Requires-Dist: pyspark<3.6.0,>=3.0.0; extra == "pyspark"
Provides-Extra: sql
Requires-Dist: sqlalchemy<2.1.0,>=2.0.0; extra == "sql"
Provides-Extra: aws
Requires-Dist: botocore==1.39.15; extra == "aws"
Requires-Dist: boto3==1.39.15; extra == "aws"
Provides-Extra: gcp
Requires-Dist: google-auth==2.40.3; extra == "gcp"
Requires-Dist: google-api-core==2.25.1; extra == "gcp"
Requires-Dist: google-cloud-storage==3.2.0; extra == "gcp"
Requires-Dist: gcsfs==2024.3.1; extra == "gcp"
Provides-Extra: azure
Requires-Dist: azure-core==1.35.0; extra == "azure"
Requires-Dist: azure-identity==1.23.1; extra == "azure"
Requires-Dist: azure-storage-blob==12.26.0; extra == "azure"
Requires-Dist: adlfs==2024.12.0; extra == "azure"
Dynamic: license-file

# 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](https://tracdap.finos.org).

## Requirements

The TRAC runtime for Python has these requirements:

* Python: 3.9 up to 3.13
* Pandas: 1.2 up to 2.2 (optional)
* NumPy: 1.2 up to 2.2 (optional, required by Pandas)
* Polars: 1.X (optional)

3rd party libraries may impose additional constraints on supported versions of key libraries.
For example, Pandas 1.5 is not available for Python 3.12 or 3.13, while NumPy 2.0 is only
compatible with Pandas 2.1 and later.

## 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](https://tracdap.readthedocs.io/en/stable/modelling/tutorial)
available in our online documentation. The tutorials are based on
[example models](https://github.com/finos/tracdap/tree/main/examples/models/python)
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
