Skip to content

feat: Support *args and **kwargs in plan definitions - #1715

Merged
tpoliaw merged 17 commits into
mainfrom
minimal-star-args
Oct 22, 2026
Merged

tpoliaw merged 17 commits into
mainfrom
minimal-star-args

Conversation

@tpoliaw

@tpoliaw tpoliaw commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Support *args and **kwargs in plans by binding a provided list of args to parameters before handing keyword arguments off to the generated pydantic model for the plan.

TaskRequest has a new args field but is optional so existing requests should have no change in behaviour. The params field of Task and TaskRequest has been left as params instead of the arguably more sensible kwargs to prevent any changes to existing APIs.

The CLI run command has gained an -a/--args flag to pass positional arguments. These should be a single string that deserialises to a JSON array. The existing behaviour of optionally passing a JSON object/mapping as keyword arguments has been left unchanged for now.

The scripting client interface now fully delegates its argument binding to the server and passes args/kwargs straight through.

Co-authored-by: oliwenmandiamond 136330507+oliwenmandiamond@users.noreply.github.com

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.46%. Comparing base (89952c9) to head (bb4b7a0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1715      +/-   ##
==========================================
+ Coverage   96.42%   96.46%   +0.03%     
==========================================
  Files          49       49              
  Lines        3749     3791      +42     
==========================================
+ Hits         3615     3657      +42     
  Misses        134      134              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oliwenmandiamond oliwenmandiamond left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good, thank you! I think this is roughly the size of my change though if I didn't add any test logic. But I think this will ultimately be smaller as you don't need to test for V1 and V2 any more, just args, kwargs and args and kwargs. This does look cleaner without V1 and V2 everywhere

(Also really good to have you back Peter)

Comment thread src/blueapi/worker/task.py Resolved
Comment thread src/blueapi/worker/task.py Resolved
Comment thread src/blueapi/cli/cli.py Resolved
Comment thread src/blueapi/service/model.py Resolved
@tpoliaw tpoliaw changed the title WIP - Alternative support for *args and **kwargs feat: Support *args and **kwargs in plan definitions Oct 22, 2026
@tpoliaw
tpoliaw marked this pull request as ready for review October 22, 2026 14:37
@tpoliaw
tpoliaw requested a review from a team as a code owner October 22, 2026 14:37

@abbiemery abbiemery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this against the same sets of plans and mix of args and kwargs as the other pr and all behaves as expected, thank you both for your hard work on this :)

I will make an issue for the potential renaming of params to kwargs, and for the cli syntax.

There is one test in the system test failing just because the match on the error message isn't full compared to what it expects:

FAILED tests/system_tests/test_blueapi_client.py::test_plan_argument_errors - AssertionError: Regex pattern did not match.
  Expected regex: "multiple values for 'detectors'"
  Actual message: "Incorrect parameters supplied\n    multiple values for argument 'detectors'"

But otherwise looks good to go for me.

@tpoliaw
tpoliaw added this pull request to the merge queue Oct 22, 2026
@tpoliaw tpoliaw linked an issue Oct 22, 2026 that may be closed by this pull request
Merged via the queue into main with commit eff0e50 Oct 22, 2026
20 checks passed
@tpoliaw
tpoliaw deleted the minimal-star-args branch October 22, 2026 17:29
ZohebShaikh pushed a commit that referenced this pull request Nov 2, 2026
Support *args and **kwargs in plans by binding a provided list of args
to parameters before handing keyword arguments off to the generated
pydantic model for the plan.

TaskRequest has a new `args` field but is optional so existing requests
should have no change in behaviour. The `params` field of Task and
TaskRequest has been left as params instead of the arguably more
sensible kwargs to prevent any changes to existing APIs.

The CLI run command has gained an `-a/--args` flag to pass positional
arguments. These should be a single string that deserialises to a JSON
array. The existing behaviour of optionally passing a JSON
object/mapping as keyword arguments has been left unchanged for now.

The scripting client interface now fully delegates its argument binding
to the server and passes args/kwargs straight through.

Co-authored-by: oliwenmandiamond
<136330507+oliwenmandiamond@users.noreply.github.com>
ZohebShaikh pushed a commit that referenced this pull request Nov 2, 2026
Support *args and **kwargs in plans by binding a provided list of args
to parameters before handing keyword arguments off to the generated
pydantic model for the plan.

TaskRequest has a new `args` field but is optional so existing requests
should have no change in behaviour. The `params` field of Task and
TaskRequest has been left as params instead of the arguably more
sensible kwargs to prevent any changes to existing APIs.

The CLI run command has gained an `-a/--args` flag to pass positional
arguments. These should be a single string that deserialises to a JSON
array. The existing behaviour of optionally passing a JSON
object/mapping as keyword arguments has been left unchanged for now.

The scripting client interface now fully delegates its argument binding
to the server and passes args/kwargs straight through.

Co-authored-by: oliwenmandiamond
<136330507+oliwenmandiamond@users.noreply.github.com>
ZohebShaikh pushed a commit that referenced this pull request Nov 9, 2026
Support *args and **kwargs in plans by binding a provided list of args
to parameters before handing keyword arguments off to the generated
pydantic model for the plan.

TaskRequest has a new `args` field but is optional so existing requests
should have no change in behaviour. The `params` field of Task and
TaskRequest has been left as params instead of the arguably more
sensible kwargs to prevent any changes to existing APIs.

The CLI run command has gained an `-a/--args` flag to pass positional
arguments. These should be a single string that deserialises to a JSON
array. The existing behaviour of optionally passing a JSON
object/mapping as keyword arguments has been left unchanged for now.

The scripting client interface now fully delegates its argument binding
to the server and passes args/kwargs straight through.

Co-authored-by: oliwenmandiamond
<136330507+oliwenmandiamond@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Plans do not function with *args

4 participants