Hi — is it valid to pass a `mapped(flatten(nested_...
# ask-community
d
Hi — is it valid to pass a
mapped(flatten(nested_list_data))
to a task?
k
Yes but why would you used
mapped
there?
Copy code
task.map(flatten(nested_list_data))
d
Ah, sorry. I have a task that takes a few other parameters as well, and those aren’t mapped. Instead of doing
task.map(a=unmapped(x), b=unmapped(y), c=flatten(nested_list_data))
I’d rather just do
task(a=x, b=y, c=mapped(flatten(nested_list_data))
🙂
I ask because I’m getting a weird error which looks like we’re trying to flatten a
None
:
Copy code
[2022-01-07 12:55:25-0800] ERROR - prefect.FlowRunner | Unexpected error: TypeError("object of type 'NoneType' has no len()")
Traceback (most recent call last):
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/engine/flow_runner.py", line 573, in get_flow_run_state
    executor=executor,
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/utilities/executors.py", line 639, in prepare_upstream_states_for_mapping
    mapped_children=mapped_children[edge.upstream_task], executor=executor
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/utilities/executors.py", line 728, in flatten_mapped_children
    [executor.submit(lambda c: len(c._result.value), c) for c in mapped_children]
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/utilities/executors.py", line 728, in <listcomp>
    [executor.submit(lambda c: len(c._result.value), c) for c in mapped_children]
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/executors/local.py", line 28, in submit
    return fn(*args, **kwargs)
  File "/home/smds/.cache/pypoetry/virtualenvs/boomerang-jSaBEsF4-py3.7/lib/python3.7/site-packages/prefect/utilities/executors.py", line 728, in <lambda>
    [executor.submit(lambda c: len(c._result.value), c) for c in mapped_children]
TypeError: object of type 'NoneType' has no len()
Maybe this is related to a question I had yesterday? I likely have a list like:
[["x", "y"], SKIP(None), SKIP(None)]
. Maybe I need to use a
FilterTask
there?
k
Yeah maybe a filter will help you here
🙌 1
1