<@ULVA73B9P> how can I translate a prefect 1 SKIP ...
# ask-marvin
j
@Marvin how can I translate a prefect 1 SKIP signal to prefect 2 syntax?
m
In Prefect 2, many ambiguities have been eliminated. For example, there is no more confusion between Prefect Core and Prefect Server — Prefect 2 unifies those into a single open source product. This product is also much easier to deploy with no requirement for Docker or docker-compose. If you want to switch your backend to use Prefect Cloud for an easier production-level managed experience, Prefect profiles let you quickly connect to your workspace. However, I couldn't find specific information on how to translate a Prefect 1 SKIP signal to Prefect 2 syntax. I recommend checking the Prefect 2 migration guide for more detailed information.
n
iirc in prefect 1 you'd raise SKIP if you want a task to just skip the rest of its execution right? or was there some downstream effect of doing that as well
its been a while for me 🙂
because what i would think the 2 analogue would be is just
return Completed(message="skipping", name="SKIPPED")
and have your downstream code react to that as desired
j
So returning the prefect 2 state
Completed
from a task will skip the rest of its execution, but not the rest of the parent flows execution is that correct?
n
yeah thats right
1
j
did SKIP maybe skip the rest of the parent flows execution as well?
I'm seeing different behavior between my prefect 1 and prefect 2 pipeline and trying to understand why
n
what is the behavior you want here? do you want a task "skipping" to just skip the rest of the task? or for the rest of the parent flow to also skip?
j
I want the parent flow to also skip
n
so something like
Copy code
In [1]: from prefect import flow, task

In [2]: from prefect.states import Completed

In [3]: @task
   ...: def flaky():
   ...:     return Completed(message="not today", name="SKIPPED")
   ...:

In [4]: @flow
   ...: def parent():
   ...:     state = flaky(return_state=True)
   ...:     if state.name == "SKIPPED":
   ...:         return "All done"
   ...:

In [5]: parent()
12:23:57.546 | INFO    | prefect.engine - Created flow run 'abiding-hound' for flow 'parent'
12:23:58.214 | INFO    | Flow run 'abiding-hound' - Created task run 'flaky-0' for task 'flaky'
12:23:58.216 | INFO    | Flow run 'abiding-hound' - Executing 'flaky-0' immediately...
12:23:59.144 | INFO    | Task run 'flaky-0' - Finished in state SKIPPED('not today', type=COMPLETED)
12:23:59.315 | INFO    | Flow run 'abiding-hound' - Finished in state Completed()
Out[5]: 'All done'
and if you didnt want the boilerplate of the if check, one could easily write a decorator i think
🙏 1
j
Ah got it so the logic just has to be piped up to the parent flow
thanks Nate - makes sense
n
yeah the difference is that
SKIPPED
is an arbitrary name for my own bookkeeping as the dev, it doesnt have the same inherent meaning as the skip signal from 1 yeah sure thing!
1