Skip to content

Better run template docs #3730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion docs/book/how-to/templates/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ Learn how to get a bearer token for the curl commands [here](https://docs.zenml.

## Advanced Usage: Running Templates from Other Pipelines

You can trigger templates from within other pipelines, enabling complex workflows:
You can trigger templates from within other pipelines, enabling complex workflows. There are two ways to do this:

### Method 1: Trigger by Pipeline Name (Uses Latest Template)

If you want to run the latest runnable template for a specific pipeline:

```python
import pandas as pd
Expand Down Expand Up @@ -235,6 +239,7 @@ def trigger_pipeline(df: UnmaterializedArtifact):
steps={"trainer": {"parameters": {"data_artifact_id": df.id}}}
)

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


Expand All @@ -244,6 +249,35 @@ def loads_data_and_triggers_training():
trigger_pipeline(df) # Will trigger the other pipeline
```

### Method 2: Trigger by Specific Template ID

If you want to run a specific template (not necessarily the latest one):

```python
@step
def trigger_specific_template(df: UnmaterializedArtifact):
run_config = PipelineRunConfiguration(
steps={"trainer": {"parameters": {"data_artifact_id": df.id}}}
)

# Option A: If you know the template ID
template_id = "your-template-uuid-here"
Client().trigger_pipeline(template_id=template_id, run_configuration=run_config)

# Option B: If you need to look up the template by name
client = Client()
template = client.get_run_template(name="my-specific-template-name", hydrate=False)
client.trigger_pipeline(template_id=template.id, run_configuration=run_config)
```

{% hint style="info" %}
**Key Difference**:
- `Client().trigger_pipeline("pipeline_name", ...)` uses the pipeline name and runs the **latest** template for that pipeline
- `Client().trigger_pipeline(template_id="uuid", ...)` runs a **specific** template by its unique ID

If you created a template with a specific name and want to run that exact template, use Method 2.
{% endhint %}

This pattern is useful for:

* Creating pipeline dependencies
Expand Down