Skip to content

Feat: Allow multiple arguments to pass to mapper #19

Description

@fubuloubu

I was trying to build a pipeline where I would have a list of tuples being returned from the first sequential task into a mapper, that should take one of the tuples and apply it for multiple args

Proposed API maybe something like this?

@broker.task
async def get_list() -> list[tuple[int, int]]:
    # some sort of process to obtain the args for the next function
    return [(1, 2), (3, 4), (5, 6), ...]

@broker.task
async def handle_args(a: int, b: int) -> int:
    return a * b  # imagine this is more computationally expensive

pipe = Pipeline(broker, get_list).map(handle_args, multiple_args=True)  # if set, would be simialr to *args
task = await pipe.kiq()
result = await task.wait_result()
print(sum(result.return_value))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions