Skip to content
Snippets Groups Projects
Commit 9ae30d6a authored by Wernle, Alexandra Nicole's avatar Wernle, Alexandra Nicole
Browse files

Merge branch 'new_env' into 'master'

Empty set upload fix for copy-absolutes

See merge request !235
parents 9bc6d17e 3fc800e7
No related branches found
No related tags found
1 merge request!235Empty set upload fix for copy-absolutes
Pipeline #270385 failed
......@@ -110,19 +110,22 @@ def create_reading_metadata(reading: Reading, created_by_label: str) -> Metadata
-------
metadata object for reading
"""
measurement_times = [m.time for m in reading.measurements if m.time]
metadata = Metadata(
category=MetadataCategory.READING,
created_by=(created_by_label),
endtime=max(measurement_times),
metadata=json.loads(reading.json()),
network="NT",
starttime=min(measurement_times),
station=reading.metadata["station"],
status="reviewed" if reading.metadata.get("reviewed") else "new",
updated_by=reading.metadata.get("reviewer"),
)
return metadata
try:
measurement_times = [m.time for m in reading.measurements if m.time]
metadata = Metadata(
category=MetadataCategory.READING,
created_by=(created_by_label),
endtime=max(measurement_times),
metadata=json.loads(reading.json()),
network="NT",
starttime=min(measurement_times),
station=reading.metadata["station"],
status="reviewed" if reading.metadata.get("reviewed") else "new",
updated_by=reading.metadata.get("reviewer"),
)
return metadata
except:
pass
def get_readings(
......@@ -184,7 +187,11 @@ def upload_reading(
)
# TODO: should this check if metadata was already uploaded?
# TODO: should that check occur before calling this method?
return factory.create_metadata(metadata=metadata)
if metadata is not None:
return factory.create_metadata(metadata=metadata)
else:
print(" Absolute set is empty, skipping upload to webservice")
pass
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment