-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support inject for default plan arguments again #773
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #773 +/- ##
==========================================
+ Coverage 93.32% 93.36% +0.04%
==========================================
Files 38 38
Lines 2083 2081 -2
==========================================
- Hits 1944 1943 -1
+ Misses 139 138 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
Is it feasible/worthwhile to write a regression test?
cbc830f
to
34d501f
Compare
Added a couple of tests to cover the 'normal' use and the failure case in 633. They're in |
34d501f
to
be46b33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Tagging @olliesilvester for awareness |
When preparing the parameters for a plan, pydantic creates an instance of the dynamically generated BaseModel, relying on the 'Reference' types to convert from strings to instances of the devices. This includes strings that are used as default field values (default parameters created using the `inject` method). We then convert the model back to a dictionary to pass as kwargs to the plan. The previously used `model_fields_set` field on the model only iterates over the fields set via the input JSON (the user supplied arguments) and skips the fields populated via the default factories in the base model. Using the `__pydantic_fields__` class variable, allows all fields to be used including the defaults. This was previously avoided as it generated warnings for unknown types but it is possible to opt-out of these warnings.
be46b33
to
de4b5e2
Compare
Let inject work again by using all fields of the built pydantic model including the default ones provided by inject
Fixes #647, #633
Instructions to reviewer on how to test:
inject
for default parameters, (egblueapi controller run stp_snapshot '{"detectors":["x"]}'
to run the plan fromexample_plans
)sample_temperature
andsample_pressure
. (It may fail at the end of the run with a different error relating to path providers for the detector but this is unrelated).inject("<misssing_device_name>")
(as for Blueapi context should except when it can't find an injected device #633), the plan will not be accepted and blueapi will return422 Unprocessable Entity
. The detailed error message is generated for this but it's not immediately obvious how to access it. Either way, that should be its own issue.Checks for reviewer