hey all, in prefect 1, i'm expecting a `None` val...
# ask-community
j
hey all, in prefect 1, i'm expecting a
None
value as a task result with
get_task_run_result
. i'm getting this error:
Copy code
Task 'get_task_run_result[17]': Exception encountered during task execution!
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/prefect/engine/task_runner.py", line 880, in get_task_run_state
    value = prefect.utilities.executors.run_task_with_timeout(
  File "/usr/local/lib/python3.9/site-packages/prefect/utilities/executors.py", line 468, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/prefect/tasks/prefect/flow_run.py", line 239, in get_task_run_result
    return task_run.get_result()
  File "/usr/local/lib/python3.9/site-packages/prefect/backend/task_run.py", line 75, in get_result
    self._assert_result_type_is_okay()
  File "/usr/local/lib/python3.9/site-packages/prefect/backend/task_run.py", line 162, in _assert_result_type_is_okay
    raise ValueError(
ValueError: The task result has no `location` so the result cannot be loaded. This often means that your task result has not been configured or has been configured incorrectly.
is there a way to for me to access a task's result if it's
None
? My code works when i pass an
int
z
Ah we don’t persist
None
results to avoid writing to files when there’s no data.
j
gotcha
j
is there a way to silence/handle that error?
z
How are you retrieving the result of that task?
Usually these results are cached in memory
j
this is with the flow of flows patterns
so in the parent flow i'm using
get_task_run_result
to get the result of a task in the child flow
z
Ah I see. That makes sense. I’d recommend just returning a different value to represent data in this case. Alternatively, you could use a utility to capture this value error when getting the result and return
None
instead.
j
i'll just return something else, thanks for your help here 🙂