Scenario configs
A scenario configuration is necessary to instantiate a Scenario. To create a
ScenarioConfig
, you can use the Config.configure_scenario()
method with the following parameters:
- id: The id of a new scenario configuration to be created. This id is mandatory and must be a unique and valid Python identifier.
- pipelines: The list of pipeline configs.
- frequency: The recurrence of the scenarios instantiated from this configuration. The scenarios are attached to the proper cycles based on this frequency.
- comparators: The list of functions used to compare scenarios. A comparator function is attached to a scenario's data node configuration. During the scenario comparison, each comparator is applied to all the data nodes instantiated from the data node configuration attached to the comparator.
- properties: A dictionary of additional properties.
Reserved keys
Note that we cannot use the word "_entity_owner" as a key in the properties as it has been reserved for internal use.
From pipeline configs¶
Here is a simple example assuming the pipeline configuration pipeline_cfg
has already been created:
1 2 3 4 |
|
In this example, we create a scenario configuration ScenarioConfig
from a pipeline configuration already defined.
From task configs¶
When the scenario configuration contains only one single pipeline configuration, we can also create the
ScenarioConfig
from the task configurations directly.
1 2 3 4 |
|
Behind the scenes, a pipeline configuration is created. Its id will be the scenario configuration id with the
_pipeline
postfix (multiply_scenario_pipeline
in the example).
Note
Note that the pipeline id can be configured as an optional parameter as follows:
1 2 3 4 5 6 |
|
Using Cycles¶
Assuming the pipeline configuration pipeline_cfg
has already been created, here is an example of a weekly
scenario configuration:
1 2 3 4 5 6 |
|
In this small example, we create a scenario configuration ScenarioConfig
from a pipeline configuration with a
WEEKLY
frequency. When scenarios (entities) get instantiated using the scenario configuration above, they will be
associated with a Cycle corresponding to their creation date. See the documentation on
Scenario and cycle management.
Using scenario comparators¶
Let us imagine a typical situation where the pipeline configuration pipeline_cfg
has been
created using datanode_cfg
as one of its data node configurations. At the scenario configuration level, you can
define a function that compares the results for the various scenarios (entities) created with this config. You
simply need to define such a function in the comparators field. Here’s an example below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
We created the scenario configuration scenario_cfg
using the indicated pipeline configuration. We use
comparators parameter to provide a dictionary indicating which data nodes and what function(s) will be
involved in the comparison. In this example we use the function compare_function()
.
Line 25 indicates that only the data nodes instantiated from data_node_cfg
are selected for the comparison.
The comments in lines 3-8, gives you an idea of what the compare_function()
function computes depending
on the given input parameters.
Info
Please refer to the scenario entity comparison section to see
how to compare scenarios using the comparators defined in a ScenarioConfig
.