Jacob Longhurst
03/17/2022, 10:05 PM@task()
def my_task():
import prefect
logger = prefect.context.get('logger')
I’ve tried it both with having the import prefect
at the top level outside of the task and in the task like in that example and both times it gives me this
TypeError: Pickling context objects is explicitly not supported. You should always access context as an attribute of the `prefect` module, as in `prefect.context`
Anyone have any ideas why it’s failing when i try to register the flow?Kevin Kho
03/17/2022, 10:08 PMJacob Longhurst
03/17/2022, 10:09 PMAnna Geller
03/17/2022, 10:09 PM@task()
def my_task():
import prefect
logger = prefect.context.get('logger')
<http://logger.info|logger.info>("some info")
but you shouldn't e.g. return the logger and pass it to other tasks as data dependencies, this won't workJacob Longhurst
03/17/2022, 10:15 PMKevin Kho
03/17/2022, 10:16 PM