-
Notifications
You must be signed in to change notification settings - Fork 41
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
added a call to an initialize function to generic_cylinders per a sug… #498
base: main
Are you sure you want to change the base?
Conversation
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'm a little confused by this. If a user wanted to use a class instead of a module, couldn't we enable that fairly easily? E.g.,
class MyClassForMpiSppy:
def __init__(self, cfg):
# anything sensible
pass
def scenario_creator(self, scenario_name, **kwargs):
## build the scenario
return scenario
# Maybe here, maybe somewhere else. Could have a different name.
# If we see this name in the module, we construct this class instead and
# use it in place of `module` in generic_cylinders.py.
mpisppy_class = MyClassForMpiSppy
# Or, we could require the user to provide a function which returns an
# instance of this class
def get_mpisppy_data(cfg):
return MyClassForMpiSppy(cfg)
I like your second idea best. I would change the function name to be |
…le'; TBD: no test yet
Co-authored-by: Tomás Valencia <[email protected]>
This still needs a test/example. |
doc/src/generic_cylinders.rst
Outdated
Note this verification is automatically performed by WheelSpinner if you call your custom writer functions through | ||
``wheel.write_first_stage_solution(solution_file_name, first_stage_solution_writer=my_first_stage_writer)`` and ``wheel.write_tree_solution(solution_dir_name, scenario_tree_solution_writer=my_tree_solution_writer)``. |
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 we just be handling this for the user, e.g., pass the function they provide into write_first_stage_solution
or write_tree_solution
? These methods also determine which cylinder has the optimal solution to write, so it's a bit more subtle than checking the cylinder rank. Plus, if you need the tree solution, you have to write from every rank.
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.
Good point.
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.
Agreed, that is probably safer and does not really restrict what the user can do; they can just put it inside the corresponding custom writer.
…into initialize
…into initialize
…gestion by Tomas. Also added callouts to a custom writer.