From bc2c41c1cd01bc5399339769103eda72cb1e7411 Mon Sep 17 00:00:00 2001 From: Roy Willy Haug <5484176+roywilly@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:03:38 +0100 Subject: [PATCH] Avoid keyerror when uploading data not related to a realization (#32) --- src/fmu/sumo/uploader/caseondisk.py | 4 ++++ src/fmu/sumo/uploader/scripts/sumo_upload.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fmu/sumo/uploader/caseondisk.py b/src/fmu/sumo/uploader/caseondisk.py index 5efecf6..1b53dda 100644 --- a/src/fmu/sumo/uploader/caseondisk.py +++ b/src/fmu/sumo/uploader/caseondisk.py @@ -145,6 +145,10 @@ def upload_parameters_txt( print(f"CONFIG_PATH: {glob_var_path}") fmu_id = self.fmu_case_uuid + if not "realization" in self.files[0].metadata["fmu"].keys(): + logger.info("Cannot upload parameters.txt due to no realization") + return + realization_id = self.files[0].metadata["fmu"]["realization"]["uuid"] query = f"fmu.case.uuid:{fmu_id} AND fmu.realization.uuid:{realization_id} AND data.content:parameters" diff --git a/src/fmu/sumo/uploader/scripts/sumo_upload.py b/src/fmu/sumo/uploader/scripts/sumo_upload.py index 3b55b05..9c8fb87 100644 --- a/src/fmu/sumo/uploader/scripts/sumo_upload.py +++ b/src/fmu/sumo/uploader/scripts/sumo_upload.py @@ -112,7 +112,7 @@ def sumo_upload_main( e.upload_parameters_txt(glob_var_path=config_path) logger.info("Upload done") except Exception as err: - logger.warning("Problem related to Sumo upload:", err, type(err)) + logger.warning(f"Problem related to Sumo upload: {err} {type(err)}") _sumo_logger = sumo_connection.api.getLogger( "log_2_server_sumo_upload" )