From 5d1e1c119d973227f304ef3789820dc5c2a06ae4 Mon Sep 17 00:00:00 2001 From: Michael Barlow Date: Wed, 15 Oct 2025 16:36:39 -0600 Subject: [PATCH 1/2] fix(config): add UseDefaultModel to configuration and set from cli option fixes #26 --- opgee/built_ins/run_plugin.py | 1 + opgee/etc/system.cfg | 13 +++++++++---- opgee/manager.py | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/opgee/built_ins/run_plugin.py b/opgee/built_ins/run_plugin.py index cad631f0..c67bc84b 100644 --- a/opgee/built_ins/run_plugin.py +++ b/opgee/built_ins/run_plugin.py @@ -290,6 +290,7 @@ def run(self, args, tool): raise CommandlineError( "No model to run: the --model-file option was not used and --no-default-model was specified." ) + setParam("OPGEE.UseDefaultModel", str(use_default_model)) # TBD: unclear if this is necessary setParam( diff --git a/opgee/etc/system.cfg b/opgee/etc/system.cfg index ca11f932..bcf651bb 100644 --- a/opgee/etc/system.cfg +++ b/opgee/etc/system.cfg @@ -48,6 +48,10 @@ OPGEE.ModelFile = etc/opgee.xml # are assumed to be within the opgee package. OPGEE.AttributesFile = etc/attributes.xml +# Whether to load the default model file before merging additional input models +# NOTE: overridden by `--no-default-model` cli option +OPGEE.UseDefaultModel = True + # Where to find user's attributes.xml files (optional) OPGEE.UserAttributesFile = @@ -80,6 +84,11 @@ OPGEE.LogFile = %(OPGEE.LogDir)s/opgee.log OPGEE.LogFileFormat = %%(asctime)s %%(levelname)s %%(name)s:%%(lineno)d %%(message)s OPGEE.LogConsoleFormat = %%(levelname)s %%(name)s: %%(message)s +# AuditLevel: Controls the level of attribute auditing. +# Options: None (default, no audit), Field (audit field-level attributes), Processes (show process graph only), All +# Note: Processes auditing (as well as "All") has a bug currently +OPGEE.AuditLevel = None + # Where to create temporary files OPGEE.TempDir = /tmp @@ -147,7 +156,3 @@ SLURM.Interface = # Which shell to use for the sbatch script SLURM.Shell = /usr/bin/bash -# AuditLevel: Controls the level of attribute auditing. -# Options: None (default, no audit), Field (audit field-level attributes), Processes (show process graph only), All -# Note: Processes auditing (as well as "All") has a bug currently -OPGEE.AuditLevel = None diff --git a/opgee/manager.py b/opgee/manager.py index bcc05467..daff0ec0 100644 --- a/opgee/manager.py +++ b/opgee/manager.py @@ -387,10 +387,12 @@ def run_serial(model_xml_file, analysis_name, field_names, result_type=DETAILED_ results = [] + use_default_model = getParam("OPGEE.UseDefaultModel") or "False" + # even though we pass 10 field names by default, each is passed singularly to `_run_field` for field_name, xml_string in extract_model(model_xml_file, analysis_name, field_names): - result = _run_field(analysis_name, field_name, xml_string, result_type) + result = _run_field(analysis_name, field_name, xml_string, result_type, use_default_model == str(True)) if result.error: _logger.error(f"Failed: {result}") From e3d4051edb1a23d25d3fd40a7a9891b5b74d8472 Mon Sep 17 00:00:00 2001 From: Michael Barlow Date: Wed, 15 Oct 2025 16:59:01 -0600 Subject: [PATCH 2/2] feat(config): allow for .cfg fallback if `--no-default-model` is missing --- opgee/built_ins/run_plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/opgee/built_ins/run_plugin.py b/opgee/built_ins/run_plugin.py index c67bc84b..0ffc614c 100644 --- a/opgee/built_ins/run_plugin.py +++ b/opgee/built_ins/run_plugin.py @@ -133,7 +133,7 @@ def addArgs(self, parser): parser.add_argument( "-n", "--no-default-model", - action="store_true", + action="store_const", help="""Don't load the built-in opgee.xml model definition.""", ) @@ -251,7 +251,7 @@ def run(self, args, tool): start_with = args.start_with trial_nums = None trials = args.trials - use_default_model = not args.no_default_model + use_default_model = not args.no_default_model if args.no_default_model is not None else None # TBD: conceptual problem: XML model merging doesn't happen until after we look for # analyses and fields in the model XML. Might want to do XML-level merging before @@ -290,7 +290,8 @@ def run(self, args, tool): raise CommandlineError( "No model to run: the --model-file option was not used and --no-default-model was specified." ) - setParam("OPGEE.UseDefaultModel", str(use_default_model)) + if use_default_model is not None: + setParam("OPGEE.UseDefaultModel", str(use_default_model)) # TBD: unclear if this is necessary setParam(