In this section, it is assumed that
module contains a Taipy configuration already implemented.
Scenarios are the most used entities in Taipy. The
create_scenario() function can be used to create a new
This function creates and returns a new scenario from the scenario configuration provided as a parameter. The scenario's creation also triggers the creation of the related entities that do not exist yet. Indeed, if the scenario has a frequency and there isn’t any corresponding cycle, the cycle will be created. Similarly, the pipelines, tasks, and data nodes nested in the scenario are created if they do not exist yet.
The simplest way of creating a scenario is to call the
create_scenario() method providing the scenario
configuration as a parameter:
1 2 3 4
Three parameters can be given to the scenario creation method :
configis a mandatory parameter of type
ScenarioConfig. It corresponds to a scenario configuration (created in the module my_config.py)
creation_dateis an optional parameter of type datetime.datetime. It corresponds to the creation date of the scenario. If the parameter is not provided, the current date-time is used by default.
nameparameter is optional as well. Any string can be provided as a
name. It can be used to display the scenario in a user interface.
my_config.py module, here is an example of how to create a scenario.
1 2 3 4 5 6 7
In this small example, one scenario for January 2022 is instantiated. A
creation_date and a
Note that the monthly_scenario_cfg has set the frequency to monthly. Therefore, scenario will be assigned to the cycle corresponding to its creation date (ie the month of January).
Behind the scene, the other related entities are also created:
- The January cycle, since the monthly_scenario_cfg has set the frequency to MONTHLY. So scenario will be assigned to the cycle corresponding to its creation date (ie the month of January).
- Two sales and production pipelines,
- Three tasks (training, predicting, planning),
- And six data nodes (sales_history, trained_model, current_month, sales_predictions, capacity, orders).
Pipelines can be created separately from scenarios using
This function creates and returns a new pipeline from the pipeline configuration provided as a parameter. The pipeline's creation also triggers the creation of the related entities that do not exist yet. Indeed, tasks and data nodes nested in the pipeline are created if they do not exist yet.
1 2 3 4