Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Allow multiple arguments to pass to mapper #19

Open
fubuloubu opened this issue Oct 25, 2024 · 0 comments
Open

Feat: Allow multiple arguments to pass to mapper #19

fubuloubu opened this issue Oct 25, 2024 · 0 comments

Comments

@fubuloubu
Copy link

fubuloubu commented Oct 25, 2024

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))
@fubuloubu fubuloubu changed the title Allow multiple arguments to pass to mapper Feat: Allow multiple arguments to pass to mapper Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant