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

Add keyword argument support #394

Merged
merged 2 commits into from
May 18, 2023
Merged

Add keyword argument support #394

merged 2 commits into from
May 18, 2023

Conversation

jpsamaroo
Copy link
Member

APIs like delayed and spawn assumed that passed kwargs were to be treated as options to the scheduler, which is both somewhat confusing for users, and precludes passing kwargs to user functions.

This PR changes those APIs, as well as @spawn, to instead pass kwargs directly to the user's function. Options are now passed in an Options struct to delayed and spawn as the second argument (the first being the function), while @spawn still keeps them before the call (which is generally more convenient).

Internally, Thunk's inputs field is now a
Vector{Pair{Union{Symbol,Nothing},Any}}, where the second element of each pair is the argument, while the first element is a position; if nothing, it's a positional argument, and if a Symbol, then it's a kwarg.

@jpsamaroo jpsamaroo force-pushed the jps/kwargs branch 2 times, most recently from 483b76a to 7c3eef0 Compare May 18, 2023 03:41
@jpsamaroo jpsamaroo marked this pull request as ready for review May 18, 2023 05:18
jpsamaroo added 2 commits May 18, 2023 08:34
APIs like `delayed` and `spawn` assumed that passed kwargs were to be
treated as options to the scheduler, which is both somewhat confusing
for users, and precludes passing kwargs to user functions.

This commit changes those APIs, as well as `@spawn`, to instead pass
kwargs directly to the user's function. Options are now passed in an
`Options` struct to `delayed` and `spawn` as the second argument (the
first being the function), while `@spawn` still keeps them before the
call (which is generally more convenient).

Internally, `Thunk`'s `inputs` field is now a
`Vector{Pair{Union{Symbol,Nothing},Any}}`, where the second element of
each pair is the argument, while the first element is a position; if
`nothing`, it's a positional argument, and if a `Symbol`, then it's a
kwarg.
@jpsamaroo jpsamaroo merged commit 5836c4d into master May 18, 2023
@jpsamaroo jpsamaroo deleted the jps/kwargs branch May 18, 2023 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant