Sequence
This page describes how to manage sequences in Taipy. It explains how to create, submit and use sequences.
A Sequence
in Taipy is an attribute of a scenario. It is a submittable entity
that represents a subset of scenario tasks that can be executed together,
independently of the other scenario's 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 are created along with the scenario creation.
Sequence creation¶
A sequence can be created directly on a scenario instance using the Scenario.add_sequence()
method.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to demonstrate how to create a sequence on a scenario.
1 2 3 4 5 6 7 8 9 10 11 |
|
Sequences can also be created along with the scenario creation by providing the sequences description in the scenario configuration. For more details, see the scenario configuration page.
Graphical User Interface¶
Taipy offers visual elements dedicated to scenario management. These elements are designed to help end-users select, visualize, and edit scenarios in an intuitive way.
In particular, the scenario visual element is designed to help end-users create, submit, and delete scenarios' sequences.
For more details and examples, see the scenario visual elements section.
Sequence attributes¶
A Sequence
is identified by a unique identifier id
that Taipy generates.
It also holds various properties accessible as an attribute of the sequence:
- subscribers: The list of Tuples (callback, params) representing the subscribers.
- properties: The complete dictionary of the sequence properties. It includes a copy of the properties of the sequence configuration, in addition to the properties provided at the creation and runtime.
- tasks: The dictionary holds the sequence's various tasks. The key corresponds to the config_id of the task while the value is the task itself.
- data_nodes: The dictionary holding the various data nodes of the sequence. The key corresponds to the data node's config_id (while the value is the data node itself).
- owner_id: The identifier of the owner, which can be a scenario, cycle, or None.
- version: The string indicates the application version of the sequence to instantiate. If not provided, the current version is used. For more details, refer to version management.
- Each property of the properties dictionary is also directly exposed as an attribute.
- Each nested entity is also exposed as an attribute of the sequence. The attribute name corresponds to the config_id of the nested entity.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show the various attributes of a sequence.
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 26 27 28 29 30 |
|
Get Sequences¶
Get by id¶
The first method to get a sequence is from its id by using the taipy.get()
method:
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to get a sequence from its id.
1 2 3 4 5 6 7 8 |
|
Here, sequence_retrieved
equals sequence
.
Get from parents¶
All sequences that are part of a scenario can be directly accessed as attributes:
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to get a sequence from its parent scenario.
1 2 3 4 5 6 7 8 9 10 11 |
|
Get all sequences¶
All the existing sequences can be retrieved using the method taipy.get_sequences()
.
This method returns the list of all existing sequences for all scenarios.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to retrieve all sequences.
1 2 3 4 |
|
Delete a sequence¶
A sequence can be deleted by using taipy.delete()
which takes the sequence id as
a parameter. The deletion is also propagated to the nested tasks, data nodes, and
jobs if they are not shared with any other sequence.
Get parent scenarios¶
To get the parent entities of a sequence (i.e., scenarios) you can use either the
method Sequence.get_parents()
or the static function taipy.get_parents()
. Both
return the parents of the sequence.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to get the parent scenarios of a sequence.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|