-
Notifications
You must be signed in to change notification settings - Fork 2
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
Only use config server if GDA didn't supply params #496
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 78.15% 78.21% +0.05%
==========================================
Files 92 92
Lines 6785 6797 +12
==========================================
+ Hits 5303 5316 +13
+ Misses 1482 1481 -1
|
def set_default_feature_flags(cls, values) -> Any: | ||
cls.features = FeatureFlags() | ||
if "use_panda" not in values: | ||
values["use_panda"] = cls.features.best_effort().use_panda_for_gridscan | ||
if "use_gpu" not in values: | ||
values["use_gpu"] = cls.features.best_effort().use_gpu_for_gridscan |
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.
Should: Only fetch the flags from the server once and only define them in one place.
With something like:
def set_default_feature_flags(cls, values) -> Any: | |
cls.features = FeatureFlags() | |
if "use_panda" not in values: | |
values["use_panda"] = cls.features.best_effort().use_panda_for_gridscan | |
if "use_gpu" not in values: | |
values["use_gpu"] = cls.features.best_effort().use_gpu_for_gridscan | |
def set_default_feature_flags(cls, values) -> Any: | |
cls.features = FeatureFlags.best_effort() | |
if "use_panda" in values: | |
cls.features.use_panda_for_gridscan = values["use_panda"] | |
... |
then the new definitions above could be removed?
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.
I agree to only get the flags from the server once, but I think the definitions for, eg use_panda
still need to be in GridCommon
, just having them in the validator isn't enough for pydantic to know that GridCommon
has these attributes
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.
oh, of course, sorry. but use_panda
still shouldn't be in GridCommon
, the flags should be passed in in features
, which is a BaseModel
as well already.
in the validator for features
you can then start with FeatureFlags.best_effort()
and update anything which is passed in
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.
Okay, that works, does that mean we should change the logic of best_effort
? Right now it checks the URL and uses Hyperion constants for things it can't find. This PR could change it to:
- Check if GDA supplied values for each parameter, if yes then use that
- Check if parameter exists in URL, if yes then use that
- Use Hyperion constants as a last resort
Is that reasonable?
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.
I don't think you need to change the logic in best_effort
to achieve that priority order, just set the defaults in teh FeatureFlags
class to the constants. maybe add a new layer to I03Constants
to hold defaults for feature flags.
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.
but if you want to add the ability to override stuff in best_effort with kwargs that sounds fine to me
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.
I think we still want GDA parameters to have priority. We use best_effort
in our plans so these should also give us the GDA parameters when they're supplied
75f232c
to
df08194
Compare
Fixes #494
Setting the parameters to
None
by default and then using an 'after' validator to say 'if None then use config server' wouldn't work due to typing complaints about setting a boolean to None.Instead, I am using a 'before' validator to check if the parameters were supplied by GDA. I have to instantiate the Feature class as this hasn't been done at the time the 'pre' validator runs
Acceptance criteria
If GDA parameters are supplied for gpu, panda and stub_offsets, these are used. If the parameters are missing, the config server is used instead