Cycle
This page describes how to manage cycles in Taipy.
A Scenario
in Taipy represents an instance of a business case that an end-user wants
to analyze, simulate, compare or solve. Some scenarios are recurrent and can be
associated with a period of time called a Cycle
. For example, a monthly scenario
can model a sales forecast problem where some predictions must be published every month.
A Cycle
represents a period of time associated with a scenario. Cycles are created
and attached to scenarios at their creation.
Note
When creating multiple scenarios at the same time period, Taipy automatically re uses the existing cycle if it exists, and attaches the new scenario to it.
That means cycles are shared between multiple scenarios. For example, multiple sales forecast scenarios can be attached to the same monthly cycle. Each one forecasting sales under different conditions.
For more details on how recurrent scenarios, please refer to the recurrent scenarios page.
Cycle attributes¶
A cycle is identified by a unique identifier id
that was generated by Taipy. A cycle also
holds various attributes and properties, each accessible as an attribute of the cycle:
- frequency corresponds to the cycle
Frequency
. It is populated at the cycle creation using the scenario frequency that triggered the cycle creation. - creation_date corresponds to the date-time of the creation of the cycle.
- start_date corresponds to the date and time of the start of the cycle.
- end_date corresponds to the date and time of the end of the cycle.
- name corresponds to a human-readable name of the cycle.
- Each property of the properties' dictionary is also directly exposed as an attribute.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to create a recurrent scenario attached to a cycle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
The scenario configuration has a monthly frequency, so the scenario is associated with the monthly cycle corresponding to the month of the scenario creation date.
Get cycles¶
Get by id¶
The basic method to get a cycle is from its id by using the taipy.get()
method.
Get by scenario¶
A parent Cycle
can be retrieved from a scenario by using the Scenario.cycle
property.
Example
The code below uses the monthly_scenario_cfg
configuration imported from the
my_config.py
module to show how to get a cycle from its id.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Here, cycle_retrieved
equals cycle
.
Here, the two variables cycle
and cycle_retrieved
are equal.
Get all cycles¶
All the cycles can be retrieved using the method taipy.get_cycles()
. This method returns
the list of all existing cycles.
Delete a cycle¶
A cycle can be deleted by using taipy.delete()
which takes the cycle id as a parameter.
The deletion is also propagated to the nested scenarios, sequences, tasks, data nodes, and
jobs if they are not shared with any other cycles.