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

added a call to an initialize function to generic_cylinders per a sug… #498

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

Conversation

DLWoodruff
Copy link
Collaborator

@DLWoodruff DLWoodruff commented Mar 25, 2025

…gestion by Tomas. Also added callouts to a custom writer.

@DLWoodruff DLWoodruff requested a review from jwatsonnm March 25, 2025 21:13
Copy link
Collaborator

@bknueven bknueven left a 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)

@bknueven bknueven requested review from jeanpaulwatson and removed request for jwatsonnm March 26, 2025 14:59
@DLWoodruff
Copy link
Collaborator Author

DLWoodruff commented Mar 26, 2025

I like your second idea best. I would change the function name to be
get_function_object

@DLWoodruff
Copy link
Collaborator Author

This still needs a test/example.

Comment on lines 81 to 82
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)``.
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor

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.

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.

3 participants