From fd86eeb4467b68defe0d005e7337574bac2d22b6 Mon Sep 17 00:00:00 2001 From: Runar Ask Johannessen <89020325+equinor-ruaj@users.noreply.github.com> Date: Wed, 27 Nov 2024 08:38:22 +0100 Subject: [PATCH] Update docs and error message (#116) * Print all missing ERT env vars at once when missing * Remove unused options argument from docs * Properly check if missing env var list is empty * Fix typo --- docs/sim2sumo.rst | 2 +- src/fmu/sumo/sim2sumo/main.py | 14 +++++++------- .../global_variables_w_eclpath_and_extras.yml | 5 ----- .../global_variables_w_eclpath_and_extras.yml | 5 ----- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/docs/sim2sumo.rst b/docs/sim2sumo.rst index 8a5d961..c654134 100644 --- a/docs/sim2sumo.rst +++ b/docs/sim2sumo.rst @@ -145,7 +145,7 @@ Custom configuration ===================== The sim2sumo section in the config file gives you full flexibility for extracting anything that ``res2df`` can extract. -You can also change where you extract results from, and even use all the extra custumization options that ``res2df`` has available. +You can also change where you extract results from, and use some of the extra customization options that ``res2df`` has available. The three relevant sections are: datafile diff --git a/src/fmu/sumo/sim2sumo/main.py b/src/fmu/sumo/sim2sumo/main.py index da60383..10e9002 100644 --- a/src/fmu/sumo/sim2sumo/main.py +++ b/src/fmu/sumo/sim2sumo/main.py @@ -51,16 +51,16 @@ def main(): """Main function to be called""" logger = logging.getLogger(__file__ + ".main") - missing = 0 + missing = [] for envVar in REQUIRED_ENV_VARS: - if environ.get(envVar) is None: - print(f"Required environment variable {envVar} is not set.") - missing += 1 + if envVar not in environ: + missing.append(envVar) - if missing > 0: + if missing: print( - "Required ERT environment variables not found. " - "This can happen if sim2sumo was called outside the ERT context. " + "Required ERT environment variables not found:" + f"{', '.join(missing)}.\n" + "This can happen if sim2sumo was called outside the ERT context.\n" "Stopping." ) exit() diff --git a/tests/data/reek/realization-0/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml b/tests/data/reek/realization-0/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml index 0916253..2ebb0ef 100644 --- a/tests/data/reek/realization-0/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml +++ b/tests/data/reek/realization-0/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml @@ -29,9 +29,4 @@ sim2sumo: - summary - grid - rft - options: - arrow: false - time_index: daily, - start_date: 2002-01-02 - end_date: 2003-01-02 grid3d: false diff --git a/tests/data/reek/realization-1/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml b/tests/data/reek/realization-1/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml index d8fcddd..f103543 100644 --- a/tests/data/reek/realization-1/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml +++ b/tests/data/reek/realization-1/iter-0/fmuconfig/output/global_variables_w_eclpath_and_extras.yml @@ -29,8 +29,3 @@ sim2sumo: - summary - grid - rft - options: - arrow: false - time_index: daily, - start_date: 2002-01-02 - end_date: 2003-01-02