https://prefect.io logo
p

Pedro Machado

01/24/2022, 4:38 PM
Hi there. I am getting this error in the
wait_for_flow_run
task when trying to implement a flow of flows:
Copy code
Unexpected error: TypeError('Object of type FlowRunView is not JSON serializable')
Any ideas? Code in thread.
Untitled.py
k

Kevin Kho

01/24/2022, 4:42 PM
I can’t tell immediately. Which
wait_for_flow_run
throws the error?
p

Pedro Machado

01/24/2022, 4:56 PM
The very first one.
The child flow ends without problems.
Copy code
Flow 'cherubic-rhino-get_employee_listings': Entered state <Success>: All reference tasks succeeded.
10:35:11
ERROR
CloudTaskRunner
Unexpected error: TypeError('Object of type FlowRunView is not JSON serializable')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 926, in get_task_run_state
    result = self.result.write(value, **formatting_kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/results/prefect_result.py", line 62, in write
    new.location = self.serializer.serialize(new.value).decode("utf-8")
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/serializers.py", line 110, in serialize
    return json.dumps(value).encode()
  File "/usr/local/lib/python3.8/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type FlowRunView is not JSON serializable
k

Kevin Kho

01/24/2022, 5:03 PM
I think this is because of the
PrefectResult()
right? It is trying to save the task output as a result.
p

Pedro Machado

01/24/2022, 5:05 PM
Yeah, I just realized that
wait_for_flow_run
returns
FlowRunView
k

Kevin Kho

01/24/2022, 5:05 PM
Try doing this:
Copy code
create_flow_run.checkpoint=False
After you import the task
p

Pedro Machado

01/24/2022, 5:06 PM
Do you mean
wait_for_flow_run.checkpoint=False
?
k

Kevin Kho

01/24/2022, 5:07 PM
Yes exactly before you use it in the Flow
p

Pedro Machado

01/24/2022, 5:23 PM
It worked! How would this affect the ability to restart the flow from failed?
k

Kevin Kho

01/24/2022, 5:26 PM
Flow of flows doesn’t work well with flow restarts. Restarting the parent flow doesn’t restart child flows so you would have to go to the child flow either way to restart
👍 1
p

Pedro Machado

01/24/2022, 5:39 PM
Does this work better in Orion?
Also, if I do restart the child flow and the parent flow, will the parent flow be able to continue?
k

Kevin Kho

01/24/2022, 5:45 PM
Yes I believe so! One of the motivations for Orion was the second-class nature of flow of flows in current Prefect
👍 2
13 Views