From d1f428c949263b9eab22e2c3e071ee1c40a3388f Mon Sep 17 00:00:00 2001 From: "Janet L. Goldstein" <jgoldste@nrao.edu> Date: Thu, 8 Jul 2021 15:12:03 -0600 Subject: [PATCH] WS-507: Corrections per review of MR333 still TODO: finish that test, finish linting --- .../ingest_envoy/ingest_envoy/ingest.py | 6 ++--- .../ingest_envoy/ingestion_manifest_writer.py | 22 +++---------------- .../test/test_miscellaneous_manifests.py | 1 - 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingest.py b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingest.py index e6c1bfa41..30e4095b1 100644 --- a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingest.py +++ b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingest.py @@ -3,7 +3,7 @@ import sys from pathlib import Path -from ingest_envoy.ingestion_manifest_writer import EvlaCalIngestionManifestWriter +from ingest_envoy.ingestion_manifest import IngestionManifest from ingest_envoy.utilities import ScienceProductType @@ -24,6 +24,4 @@ def main(): # ValueError will be thrown if ingestion_type isn't a known ScienceProductType ingestion_type = ScienceProductType.from_str(ingestion_type) - writer = EvlaCalIngestionManifestWriter(ingestion_type, source_dir) - writer.write_evla_cal_manifest(locator) - # IngestionManifest(source_dir, ingestion_type, locator).create() + IngestionManifest(source_dir, ingestion_type, locator).create() diff --git a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest_writer.py b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest_writer.py index 9d823a9fc..c823bf861 100644 --- a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest_writer.py +++ b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest_writer.py @@ -1,6 +1,4 @@ """Build an ingestion manifest file""" - - import json import logging import re @@ -132,7 +130,7 @@ class EvlaCalIngestionManifestWriter: raise NotImplementedError(f"{self.sp_type}") @staticmethod - def format_timestamp(start_time: DateTime) -> str: + def format_timestamp(datetime: DateTime) -> str: """ Format the current time as follows: input format: @@ -140,25 +138,11 @@ class EvlaCalIngestionManifestWriter: desired output format as yyyy_MM_dd_'T'HH_mm_ss.SSS: 2021_07_01'T'13_49_17.237 - :param start_time: current pendulum timestamp + :param datetime: current pendulum timestamp :return: timestamp suitable for ingestion manifest filename """ - time_str = str(start_time) - # change hyphens and colons to underscores - timestamp = time_str.replace("-", "_", len(time_str)) - timestamp = timestamp.replace(":", "_", len(timestamp)) - # chop off the last bit - timestamp = timestamp.split("+")[0] - # now timestamp ends with ss.###....; round to 3 places - ts_parts = timestamp.split("_") - seconds = float(ts_parts[len(ts_parts) - 1]) - rounded = round(seconds, 3) - timestamp = timestamp.replace(str(seconds), str(rounded)) - # finally, the T in single quotes - timestamp = timestamp.replace("T", "'T'") - - return timestamp + return datetime.format("YYYY_MM_DD'T'hh_mm_ss.SSS") @staticmethod def manifest_filename() -> str: diff --git a/apps/cli/executables/pexable/ingest_envoy/test/test_miscellaneous_manifests.py b/apps/cli/executables/pexable/ingest_envoy/test/test_miscellaneous_manifests.py index 396ae8460..2ae870eff 100644 --- a/apps/cli/executables/pexable/ingest_envoy/test/test_miscellaneous_manifests.py +++ b/apps/cli/executables/pexable/ingest_envoy/test/test_miscellaneous_manifests.py @@ -9,7 +9,6 @@ import pytest from ingest_envoy.ingestion_manifest import IngestionManifest from ingest_envoy.utilities import ScienceProductType -# ingest_path import IS used; keep it from .conftest import populate_fake_ingest_path, WANTED_FILENAMES, UNWANTED logger = logging.getLogger(IngestionManifest.__name__) -- GitLab