Skip to content

Task management

In this section, it is assumed that my_config.py module contains a Taipy configuration already implemented.

Tasks get created when scenarios or pipelines are created. Please refer to the Entities' creation section for more details.

Task attributes

Now that we assume to know how to create a new Task, this section focuses on describing the task's attributes and utility methods for using tasks.

A Task entity is identified by a unique identifier id that is generated by Taipy. A task also holds various properties accessible as an attribute of the task:

  • config_id is the id of the scenario configuration.
  • function is the function that will take data from input data nodes and return data that should go inside the output data nodes.
  • input is the list of input data nodes.
  • output is the list of output data nodes.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import taipy as tp
import my_config

scenario = tp.create_scenario(my_config.monthly_scenario_cfg)
task = scenario.predicting

# the config_id is an attribute of the task and equals "task_configuration"
task.config_id

# the function which is going to be executed with input data
# nodes and return value on output data nodes.
task.function # predict

# input is the list of input data nodes of the task
task.input # [trained_model_cfg, current_month_cfg]

# output is the list of input data nodes of the task
task.output # [trained_model_cfg]

# the current_month data node entity is exposed as an attribute of the task
current_month_data_node = task.current_month

Taipy exposes multiple methods to manage the various tasks.

Get Tasks

The first method to get a job is from its id by using the get() method

1
2
3
4
5
6
7
import taipy as tp
import my_config

scenario = tp.create_scenario(my_config.monthly_scenario_cfg)
task = scenario.training
task_retrieved = tp.get(task.id)
# task == task_retrieved

Here, the two variables task and task_retrieved are equal.

A task can also be retrieved from a scenario or a pipeline, by accessing the task config_id attribute.

1
2
3
4
task_1 = scenario.predicting
pipeline = scenario.sales
task_2 - pipeline.predicting
# task_1 == task_2

All the jobs can be retrieved using the method get_tasks().

The next section shows the data node management.