Skip to content

Commit

Permalink
Require certain ERT env variables before running
Browse files Browse the repository at this point in the history
  • Loading branch information
equinor-ruaj committed Oct 16, 2024
1 parent 97818be commit af4c01f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/fmu/sumo/sim2sumo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import logging
from os import environ

from .grid3d import upload_simulation_runs
from .tables import upload_tables
Expand Down Expand Up @@ -64,9 +65,24 @@ def parse_args():
return args


# fmu-dataio needs these when creating metadata
REQUIRED_ENV_VARS = ["_ERT_EXPERIMENT_ID", "_ERT_RUNPATH"]


def main():
"""Main function to be called"""
logger = logging.getLogger(__file__ + ".main")

missing = 0
for envVar in REQUIRED_ENV_VARS:
if environ.get(envVar) is None:
print(f"{envVar} is not set.")
missing += 1

if missing > 0:
print("Missing required environment variables. Stopping.")
exit()

args = parse_args()
logger.debug("Running with arguments %s", args)
if args.help_on != "No help":
Expand Down

0 comments on commit af4c01f

Please sign in to comment.