conditional evaluation of nodes / sub-pipelines
See original GitHub issueDescription
Is there a way to declare a pipeline that contains nodes (sub-pipelines) that are only evaluated based on the value of a predicate?
Context
Possible Implementation
Here’s conceptually what I would like to achieve:
node_if
executes pipeline_a
if the predicate is true and pipeline_b
otherwise.
def condition(val):
return val < 10
def do_a1(val):
return f"a1-{val}"
def do_a2(val):
return f"a2-{val}"
def do_b(val):
return f"b-{val}"
pipeline_a = Pipeline([
node(func=do_a1, inputs=['val'], outputs='val_a1', name='do_a1'),
node(func=do_a2, inputs=['val_a1'], outputs='val_a2', name='do_a2')
])
pipeline_b = Pipeline([
node(func=do_b, inputs=['val'], outputs='val_b', name='do_b'),
])
pipeline = Pipeline([
node_if(func=condition, inputs=['val'], branch_true=pipeline_a, branch_false=pipeline_b),
])
Possible Alternatives
(Optional) Describe any alternative solutions or features you’ve considered.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
conditional evaluation of nodes / sub-pipelines #104 - GitHub
Is there a way to declare a pipeline that contains nodes (sub-pipelines) that are only evaluated based on the value of a predicate?...
Read more >Adding conditions to the pipeline - IBM
Condition Response checks a condition on the status of the previous node. Simple condition is a no-code condition in the form of an...
Read more >Comparing Pipelines and SGJC Controllers
For example, if your subpipeline start node is named 1start, you must rename it before overriding it with a controller method, because the...
Read more >XProc: An XML Pipeline Language - W3C
It's possible for steps in a partially evaluated pipeline to have side effects that are visible outside the processor, even if the final...
Read more >XProc 3.0+: An XML Pipeline Language
A pipeline must behave as if it evaluated each step each time it ... If the item is a document node, content-type "application/xml"...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @khdlim, thank you for sharing your experience, this is invaluable feedback!! Please see my inline responses, hoping they make sense to you. Feel free to reach out otherwise!
That’s a good point and I believe it has been raised before. We’re in the process of rethinking and improving the experience of
KedroContext
/ProjectContext
and we’ll be sure to include this type of arguments in the discussion.That is the right question to ask. If you look at the architecture diagram you can see that
Pipeline
andDataCatalog
don’t know about each other. You do have access to the catalog insidecreate_pipeline
, as it’s a property on theKedroContext
class. While you can access it to get some information, we don’t recommend mutating it - weird things might happen as a result.You are in luck! We released version
0.15.2
yesterday, fetch it while it’s hot. 😃 You can check out a summary of the introduced changes here.I am closing this issue as answered, but please feel free to open a new one if there’s a need for further clarification. 😃