Scenario config
In this section, we delve into the specifics of configuring scenarios for task orchestration.
From task configurations¶
The code below aims at configuring a ScenarioConfig
from a single TaskConfig
to instantiate a simple scenario computing the double of a given number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Two data node configurations are created with the Config.configure_data_node()
method.
One "input" for the number to double and one "output" for the result. For more details,
see the data node configuration page.
Then, a task configuration double_task_cfg
is created using the Config.configure_task()
method. It takes as parameter the input and output data node configurations and the function
double()
that computes the double of a given number.
Finally, the scenario configuration double_scenario
is created as a ScenarioConfig
passing the task configuration as parameter.
Adding sequence descriptions¶
A Sequence
is a subset of scenario tasks that can be executed together, independently of
the other tasks. The sequences can be created directly on scenario instances, at run time,
but they can also be describes in the scenario configurations, so they can be created along
with the scenario creation.
Here is a simple example assuming the task configurations
add_task_cfg_1
, add_task_cfg_2
, multiply_task_cfg_1
, multiply_task_cfg_2
have
already been created:
1 2 3 4 5 6 7 8 9 |
|
An alternative way to add sequences to a scenario configuration is to use the add_sequences()
method.
1 2 3 4 5 6 7 8 9 10 |
|
We can also remove sequences after providing them in your scenario configuration.
1 2 3 4 5 6 7 8 9 10 |
|
In the small examples above, we create a scenario configuration ScenarioConfig
from task configurations and define sequences for that scenario configuration.
When defining a sequence in a ScenarioConfig
, you need to provide a dictionary
with the sequence name as the key and a list of task configurations that belong to
the sequence as the value. Note that the task configurations of the sequence must
also exist in the tasks of the scenario configuration.
Additional data nodes¶
In addition to the execution graph made of task and data node configurations,
a scenario configuration ScenarioConfig
can also hold some additional data
node configurations that are not connected to the execution graph. These
configurations can be added to the scenario configuration using the
Config.configure_scenario()
method.
For more examples, see the multiple scenarios page.
Frequency for cycle management¶
A ScenarioConfig
can also hold a frequency to model recurrent business problem
to solve. When a frequency is provided to a configuration, the scenarios instantiated
from this configuration are automatically attached to the Cycle
(a time period)
corresponding to the date of the scenario creation.
For more details on cycles see the
Recurrent Scenarios page.
Adding scenario comparator¶
A ScenarioConfig
can also hold some scenario comparators. A scenario comparator is a
user function used to compare multiple scenarios from the same configuration.
For more details, see the
scenario comparison
page.