Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
equinor-ruaj committed Oct 15, 2024
1 parent 7ad08d6 commit 6c53e62
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions src/fmu/sumo/uploader/_upload_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
logger = get_uploader_logger()


def get_parameter_file(
case_uuid,
realization_id,
parameters_path,
config_path,
sumoclient,
):
def get_parameter_file(parameters_path, config_path):
"""Return a parameters object from the parameters.txt file
Args:
Expand Down Expand Up @@ -75,7 +69,6 @@ def get_parameter_file(
paramfile.metadata_path = ""
paramfile.path = ""
paramfile.size = len(bytestring)

return paramfile


Expand Down Expand Up @@ -125,6 +118,8 @@ def _upload_files(
parameters_path="parameters.txt",
):
"""
Upload realization and iteration objects if they do not exist
Upload parameters file if it does not exist or it has changed
Create threads and call _upload in each thread
"""

Expand All @@ -142,25 +137,18 @@ def _upload_files(
e.with_traceback(None),
)

paramfile = get_parameter_file(parameters_path, config_path)
# Check if the parameters file does not exist or if it has changed
query = f"fmu.case.uuid:{sumo_parent_id} AND fmu.realization.uuid:{realization_id} AND data.content:parameters"
search_res = sumoclient.get("/search", {"$query": query}).json()
if search_res["hits"]["total"]["value"] == 0:
paramfile = get_parameter_file(
sumo_parent_id,
realization_id,
parameters_path,
config_path,
sumoclient,
)
if (
search_res["hits"]["hits"][0]["_source"]["_sumo"][
"blob_md5"
]
!= paramfile.metadata["_sumo"]["blob_md5"]
):
files.append(paramfile)
# return None
# if paramfile is not None:
if (
search_res["hits"]["total"]["value"] == 0
or search_res["hits"]["hits"][0]["_source"]["_sumo"][
"blob_md5"
]
!= paramfile.metadata["_sumo"]["blob_md5"]
):
files.append(paramfile)

break

Expand Down

0 comments on commit 6c53e62

Please sign in to comment.