diff --git a/geomagio/processing/copy_absolutes.py b/geomagio/processing/copy_absolutes.py index d1318159ae57f5f7159aa3bbf51a455698d0c6b8..db38d3eff0519ac713e773070987f3a119e24f58 100644 --- a/geomagio/processing/copy_absolutes.py +++ b/geomagio/processing/copy_absolutes.py @@ -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__":