diff --git a/geomagio/processing/copy_absolutes.py b/geomagio/processing/copy_absolutes.py index be0c5b41f2e6b97d752a985f3bb7ea8166446182..d1318159ae57f5f7159aa3bbf51a455698d0c6b8 100644 --- a/geomagio/processing/copy_absolutes.py +++ b/geomagio/processing/copy_absolutes.py @@ -66,10 +66,10 @@ def copy_absolutes( """Copy absolutes from the web absolutes service OR residual spreadsheets into the metadata service.""" if factory.value == ResidualFactory.WEB_ABSOLUTES: factory = WebAbsolutesFactory(url=web_absolutes_url) - source_factory = "webabsolutes" + created_by_label = "webabsolutes" else: factory = SpreadsheetAbsolutesFactory(base_directory=directory) - source_factory = "spreadsheet" + created_by_label = "spreadsheet" readings = get_readings( factory=factory, @@ -92,11 +92,13 @@ def copy_absolutes( ) as progressbar: for reading in progressbar: upload_reading( - factory=metadata_factory, reading=reading, source_factory=source_factory + factory=metadata_factory, + reading=reading, + created_by_label=created_by_label, ) -def create_reading_metadata(reading: Reading, source_factory) -> Metadata: +def create_reading_metadata(reading: Reading, created_by_label: str) -> Metadata: """Create reading metadata object. Parameters @@ -111,7 +113,7 @@ def create_reading_metadata(reading: Reading, source_factory) -> Metadata: measurement_times = [m.time for m in reading.measurements if m.time] metadata = Metadata( category=MetadataCategory.READING, - created_by=(source_factory), + created_by=(created_by_label), endtime=max(measurement_times), metadata=json.loads(reading.json()), network="NT", @@ -162,7 +164,7 @@ def main() -> None: def upload_reading( - factory: MetadataFactory, reading: Reading, source_factory + factory: MetadataFactory, reading: Reading, created_by_label: str ) -> Metadata: """Upload reading to metadata service @@ -177,7 +179,9 @@ def upload_reading( ------- created metadata object """ - metadata = create_reading_metadata(reading=reading, source_factory=source_factory) + metadata = create_reading_metadata( + reading=reading, created_by_label=created_by_label + ) # TODO: should this check if metadata was already uploaded? # TODO: should that check occur before calling this method? return factory.create_metadata(metadata=metadata)