Hi everyone. I am getting this error when calling ...
# ask-community
t
Hi everyone. I am getting this error when calling create_flow_run from one flow to call another. This used to work. Is this still supported?
Unexpected error: TypeError('Object of type SUCCESS is not JSON serializable')
Traceback (most recent call last):
File "/root/.local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 911, in get_task_run_state
result = self.result.write(value, **formatting_kwargs)
File "/root/.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 "/root/.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 SUCCESS is not JSON serializable
k
Hey @Trevor Kramer, do you have an example of the code causing this? Yes
Client.create_flow_run
is still supported. what Prefect version are you on?
t
version 0.15.2
Copy code
flow_run_id = client.create_flow_run(
    flow_id,
    run_name=prefect.context.get("flow_run_name"),
    parameters={
        "input": yi,
        "stack": stack,
        "pruned_locations": pruned_locations,
        "image": image,
        "commit": commit,
    },
)

while True:
    time.sleep(10)
    flow_run_state = client.get_flow_run_info(flow_run_id).state
    if flow_run_state.is_finished():
        raise signal_from_state(flow_run_state)(
            f"{flow_run_id} finished in state {flow_run_state}"
        )
I am using prefect results - result=PrefectResult()
k
Was the Flow kicked off and did it succeed? I’m wondering if this error is related to the Flow that ran.
t
it did succeed
k
It seems the error is caused by the raise that is being serialized into the PrefectResult. Did that
raise
signal into the Prefect Result work before?
The PrefectResult needs to be JSON Serializable and the raise is that is being returned so you need something other than the signal.
t
Thanks.