Trac models

Base class

All models inherit from the TracModel base class and implement the following methods.

define_inputs()

Defines the schema of all the inputs the model needs

define_parameters()

Defines the schema of all the runtime parameters that the model needs

define_outputs()

Defines the schema of all the outputs that the model generates

run_model()

Contains the model’s internal business logic

Responsibility for data marshalling, validation and formatting is taken entirely outside of the model code, which simply has to define it’s schema (inputs, parameters and outputs) and business logic.

Run Model method

When writing the run_model() method, modellers are largely free to do what they like — except for three rules:

  • No threading

  • Use trac for random number generation

  • Use trac to access the current time

You should also avoid making system calls, or using the Python builtins exec() or eval().

When the model runs, a TracContext is supplied to the run_model() method which allows the model to access parameters, data and other resources through the TRAC framework.

Launch functions

When running models on the trac platform, jobs are launched via the UI. When working locally - e.g. in your IDE - you have two options.

launch_model()

Launches an individual model using its Python class - perfect for individual models

launch_job()

Launches a job using external configuration file - best for chained models

Note

For more details on class methods, attributes and helper functions see TracModel.