You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add dynamic fan-out/fan-in with run templates (#3826)
* Add dynamic fan-out/fan-in with run templates
* Refactor code for advanced features in pipelines
* Refactor chunk processing and results aggregation
* Add `is_failed` property to `ExecutionStatus` enum
* Update check for failed runs to use run status value
* Remove unnecessary import in advanced_features.md
* Update is_failed property return statement to refer to failed execution
* Update advanced features with improved process_chunk logic
* Update advanced features documentation and usage example
* Update docs/book/how-to/steps-pipelines/advanced_features.md
(cherry picked from commit 07beafb)
Copy file name to clipboardExpand all lines: docs/book/how-to/steps-pipelines/advanced_features.md
+175Lines changed: 175 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -303,6 +303,181 @@ The fan-in, fan-out method has the following limitations:
303
303
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.
304
304
{% endhint %}
305
305
306
+
### Dynamic Fan-out/Fan-in with Run Templates
307
+
308
+
For scenarios where you need to determine the number of parallel operations at runtime (e.g., based on database queries or dynamic data), you can use [run templates](https://docs.zenml.io/user-guides/tutorial/trigger-pipelines-from-external-systems) to create a more flexible fan-out/fan-in pattern. This approach allows you to trigger multiple pipeline runs dynamically and then aggregate their results.
309
+
310
+
```python
311
+
from typing import List, Optional
312
+
from uuid import UUID
313
+
import time
314
+
315
+
from zenml import step, pipeline
316
+
from zenml.client import Client
317
+
318
+
319
+
@step
320
+
def load_relevant_chunks() -> List[str]:
321
+
"""Load chunk identifiers from database or other dynamic source."""
322
+
# Example: Query database for chunk IDs
323
+
# In practice, this could be a database query, API call, etc.
description="Template for processing individual chunks"
472
+
)
473
+
474
+
# Run the fan-out/fan-in pipeline with the template
475
+
# You can also get the template ID from the dashboard
476
+
fan_out_fan_in_pipeline(template_id=template.id)
477
+
```
478
+
479
+
This pattern enables dynamic scaling, true parallelism, and database-driven workflows. Key advantages include fault tolerance and separate monitoring for each chunk. Consider resource management and proper error handling when implementing.
480
+
306
481
### Custom Step Invocation IDs
307
482
308
483
When calling a ZenML step as part of your pipeline, it gets assigned a unique **invocation ID** that you can use to reference this step invocation when defining the execution order of your pipeline steps or use it to fetch information about the invocation after the pipeline has finished running.
0 commit comments