Trac models¶
Base class¶
All models inherit from the TracModel
base class and implement the
following methods.
Defines the schema of all the inputs the model needs |
|
Defines the schema of all the runtime parameters that the model needs |
|
Defines the schema of all the outputs that the model generates |
|
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.
Launches an individual model using its Python class - perfect for individual models |
|
Launches a job using external configuration file - best for chained models |
Note
For more details on class methods, attributes and helper functions see TracModel
.