s

    Sanjay Patel

    2 years ago
    Hello! is there a way to use **kwargs with the prefect map function as per the below?
    changes = generator_task.map(
                    sim, 
                    unmapped(x), 
                    unmapped(y),
                    unmapped(z),
                    **kwargs #need this unmapped
                )
    Jim Crist-Harif

    Jim Crist-Harif

    2 years ago
    Hi Sanjay.
    kwargs
    should work fine, but you may need to wrap them in
    unmapped
    as well. Are you seeing an issue?
    s

    Sanjay Patel

    2 years ago
    yes, where does the unmapped wrap around it? these two don't work
    unmapped(**kwargs)
    **unmapped(kwargs)
    by the way, thank you for the super quick reply
    Jim Crist-Harif

    Jim Crist-Harif

    2 years ago
    you'd need to wrap each of the values in
    **kwargs
    in unmapped. The following should work:
    task.map(..., **{k: unmapped(v) for k, v in kwargs.items()})
    I'd probably break that into multiple lines for readability:
    unmapped_kwargs = {k: unmapped(v) for k, v in kwargs.items()}
    task.map(..., **unmapped_kwargs)
    s

    Sanjay Patel

    2 years ago
    Thank you so much! that worked
    Jim Crist-Harif

    Jim Crist-Harif

    2 years ago
    Glad to hear it! Please let us know if you run into any other issues.