Skip to content

Commit

Permalink
Remove verbose logging (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
equinor-ruaj authored Oct 10, 2024
1 parent 068d18f commit 207a604
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
15 changes: 10 additions & 5 deletions src/fmu/sumo/uploader/_sumofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ def _upload_metadata(self, sumoclient, sumo_parent_id):

def _upload_byte_string(self, sumoclient, object_id, blob_url):
blobclient = BlobClient.from_blob_url(blob_url)
content_settings = ContentSettings(content_type="application/octet-stream")
response = blobclient.upload_blob(self.byte_string, blob_type="BlockBlob", length=len(self.byte_string), overwrite=True, content_settings=content_settings)
content_settings = ContentSettings(
content_type="application/octet-stream"
)
response = blobclient.upload_blob(
self.byte_string,
blob_type="BlockBlob",
length=len(self.byte_string),
overwrite=True,
content_settings=content_settings,
)
# response has the form {'etag': '"0x8DCDC8EED1510CC"', 'last_modified': datetime.datetime(2024, 9, 24, 11, 49, 20, tzinfo=datetime.timezone.utc), 'content_md5': bytearray(b'\x1bPM3(\xe1o\xdf(\x1d\x1f\xb9Qm\xd9\x0b'), 'client_request_id': '08c962a4-7a6b-11ef-8710-acde48001122', 'request_id': 'f459ad2b-801e-007d-1977-0ef6ee000000', 'version': '2024-11-04', 'version_id': None, 'date': datetime.datetime(2024, 9, 24, 11, 49, 19, tzinfo=datetime.timezone.utc), 'request_server_encrypted': True, 'encryption_key_sha256': None, 'encryption_scope': None}
# ... which is not what the caller expects, so we return something reasonable.
return httpx.Response(201)
Expand All @@ -99,9 +107,6 @@ def _delete_metadata(self, sumoclient, object_id):

def upload_to_sumo(self, sumo_parent_id, sumoclient, sumo_mode):
"""Upload this file to Sumo"""

logger.debug("Starting upload_to_sumo()")

# We need these included even if returning before blob upload
result = {"blob_file_path": self.path, "blob_file_size": self._size}

Expand Down
17 changes: 5 additions & 12 deletions src/fmu/sumo/uploader/_upload_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ def create_parameter_file(
search_res = sumoclient.get("/search", {"$query": query}).json()

if search_res["hits"]["total"]["value"] > 0:
logger.info("Parameters already uploaded")
return None

logger.info("Trying to read parameters at %s", parameters_path)
try:
with open(config_path, "r", encoding="utf-8") as variables_yml:
global_config = yaml.safe_load(variables_yml)
Expand All @@ -76,14 +74,14 @@ def create_parameter_file(
metadata = exd.generate_metadata(parameters)

if "fmu" not in metadata:
logger.warning("No fmu section upload will fail..")
logger.warning("No fmu section in metadata. Cannot upload parameters.")
return None

bytestring = json.dumps(parameters).encode("utf-8")
paramfile = FileOnJob(bytestring, metadata)
paramfile.metadata_path = ""
paramfile.path = ""
paramfile.size = len(bytestring)
logger.info("Parameters will be uploaded")
return paramfile


Expand Down Expand Up @@ -120,9 +118,7 @@ def maybe_upload_realization_and_iteration(sumoclient, base_metadata):
f"/objects('{case_uuid}')", json=iteration_metadata
)

sumoclient.post(
f"/objects('{case_uuid}')", json=realization_metadata
)
sumoclient.post(f"/objects('{case_uuid}')", json=realization_metadata)


def _upload_files(
Expand All @@ -149,7 +145,7 @@ def _upload_files(
except Exception as e:
logger.error(
"Failed to upload realization and iteration objects: %s",
e.with_traceback(None)
e.with_traceback(None),
)

paramfile = create_parameter_file(
Expand All @@ -167,10 +163,7 @@ def _upload_files(
with ThreadPoolExecutor(threads) as executor:
results = executor.map(
_upload_file,
[
(file, sumoclient, sumo_parent_id, sumo_mode)
for file in files
],
[(file, sumoclient, sumo_parent_id, sumo_mode) for file in files],
)

return results
Expand Down
6 changes: 1 addition & 5 deletions src/fmu/sumo/uploader/caseondisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ def register(self):
sumo_parent_id (uuid4): Unique ID for this case on Sumo
"""

logger.info("About to register case on Sumo")

try:
sumo_parent_id = self._upload_case_metadata(self.case_metadata)
self._sumo_parent_id = sumo_parent_id
Expand Down Expand Up @@ -194,9 +192,7 @@ def register(self):
def _upload_case_metadata(self, case_metadata: dict):
"""Upload case metadata to Sumo."""

response = self.sumoclient.post(
path="/objects", json=case_metadata
)
response = self.sumoclient.post(path="/objects", json=case_metadata)

returned_object_id = response.json().get("objectid")

Expand Down

0 comments on commit 207a604

Please sign in to comment.