https://dagster.io/ logo
#ask-community
Title
# ask-community
d

David Erukhimovich

05/16/2022, 7:37 AM
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

Samuel Stütz

05/16/2022, 7:51 AM
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

David Erukhimovich

05/16/2022, 8:53 AM
Thanks! I can actually make it a generic sub-graph, renaming foo to is_enabled() and baz to coalesce() or something like that