Florian K. (He/Him)
05/12/2020, 8:49 PMUnexpected error: TypeError("cannot pickle 'google.protobuf.pyext._message.MessageDescriptor' object")
Traceback (most recent call last):
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 934, in get_task_run_state
state._result.store_safe_value()
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/prefect/engine/result/base.py", line 126, in store_safe_value
value = self.result_handler.write(self.value)
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/prefect/engine/result_handlers/local_result_handler.py", line 81, in write
f.write(cloudpickle.dumps(result))
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/cloudpickle/cloudpickle_fast.py", line 63, in dumps
cp.dump(obj)
File "/home/fkluiben/bin/miniconda3/envs/RodeoEnv/lib/python3.8/site-packages/cloudpickle/cloudpickle_fast.py", line 548, in dump
return Pickler.dump(self, obj)
TypeError: cannot pickle 'google.protobuf.pyext._message.MessageDescriptor' object
BTW, apologies for my way of describing the issue. I am sure it's pretty clumsy and inaccurate. Looking forward to learn and raise my awareness of prefect terminology!!Jim Crist-Harif
05/12/2020, 9:05 PMcheckpoint=False
for the task(s) returning protobufs, these won't be checkpointed to disk then.
• Serialize your protobufs to bytes first before returning them, then deserialize inside downstream tasks.
• Return a different object type that pickle does support
If you want to serialize data as protobufs with pickle, you could work around this by using copyreg
to register your protobuf objects so that pickle knows about them: https://docs.python.org/3/library/copyreg.htmlJim Crist-Harif
05/12/2020, 9:07 PMFlorian K. (He/Him)
05/12/2020, 9:20 PMLaura Lorenz (she/her)
05/12/2020, 9:38 PMcheckpoint=False
on the task, whereas it is disabled by default in Core only aka when you are running it as a script (it can be enabled globally in Core only by configuring prefect.config.flows.checkpointing to True). There’s a bit more information at https://docs.prefect.io/core/advanced_tutorials/using-result-handlers.html#setting-up-to-handle-results, everywhere you see “Cloud” in that configuration explanation you can imagine it also says “server”!Florian K. (He/Him)
05/13/2020, 12:44 PMPREFECT__FLOWS__CHECKPOINTING=false
and all my test setup looks like this:
@task(checkpoint=False)
def load_protobuff():
refpath = os.path.join(settings.BASE_DIR,
...
ts = ts_helpers.binfile2ts(refpath)
return ts
@task(checkpoint=False)
def print_protobuff(ts):
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(f'mi: {ts.metaInfo}')
<http://logger.info|logger.info>(f'series: {ts_helpers.ts2series(ts)}')
with Flow("Logs4Development") as flow:
tsresult = load_protobuff()
print_protobuff(tsresult)
flow.register(project_name="PB2 Test")
When I run it on the server, load_protobuff finishes successful, but when print_protobuff is being invoked, the LocalResultHandler runs into the pickling error again. Why would it even try to write the result to disk?
BTW, I also tried writing my own ResultHandler, but this is a story for another time I guess 🙂
I appreciate all your help!!!!Laura Lorenz (she/her)
05/13/2020, 12:49 PMFlorian K. (He/Him)
05/14/2020, 7:26 PMLaura Lorenz (she/her)
05/14/2020, 9:27 PMFlorian K. (He/Him)
05/14/2020, 9:30 PMFlorian K. (He/Him)
05/18/2020, 2:46 PMLaura Lorenz (she/her)
05/18/2020, 2:54 PM