clearml-docs/docs/guides/automation/task_piping.md
2021-05-14 02:48:51 +03:00

25 lines
2.1 KiB
Markdown

---
title: Task Piping
---
The [task_piping_example.py](https://github.com/allegroai/clearml/blob/master/examples/automation/task_piping_example.py)
example demonstrates:
1. Creating an instance of a Task from a template Task.
1. Customizing that instance by changing the value of a parameter
1. Enqueuing the customized instance for execution.
This example accomplishes a task pipe by doing the following:
1. Creating the template Task which is named `Toy Base Task`. It must be stored in **ClearML Server** before instances of
it can be created. To create it, run another **ClearML** example script, [toy_base_task.py](https://github.com/allegroai/clearml/blob/master/examples/automation/toy_base_task.py).
The template Task has a parameter dictionary, which is connected to the Task: `{'Example_Param': 1}`.
1. Back in `task_piping_example.py`, creating a parameter dictionary, which is connected to the Task by calling [Task.connect](../../references/sdk/task.md#connect)
so that the parameters are logged by **ClearML**. The dictionary contains the name of the parameter from the template
Task that is going to be customized (`Example_Param`), as well as its new value.
1. Creating a Task object referencing the template Task. See [Task.get_task](../../references/sdk/task.md#taskget_task).
1. Creating an instance of the template Task by cloning it.
1. Getting the newly cloned Task's parameters. See [Task.get_parameters](../../references/sdk/task.md#get_parameters).
1. Setting the newly cloned Task's parameters to the search values in the parameter dictionary (Step 2). See [Task.set_parameters](../../references/sdk/task.md#set_parameters).
1. Enqueuing the newly cloned Task to execute. See [Task.enqueue](../../references/sdk/task.md#taskenqueue).
When the example script runs, it creates an instance of the template experiment, named `Auto generated cloned task` which is associated with the `examples` project. In the instance, the value of the customized parameter, `Example_Param` changed to `3`. You can see it in **CONFIGURATIONS** **>** **HYPER PARAMETERS**.