Skip to content

Commit

Permalink
getting started on a checker for selected config options (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
DLWoodruff authored Oct 1, 2024
1 parent f4cc7e6 commit 49ded60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mpisppy/generic_cylinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def _parse_args(m):
cfg.sep_rho_args()
cfg.coeff_rho_args()
cfg.sensi_rho_args()

cfg.parse_command_line(f"mpi-sppy for {cfg.module_name}")

cfg.checker() # looks for inconsistencies
return cfg

def _name_lists(module, cfg):
Expand Down
14 changes: 14 additions & 0 deletions mpisppy/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ def get(self, name, ifmissing=None):
else:
return ifmissing

#===============
def checker(self):
"""Verify that options *selected* make sense with respect to each other
"""
def _bad_rho_setters(msg):
raise ValueError("Rho setter options do not make sense together:\n"
f"{msg}")

if self.grad_rho_setter and self.sensi_rho:
_bad_rho_setters("Only one rho setter can be active.")
if not self.grad_rho_setter and not self.sensi_rho:
if self.dynamic_rho_primal_crit or self.dynamic_rho_dual_crit:
_bad_rho_setters("dynamic rho only works with grad- and sensi-")

def add_solver_specs(self, prefix=""):
sstr = f"{prefix}_solver" if prefix != "" else "solver"
self.add_to_config(f"{sstr}_name",
Expand Down

0 comments on commit 49ded60

Please sign in to comment.