Skip to content

Commit 4d76d01

Browse files
AlexejPenneravishniakovbcdurakschustmi
authored
Better run template docs (#3730)
* Initial proposal * Update docs/book/how-to/templates/templates.md Co-authored-by: Andrei Vishniakov <[email protected]> * Update docs/book/how-to/templates/templates.md Co-authored-by: Barış Can Durak <[email protected]> * Update docs/book/how-to/templates/templates.md Co-authored-by: Barış Can Durak <[email protected]> * Update docs/book/how-to/templates/templates.md Co-authored-by: Michael Schuster <[email protected]> --------- Co-authored-by: Andrei Vishniakov <[email protected]> Co-authored-by: Barış Can Durak <[email protected]> Co-authored-by: Michael Schuster <[email protected]>
1 parent e13eb54 commit 4d76d01

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

docs/book/how-to/templates/templates.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ Learn how to get a bearer token for the curl commands [here](https://docs.zenml.
202202

203203
## Advanced Usage: Running Templates from Other Pipelines
204204

205-
You can trigger templates from within other pipelines, enabling complex workflows:
205+
You can trigger templates from within other pipelines, enabling complex workflows. There are two ways to do this:
206+
207+
### Method 1: Trigger by Pipeline Name (Uses Latest Template)
208+
209+
If you want to run the latest runnable template for a specific pipeline:
206210

207211
```python
208212
import pandas as pd
@@ -237,6 +241,7 @@ def trigger_pipeline(df: UnmaterializedArtifact):
237241
steps={"trainer": {"parameters": {"data_artifact_id": df.id}}}
238242
)
239243

244+
# This triggers the LATEST runnable template for the "training_pipeline" pipeline
240245
Client().trigger_pipeline("training_pipeline", run_configuration=run_config)
241246

242247

@@ -246,6 +251,35 @@ def loads_data_and_triggers_training():
246251
trigger_pipeline(df) # Will trigger the other pipeline
247252
```
248253

254+
### Method 2: Trigger by Specific Template ID
255+
256+
If you want to run a specific template (not necessarily the latest one):
257+
258+
```python
259+
@step
260+
def trigger_specific_template(df: UnmaterializedArtifact):
261+
run_config = PipelineRunConfiguration(
262+
steps={"trainer": {"parameters": {"data_artifact_id": df.id}}}
263+
)
264+
265+
# Option A: If you know the template ID
266+
template_id = UUID(<YOUR-TEMPLATE-ID>)
267+
Client().trigger_pipeline(template_id=template_id, run_configuration=run_config)
268+
269+
# Option B: If you need to look up the template by name
270+
client = Client()
271+
template = client.get_run_template(name="my-specific-template-name", hydrate=False)
272+
client.trigger_pipeline(template_id=template.id, run_configuration=run_config)
273+
```
274+
275+
{% hint style="info" %}
276+
**Key Difference**:
277+
- `Client().trigger_pipeline("pipeline_name", ...)` uses the pipeline name and runs the **latest** template for that pipeline
278+
- `Client().trigger_pipeline(template_id="uuid", ...)` runs a **specific** template by its unique ID
279+
280+
If you created a template with a specific name and want to run that exact template, use Method 2.
281+
{% endhint %}
282+
249283
This pattern is useful for:
250284

251285
* Creating pipeline dependencies

0 commit comments

Comments
 (0)