https://prefect.io logo
Title
e

Elliot Oram

10/09/2020, 3:35 PM
Hi all upgrading from 0.10.6 to 0.13.10 and looking for some advice/clarification. We used create the flow with a context manager to setup task orders and register e.g.
with Flow("Flow name") as flow:
   flow.add_task(abc)
   flow.register(project_name="Test")
In the latest version I find that this isn't possible anymore as I get a
TypeError: can't pickle generator objects
My solution has been to replace this by defining the the flow object directly and ditching the context manager e.g.
flow = Flow("Flow name")
flow.add_task(abc)
flow.register(project_name="Test")
This works absolutely fine and I'm happy to continue with it. I just wanted to check if: 1. This is the expected / best way to resolve this problem 2. [Some of the documentation](https://docs.prefect.io/core/concepts/tasks.html#overview) still refers to the use of the context manager style. Is this okay to do simply because tese example do not register a flow? Any advice is welcome ๐Ÿ™‚ Thanks!
c

Chris White

10/09/2020, 3:36 PM
Hi Elliot - can you try registering your Flow outside of the context manager? E.g.,
with Flow("Flow name") as flow:
   flow.add_task(abc)

flow.register(project_name="Test")
:party-parrot: 1
a

ale

10/09/2020, 3:40 PM
Hi @Elliot Oram! Iโ€™ve had a similar issue and solved by doing what @Chris White suggests
๐Ÿ’ฏ 2
e

Elliot Oram

10/09/2020, 3:41 PM
Ah that's much cleaner! Thanks both ๐ŸŽ‰
j

Jim Crist-Harif

10/09/2020, 3:41 PM
Hmmm, that's an odd error to result from that, we should look fix that to raise a nicer error. Will fix.
Thanks for reporting the issue! Glad you got things working.
a

ale

10/09/2020, 3:45 PM
First time it took me more or less 4h to figure out it was โ€œjustโ€ and indentation problem ๐Ÿ˜…
j

Jim Crist-Harif

10/09/2020, 4:49 PM