Hi, I have the following code in a job: ```... val...
# ask-community
d
Hi, I have the following code in a job:
Copy code
...
val = foo(val)
val = bar(val)
val = baz(val)
...
(foo, bar and baz are ops) Now,
bar
is optional - there is a configuration that allows the user to skip
bar
and then the output of
foo
will go strait to
baz.
I can implement it naively with a simple condition in the beginning of
bar
(and I did), but - Can I visualize it better? represent it somehow in the DAG? maybe gray out the op during execution? Thanks!
dagster bot responded by community 1
🤖 1
s
Just move the condition to foo and output a Tuple[Optional[…],Optional[…])
Copy code
optBazInput, optBarInput = foo(val)
bazInput = bar(optBarInput[required])
bazRes = baz(optBazInput[optional], bazInput[optional])
And definitely rename them. But just returning both possible outcomes, functional slitly like an Either Tuple and then consume that tuple baz. Of course requires that in baz to have the logic coalesce the 2 optional inputs to one. So its a bit more code but you get it visualized in the graph. Think of it as functional style code with hard/statically typed outputs than it usually maps to a valid DAG I think.
d
Thanks! I can actually make it a generic sub-graph, renaming foo to is_enabled() and baz to coalesce() or something like that