Skip to content

Commit f41467d

Browse files
htahir1bcdurak
andcommitted
Add some nicer docs (#3328)
* Update trigger pipeline links to the new location.- Moved trigger pipeline links to the new location * Update trigger pipelines documentation links * Update trigger pipeline section title to 'Trigger a pipeline (Run Templates)'. * Add fan-in, fan-out pipeline pattern * Apply suggestions from code review Co-authored-by: Barış Can Durak <36421093+bcdurak@users.noreply.github.com> * some fixes --------- Co-authored-by: Barış Can Durak <36421093+bcdurak@users.noreply.github.com> Co-authored-by: Baris Can Durak <bariscandurak@hotmail.com> (cherry picked from commit dddc721)
1 parent a73a6c4 commit f41467d

File tree

17 files changed

+157
-90
lines changed

17 files changed

+157
-90
lines changed

.gitbook.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,8 @@ redirects:
264264
how-to/advanced-topics/control-logging/disable-rich-traceback: how-to/control-logging/disable-rich-traceback.md
265265
how-to/advanced-topics/control-logging/disable-colorful-logging: how-to/control-logging/disable-colorful-logging.md
266266

267-
267+
how-to/pipeline-development/trigger-pipelines/: how-to/trigger-pipelines/README.md
268+
how-to/pipeline-development/trigger-pipelines/use-templates-python: how-to/trigger-pipelines/use-templates-python.md
269+
how-to/pipeline-development/trigger-pipelines/use-templates-cli: how-to/trigger-pipelines/use-templates-cli.md
270+
how-to/pipeline-development/trigger-pipelines/use-templates-dashboard: how-to/trigger-pipelines/use-templates-dashboard.md
271+
how-to/pipeline-development/trigger-pipelines/use-templates-rest-api: how-to/trigger-pipelines/use-templates-rest-api.md

docs/book/getting-started/zenml-pro/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ that expand the functionality of the Open Source product. ZenML Pro adds a manag
1414
- **User management with teams**: Create [organizations](./organization.md) and [teams](./teams.md) to easily manage users at scale.
1515
- **Role-based access control and permissions**: Implement fine-grained access control using customizable [roles](./roles.md) to ensure secure and efficient resource management.
1616
- **Enhanced model and artifact control plane**: Leverage the [Model Control Plane](../../user-guide/starter-guide/track-ml-models.md) and [Artifact Control Plane](../../user-guide/starter-guide/manage-artifacts.md) for improved tracking and management of your ML assets.
17-
- **Triggers and run templates**: ZenML Pro enables you to [create and run templates](../../how-to/pipeline-development/trigger-pipelines/README.md#run-templates). This way, you can use the dashboard or our Client/REST API to run a pipeline with updated configuration, allowing you to iterate quickly with minimal friction.
17+
- **Triggers and run templates**: ZenML Pro enables you to [create and run templates](../../how-to/trigger-pipelines/README.md#run-templates). This way, you can use the dashboard or our Client/REST API to run a pipeline with updated configuration, allowing you to iterate quickly with minimal friction.
1818
- **Early-access features**: Get early access to pro-specific features such as triggers, filters, sorting, generating usage reports, and more.
1919

2020
Learn more about ZenML Pro on the [ZenML website](https://zenml.io/pro).

docs/book/getting-started/zenml-pro/core-concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The image above shows the hierarchy of concepts in ZenML Pro.
1212
- [**Teams**](./teams.md) are groups of users within an organization. They help in organizing users and managing access to resources.
1313
- **Users** are single individual accounts on a ZenML Pro instance.
1414
- [**Roles**](./roles.md) are used to control what actions users can perform within a tenant or inside an organization.
15-
- [**Templates**](../../how-to/pipeline-development/trigger-pipelines/README.md) are pipeline runs that can be re-run with a different configuration.
15+
- [**Templates**](../../how-to/trigger-pipelines/README.md) are pipeline runs that can be re-run with a different configuration.
1616

1717
More details about each of these concepts are available in their linked pages below:
1818

docs/book/getting-started/zenml-pro/self-hosted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ZenML Pro can be installed as a self-hosted deployment. You need to be granted a
1414
This document will guide you through the process.
1515

1616
{% hint style="info" %}
17-
Please note that the SSO (Single Sign-On) and [Run Templates](../../how-to/pipeline-development/trigger-pipelines/README.md) (i.e. running pipelines from the dashboard) features are currently not available in the on-prem version of ZenML Pro. These features are on our roadmap and will be added in future releases.
17+
Please note that the SSO (Single Sign-On) and [Run Templates](../../how-to/trigger-pipelines/README.md) (i.e. running pipelines from the dashboard) features are currently not available in the on-prem version of ZenML Pro. These features are on our roadmap and will be added in future releases.
1818
{% endhint %}
1919

2020

docs/book/getting-started/zenml-pro/tenants.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ Some Pro-only features that you can leverage in your tenant are as follows:
104104

105105
- [Model Control Plane](../../../../docs/book/how-to/model-management-metrics/model-control-plane/register-a-model.md)
106106
- [Artifact Control Plane](../../how-to/data-artifact-management/handle-data-artifacts/README.md)
107-
- [Ability to run pipelines from the Dashboard](../../../../docs/book/how-to/pipeline-development/trigger-pipelines/use-templates-rest-api.md),
108-
- [Create templates out of your pipeline runs](../../../../docs/book/how-to/pipeline-development/trigger-pipelines/use-templates-rest-api.md)
107+
- [Ability to run pipelines from the Dashboard](../../../../docs/book/how-to/trigger-pipelines/use-templates-rest-api.md),
108+
- [Create templates out of your pipeline runs](../../../../docs/book/how-to/trigger-pipelines/use-templates-rest-api.md)
109109

110110
and [more](https://zenml.io/pro)!
111111

docs/book/how-to/data-artifact-management/complex-usecases/unmaterialized-artifacts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ def example_pipeline():
8989
example_pipeline()
9090
```
9191

92-
You can see another example of using an `UnmaterializedArtifact` when triggering a [pipeline from another](../../pipeline-development/trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline).
92+
You can see another example of using an `UnmaterializedArtifact` when triggering a [pipeline from another](../../trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline).
9393

9494
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>

docs/book/how-to/pipeline-development/build-pipelines/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ locally or remotely. See our documentation on this [here](../../../getting-start
4949

5050
Check below for more advanced ways to build and interact with your pipeline.
5151

52-
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Configure pipeline/step parameters</td><td></td><td></td><td><a href="use-pipeline-step-parameters.md">use-pipeline-step-parameters.md</a></td></tr><tr><td>Name and annotate step outputs</td><td></td><td></td><td><a href="step-output-typing-and-annotation.md">step-output-typing-and-annotation.md</a></td></tr><tr><td>Control caching behavior</td><td></td><td></td><td><a href="control-caching-behavior.md">control-caching-behavior.md</a></td></tr><tr><td>Run pipeline from a pipeline</td><td></td><td></td><td><a href="../trigger-pipelines/README.md">README.md</a></td></tr><tr><td>Control the execution order of steps</td><td></td><td></td><td><a href="control-execution-order-of-steps.md">control-execution-order-of-steps.md</a></td></tr><tr><td>Customize the step invocation ids</td><td></td><td></td><td><a href="using-a-custom-step-invocation-id.md">using-a-custom-step-invocation-id.md</a></td></tr><tr><td>Name your pipeline runs</td><td></td><td></td><td><a href="name-your-pipeline-runs.md">name-your-pipeline-runs.md</a></td></tr><tr><td>Use failure/success hooks</td><td></td><td></td><td><a href="use-failure-success-hooks.md">use-failure-success-hooks.md</a></td></tr><tr><td>Hyperparameter tuning</td><td></td><td></td><td><a href="hyper-parameter-tuning.md">hyper-parameter-tuning.md</a></td></tr><tr><td>Attach metadata to a step</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/attach-metadata-to-a-step.md">attach-metadata-to-a-step.md</a></td></tr><tr><td>Fetch metadata within steps</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/fetch-metadata-within-steps.md">fetch-metadata-within-steps.md</a></td></tr><tr><td>Fetch metadata during pipeline composition</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/fetch-metadata-within-pipeline.md">fetch-metadata-within-pipeline.md</a></td></tr><tr><td>Enable or disable logs storing</td><td></td><td></td><td><a href="../../control-logging/enable-or-disable-logs-storing.md">enable-or-disable-logs-storing.md</a></td></tr><tr><td>Special Metadata Types</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/logging-metadata.md">logging-metadata.md</a></td></tr><tr><td>Access secrets in a step</td><td></td><td></td><td><a href="access-secrets-in-a-step.md">access-secrets-in-a-step.md</a></td></tr></tbody></table>
52+
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Configure pipeline/step parameters</td><td></td><td></td><td><a href="use-pipeline-step-parameters.md">use-pipeline-step-parameters.md</a></td></tr><tr><td>Name and annotate step outputs</td><td></td><td></td><td><a href="step-output-typing-and-annotation.md">step-output-typing-and-annotation.md</a></td></tr><tr><td>Control caching behavior</td><td></td><td></td><td><a href="control-caching-behavior.md">control-caching-behavior.md</a></td></tr><tr><td>Customize the step invocation ids</td><td></td><td></td><td><a href="using-a-custom-step-invocation-id.md">using-a-custom-step-invocation-id.md</a></td></tr><tr><td>Name your pipeline runs</td><td></td><td></td><td><a href="name-your-pipeline-runs.md">name-your-pipeline-runs.md</a></td></tr><tr><td>Use failure/success hooks</td><td></td><td></td><td><a href="use-failure-success-hooks.md">use-failure-success-hooks.md</a></td></tr><tr><td>Hyperparameter tuning</td><td></td><td></td><td><a href="hyper-parameter-tuning.md">hyper-parameter-tuning.md</a></td></tr><tr><td>Attach metadata to a step</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/attach-metadata-to-a-step.md">attach-metadata-to-a-step.md</a></td></tr><tr><td>Fetch metadata within steps</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/fetch-metadata-within-steps.md">fetch-metadata-within-steps.md</a></td></tr><tr><td>Fetch metadata during pipeline composition</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/fetch-metadata-within-pipeline.md">fetch-metadata-within-pipeline.md</a></td></tr><tr><td>Enable or disable logs storing</td><td></td><td></td><td><a href="../../control-logging/enable-or-disable-logs-storing.md">enable-or-disable-logs-storing.md</a></td></tr><tr><td>Special Metadata Types</td><td></td><td></td><td><a href="../../model-management-metrics/track-metrics-metadata/logging-metadata.md">logging-metadata.md</a></td></tr><tr><td>Access secrets in a step</td><td></td><td></td><td><a href="access-secrets-in-a-step.md">access-secrets-in-a-step.md</a></td></tr></tbody></table>
5353

5454
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>

docs/book/how-to/pipeline-development/build-pipelines/compose-pipelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def training_pipeline():
3030
```
3131

3232
{% hint style="info" %}
33-
Here we are calling one pipeline from within another pipeline, so functionally the `data_loading_pipeline` is functioning as a step within the `training_pipeline`, i.e. the steps of the former are added to the latter. Only the parent pipeline will be visible in the dashboard. In order to actually trigger a pipeline from another, see [here](../../pipeline-development/trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline)
33+
Here we are calling one pipeline from within another pipeline, so functionally the `data_loading_pipeline` is functioning as a step within the `training_pipeline`, i.e. the steps of the former are added to the latter. Only the parent pipeline will be visible in the dashboard. In order to actually trigger a pipeline from another, see [here](../../trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline)
3434
{% endhint %}
3535

3636
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Learn more about orchestrators here</td><td></td><td></td><td><a href="../../../component-guide/orchestrators/orchestrators.md">orchestrators.md</a></td></tr></tbody></table>

docs/book/how-to/pipeline-development/build-pipelines/configuring-a-pipeline-at-runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ You can learn more about these options [here](../../pipeline-development/use-con
1414

1515
However, there is one exception: if you would like to trigger a pipeline from the client
1616
or another pipeline, you would need to pass the `PipelineRunConfiguration` object.
17-
Learn more about this [here](../../pipeline-development/trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline).
17+
Learn more about this [here](../../trigger-pipelines/use-templates-python.md#advanced-usage-run-a-template-from-another-pipeline).
1818

19-
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Using config files</td><td></td><td></td><td><a href="../../pipeline-development/use-configuration-files/README.md">../../pipeline-development/use-configuration-files/README.md</a></td></tr></tbody></table>
19+
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Using config files</td><td></td><td></td><td><a href="../../use-configuration-files/README.md">../../pipeline-development/use-configuration-files/README.md</a></td></tr></tbody></table>
2020

2121
<!-- For scarf -->
2222
<figure><img alt="ZenML Scarf" referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" /></figure>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
description: Running steps in parallel.
3+
---
4+
5+
# Fan-in and Fan-out Patterns
6+
7+
The fan-out/fan-in pattern is a common pipeline architecture where a single step splits into multiple parallel operations (fan-out) and then consolidates the results back into a single step (fan-in). This pattern is particularly useful for parallel processing, distributed workloads, or when you need to process data through different transformations and then aggregate the results. For example, you might want to process different chunks of data in parallel and then aggregate the results:
8+
9+
```python
10+
from zenml import step, get_step_context, pipeline
11+
from zenml.client import Client
12+
13+
14+
@step
15+
def load_step() -> str:
16+
return "Hello from ZenML!"
17+
18+
19+
@step
20+
def process_step(input_data: str) -> str:
21+
return input_data
22+
23+
24+
@step
25+
def combine_step(step_prefix: str, output_name: str) -> None:
26+
run_name = get_step_context().pipeline_run.name
27+
run = Client().get_pipeline_run(run_name)
28+
29+
# Fetch all results from parallel processing steps
30+
processed_results = {}
31+
for step_name, step_info in run.steps.items():
32+
if step_name.startswith(step_prefix):
33+
output = step_info.outputs[output_name][0]
34+
processed_results[step_info.name] = output.load()
35+
36+
# Combine all results
37+
print(",".join([f"{k}: {v}" for k, v in processed_results.items()]))
38+
39+
40+
@pipeline(enable_cache=False)
41+
def fan_out_fan_in_pipeline(parallel_count: int) -> None:
42+
# Initial step (source)
43+
input_data = load_step()
44+
45+
# Fan out: Process data in parallel branches
46+
after = []
47+
for i in range(parallel_count):
48+
_ = process_step(input_data, id=f"process_{i}")
49+
after.append(f"process_{i}")
50+
51+
# Fan in: Combine results from all parallel branches
52+
combine_step(step_prefix="process_", output_name="output", after=after)
53+
54+
55+
fan_out_fan_in_pipeline(parallel_count=8)
56+
```
57+
58+
The fan-out pattern allows for parallel processing and better resource utilization, while the fan-in pattern enables aggregation and consolidation of results. This is particularly useful for:
59+
60+
- Parallel data processing
61+
- Distributed model training
62+
- Ensemble methods
63+
- Batch processing
64+
- Data validation across multiple sources
65+
- [Hyperparameter tuning](./hyper-parameter-tuning.md)
66+
67+
Note that when implementing the fan-in step, you'll need to use the ZenML Client to query the results from previous parallel steps, as shown in the example above, and you can't pass in the result directly.
68+
69+
{% hint style="warning" %}
70+
The fan-in, fan-out method has the following limitations:
71+
72+
1. Steps run sequentially rather than in parallel if the underlying orchestrator does not support parallel step runs (e.g. with the local orchestrator)
73+
2. The number of steps need to be known ahead-of-time, and ZenML does not yet support the ability to dynamically create steps on the fly.
74+
{% endhint %}
75+
76+
77+
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>

0 commit comments

Comments
 (0)