-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make context pickleable #1710
Comments
This is a good idea and in principle is trivial to implement. However, all implementations I've tried so far preserve context as it was at task creation, which means that all of the things we put into context during a task run (e.g., The reason for this is that the serialization occurs at task submission time, and the deserialization occurs prior to the task runner actually running anything, so there's never really a chance to update context with the appropriate information. I think instead of making context pickleable, for now I'm going to simply raise an informative error message. |
As it is, if you follow documentation as a noob and put logger = context.get("logger") anywhere in your code - it breaks flow registration... my first thought was "But i'm not doing anything with context?" up seeing error message. Was only this issue that made me realise it was the logger! |
To follow up with this, I agree this is a trivial change, but an unimplemented trivial change that ultimately sent us away from Prefect. The flow runs locally, then after a myriad of problems using Prefect Cloud, we found this trivial issue and gave up. You should fix this. It's messy and caused an issue of confidence that we weren't going to constantly run into trivial, yet flow-breaking issues. |
Current behavior
In the following flow:
We will see the error
Unexpected error occured in FlowRunner: TypeError("can't pickle Context objects")
becausecontext
is used as an attribute ofprefect
. This requires users toimport prefect
in their tasks in order to use context.Proposed behavior
We could adjust the behavior so that context would be unpickled in the task and return
prefect.context
therefore avoiding this extra step of having to import prefect.The text was updated successfully, but these errors were encountered: