Entities' creation
In this section, it is assumed that my_config.py
module contains a Taipy configuration already implemented.
Scenario creation¶
Scenarios are the most used entities in Taipy. The create_scenario()
function can be used to create a new
scenario.
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 :
config
is a mandatory parameter of typeScenarioConfig
. It corresponds to a scenario configuration (created in the module my_config.py)creation_date
is 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.- The
name
parameter is optional as well. Any string can be provided as aname
. It can be used to display the scenario in a user interface.
Example
Using the 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 name
are
provided.
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).
Pipeline creation¶
Deprecation
Note that function create_pipeline()
has been deprecated in version 2.3.
Pipelines can be created separately from scenarios using create_pipeline()
function.
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 |
|
The next section presents the scenario and cycle management.