diff --git a/doc/src/generic_cylinders.rst b/doc/src/generic_cylinders.rst index 92955bf9..c85c77bc 100644 --- a/doc/src/generic_cylinders.rst +++ b/doc/src/generic_cylinders.rst @@ -28,6 +28,17 @@ needed even with the ``--help`` argument, e.g., .. Note:: This functionality is at the level of alpha-release. +Advanced manipulation of the hub and spokes dicts +------------------------------------------------- + +Advanced users might want to directly manipulate the hub and spoke dicts +immediately before ``spin_the_wheel()`` is called. If the module (or class) +contains a function called ``hub_and_spoke_dict_callback()``, it will be called +immediately before the ``WheelSpinner`` object is created. The ``hub_dict``, +``list_of_spoke_dict``, and ``cfg`` object will be passed to it. +See ``generic_cylinders.py`` for details. + + Pickled Scenarios ----------------- diff --git a/mpisppy/generic_cylinders.py b/mpisppy/generic_cylinders.py index ce605b17..c97f0a73 100644 --- a/mpisppy/generic_cylinders.py +++ b/mpisppy/generic_cylinders.py @@ -104,10 +104,6 @@ def _parse_args(m): default=None) # TBD - think about adding directory for json options files - cfg.add_to_config("hub_and_spoke_dict_callback", - description="[FOR EXPERTS ONLY] Module that contains the function hub_and_spoke_dict_callback that will be passed the hubdict and list of spokedicts prior to spin-the-wheel (last chance for intervention)", - domain=str, - default=None) cfg.parse_command_line(f"mpi-sppy for {cfg.module_name}") @@ -390,9 +386,9 @@ def _do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_ list_of_spoke_dict.append(reduced_costs_spoke) # if the user dares, let them mess with the hubdict prior to solve - if cfg.hub_and_spoke_dict_callback is not None: - module = sputils.module_name_to_module(cfg.hub_and_spoke_dict_callback) - module.hub_and_spoke_dict_callback(hub_dict, list_of_spoke_dict) + if hasattr(module,'hub_and_spoke_dict_callback'): + module.hub_and_spoke_dict_callback(hub_dict, list_of_spoke_dict, cfg) + wheel = WheelSpinner(hub_dict, list_of_spoke_dict) wheel.spin()