hi, I've found the conditional tasks to be rather ...
# ask-community
d
hi, I've found the conditional tasks to be rather confusing. In particular I was hoping that if you have something like this...
Copy code
a = task_a()
test_value = task_get_test_value()
with case(test_value, 'test-against-this'):
  b = task_b()
  b.set_upstream(a)
...then task
b
would fail if
a
fails regardless of whether the
case
block is in the skipped or non skipped state. However that doesn't seem to be the way it works - rather if the
case
block skips, then it 'hides' whether or not
a
succeeded.
i also found it confusing that if you wanted to have a
task_c
and set
b
to be upstream, then you need to be very careful around not propagating the skipping. That seems at odds with the idea of a
with
block isolating logic..it's actually leaked out
i'm now trying to write my own verison of the
case
class to see if i can accomplish what i'm after, but i'm finding i'm running into gaps in documentation, e.g. around the
trigger
function on a task
k
Hey @Daniel Manson, I think this is because the case is a task and it propagates
SKIP
if the case is not met.
task_b
then has two upstream tasks with
task_a
and
case
.
task_a
will be
FAILED
and
case
will be
SKIPPED
and
SKIPPED
propagates. You can try with the
skip_on_upstream_skip
flag
Copy code
@task(skip_on_upstream_skip=True)
def task_b():
    ...

a = task_a()
test_value = task_get_test_value()
with case(test_value, 'test-against-this'):
  b = task_b()
  b.set_upstream(a)
d
isn't
True
the default for
skip_on_upstream_skip
k
Ah sorry. You’re right. Should be False
d
but wouldn't that mean
b
is never skipped?
what we want is it to propagate failures of
a
through
b
, but allow
b
to be skipped if the
case
is false
i'm not sure why that doesn't happen already, because the defualt
trigger
is
all_successful
and `b`'s upstream tasks are [
a
,
case
], so even if
case
is skipped,
b
should fail if
a
has failed, no?
k
Let me try this out a bit
b
is never
SKIPPED
but it won’t run with
TriggerFailed
. Still not ideal. Still looking into it.
d
thanks
k
Ok I am starting to believe this is indeed a gap in the triggers because the main issue is the two upstream tasks with
FAILED
and
SKIPPED
will
SKIP
the next task and we need to get failed. I think I will open an issue to see how we can address that. Would you like me to open an issue or do you want to?
d
you are welcome to - that would be great
k
On it
I dunno how feasible this is honestly: https://github.com/PrefectHQ/prefect/issues/5071
d
thanks
do you have any vauge idea how long something like this might take to go into a release (if at all)? are we talking days or weeks?
k
I don’t because I can’t even picture the solution for this one. Or maybe the core team just details a better workaround than me.
👍 1