Skip to content

Commit 888f458

Browse files
DLWoodruffbknueven
andauthored
do_decomp is now considered callable (#575)
* _do_decomp is now do_decomp and it returns its wheel object * added a descriptor for cfg * Update mpisppy/generic_cylinders.py Co-authored-by: bknueven <[email protected]> --------- Co-authored-by: bknueven <[email protected]>
1 parent 9775f23 commit 888f458

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

mpisppy/generic_cylinders.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,20 @@ def _name_lists(module, cfg, bundle_wrapper=None):
128128

129129

130130
#==========
131-
def _do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_denouement, bundle_wrapper=None):
131+
def do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_denouement, bundle_wrapper=None):
132+
"""Essentially, the main program for decomposition
133+
134+
Args:
135+
module (Python module or class): the model file with required functions or a class with the required methods.
136+
cfg (Pyomo config object): parsed arguments with perhaps a few attachments
137+
scenario_creator (function): note: this might be a wrapper and therefore not in the module
138+
scenario_creator_kwargs (dict): args for the scenario creator function
139+
scenario_denouement (function): some things (e.g. PH) call this for each scenario at the end
140+
bundle_wrapper (ProperBundler): wraps the module for proper bundle creation
141+
142+
Returns:
143+
wheel (WheelSpinner): the container used for the spokes (so callers can query results)
144+
"""
132145
if cfg.get("scenarios_per_bundle") is not None and cfg.scenarios_per_bundle == 1:
133146
raise RuntimeError("To get one scenarios-per-bundle=1, you need to write then read the 'bundles'")
134147
rho_setter = module._rho_setter if hasattr(module, '_rho_setter') else None
@@ -450,6 +463,8 @@ def _do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_
450463
if hasattr(module, "custom_writer"):
451464
module.custom_writer(wheel, cfg)
452465

466+
return wheel
467+
453468

454469
#==========
455470
def _write_scenarios(module,
@@ -680,4 +695,4 @@ def _proper_bundles(cfg):
680695
elif cfg.EF:
681696
_do_EF(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_denouement, bundle_wrapper=bundle_wrapper)
682697
else:
683-
_do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_denouement, bundle_wrapper=bundle_wrapper)
698+
do_decomp(module, cfg, scenario_creator, scenario_creator_kwargs, scenario_denouement, bundle_wrapper=bundle_wrapper)

0 commit comments

Comments
 (0)