-
Notifications
You must be signed in to change notification settings - Fork 13
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
Patch for Xopt 2.5.4 #144
Patch for Xopt 2.5.4 #144
Changes from 5 commits
b29f5c6
bd31880
4386158
cf2cdd8
818927b
be3e637
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,13 +188,20 @@ def _get_bounds( | |
variable_names_new = [ | ||
name for name in variable_names if not len(self.variables.get(name, [])) | ||
] | ||
if len(variable_names_new): | ||
self.variables.update(self.get_bounds(variable_names_new)) | ||
|
||
# Set a default value for the bounds if not defined | ||
default_value = [-1, 1] | ||
# Get bound one by one due to potential failure | ||
for name in variable_names_new: | ||
try: | ||
bound = self.get_bound(name) | ||
except Exception: | ||
raise BadgerEnvVarError(f"Failed to get bound for {name}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this puts up a warning box in the GUI correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right -- any issues raised during an action through GUI would result in a warning box (implemented by Shamin) :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great thx |
||
|
||
return {k: self.variables.get(k, default_value) for k in variable_names} | ||
if bound[1] <= bound[0]: | ||
raise BadgerEnvVarError(f"Invalid bound for {name}: {bound}") | ||
|
||
self.variables.update({name: bound}) | ||
|
||
return {k: self.variables[k] for k in variable_names} | ||
|
||
|
||
def instantiate_env(env_class, configs, manager=None): | ||
|
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.
instead of using try/except, can we use an isinstance (routine.generator, BayesianGenerator) which would be more stable?
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 for our current application/code the two approaches would perform exactly the same. If we add in more generators with state in Xopt in the future I feel we might need more general
reset()
API, in that case it could be easier to just write try except blocks...I'm of course open to further discussion, it would be great if you can show me an example where the
isinstance
approach is better than the try catch one, then we can change the code accordingly :)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.
There are no generators outside Bayesian ones that are likely to use the same turbo controller type. There are many possible ways inside calling the turbo controller that could raise an Attribute error which in turn would fail silently due to the try except block.
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.
we don't want things to fail silently
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 see! Thanks for the explanation/example! That makes sense. So we don't want the potential internal Attribute errors to be ignored when we call
turbo_controller.reset()
. Will do the isinstance logic once the reset API works.