Tim Enders
08/16/2022, 4:40 PMNone
defined on a mapped task? I now get this error (TypeError: object of type 'NoneType' has no len()
) when trying to map across the subsequent function signature.
@task
def get_items_list(
client, entity, page,
response_attr=None, path=None, params=None
):
Anna Geller
08/16/2022, 11:02 PMTim Enders
08/17/2022, 1:26 PMNone
values defined in the function signature:
items = get_items_list.map(
unmapped(client), unmapped("subscriptions"), pages_list
)
Anna Geller
08/18/2022, 12:19 AMitems = get_items_list.map(
pages_list, unmapped(client), unmapped("subscriptions")
)
Tim Enders
08/18/2022, 1:30 PM[]
for the mapping to work. Which makes the code smelly to me, and doesn't seem like very good Python.Alex Wilcoxson
08/18/2022, 7:43 PMTim Enders
08/18/2022, 8:18 PMAnna Geller
08/19/2022, 1:59 AMunmapped(None)
in place of those default unmapped arguments as shown here:
"""
with: mapped_future = add_one.map([1, 2, 3])
prefect.exceptions.MappingLengthMismatch: Received parameters with different lengths.
Parameters for map must all be the same length. Got lengths: {'x': 3, 'statis_value': 6}
"""
from prefect import flow, task, get_run_logger, unmapped
@task
def add_one(x: int, statis_value: str = None) -> int:
logger = get_run_logger()
<http://logger.info|logger.info>("Hello, %s!", statis_value)
<http://logger.info|logger.info>("Current value of x is %s", x)
return x + 1
@flow
def mapping_unmapped():
mapped_future = add_one.map([1, 2, 3], unmapped(None))
# mapped_future = add_one.map([1, 2, 3], unmapped("Anna"))
# add_one.map(mapped_future, unmapped("Second mapped loop"))
if __name__ == "__main__":
mapping_unmapped()
Tim Enders
08/19/2022, 2:30 PMAnna Geller
08/19/2022, 2:47 PMunmapped
to keep things consistent for the caller of map
- there is an open issue for that here https://github.com/PrefectHQ/prefect/issues/6383
Again, thanks so much for reporting thisAlex Wilcoxson
08/19/2022, 2:54 PM