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

Only use config server if GDA didn't supply params #496

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

olliesilvester
Copy link
Contributor

@olliesilvester olliesilvester commented Sep 16, 2024

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

@olliesilvester olliesilvester marked this pull request as ready for review September 17, 2024 16:20
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.21%. Comparing base (b10420c) to head (42d777a).

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     
Components Coverage Δ
i24 SSX 57.12% <ø> (ø)
hyperion 96.27% <100.00%> (+0.04%) ⬆️
other 100.00% <ø> (ø)

Comment on lines 52 to 57
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
Copy link
Contributor

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:

Suggested change
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?

Copy link
Contributor Author

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

Copy link
Contributor

@dperl-dls dperl-dls Oct 21, 2024

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

Copy link
Contributor Author

@olliesilvester olliesilvester Oct 21, 2024

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:

  1. Check if GDA supplied values for each parameter, if yes then use that
  2. Check if parameter exists in URL, if yes then use that
  3. Use Hyperion constants as a last resort

Is that reasonable?

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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

@olliesilvester olliesilvester force-pushed the 494_turn_on_experimental_features branch from 75f232c to df08194 Compare October 14, 2024 10:32
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.

Decide how turn on experimental features
2 participants