From ce6917ce42c79e5ce8789501e369c2831c7db538 Mon Sep 17 00:00:00 2001 From: Charlotte Hausman <chausman@nrao.edu> Date: Thu, 5 Aug 2021 14:48:06 +0000 Subject: [PATCH] fixing aux_image_metadata.json missing from staging area --- .../ingest_envoy/ingest_envoy/collectors.py | 15 ++++++++++----- .../pexable/ingest_envoy/test/test_collectors.py | 8 +++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/collectors.py b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/collectors.py index 253d6013b..d10092f6b 100644 --- a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/collectors.py +++ b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/collectors.py @@ -1,14 +1,9 @@ -import glob -import os -import pathlib import shutil import subprocess import sys import logging -import json - from ingest_envoy.schema import AbstractTextFile @@ -17,6 +12,9 @@ class ImageCollector: self.logger = logging.getLogger("ingest_envoy") self.parameters = parameters self.spl = parameters["spl"] + self.staging_source_dir = ( + self.parameters["staging_area"] + "/" + self.parameters["workflowDir"] + ) def collect_image_metadata(self) -> AbstractTextFile: file = open("./aux_image_metadata.json", "r") @@ -34,6 +32,13 @@ class ImageCollector: stdout=sys.stdout, stderr=sys.stderr, ) + self.aux_file_to_staging() + + def aux_file_to_staging(self): + shutil.copy2( + "./aux_image_metadata.json", + self.staging_source_dir, + ) def create_artifacts_name(self): name = "pipeline_artifacts_" diff --git a/apps/cli/executables/pexable/ingest_envoy/test/test_collectors.py b/apps/cli/executables/pexable/ingest_envoy/test/test_collectors.py index fa5a4c1e1..a9dc56d3b 100644 --- a/apps/cli/executables/pexable/ingest_envoy/test/test_collectors.py +++ b/apps/cli/executables/pexable/ingest_envoy/test/test_collectors.py @@ -30,11 +30,17 @@ class TestImageCollector: assert mock_open.call_count == 1 assert isinstance(aux, AbstractTextFile) + @patch("shutil.copy2") @patch("subprocess.run") - def test_collect_image_products(self, mock_run): + def test_collect_image_products(self, mock_run, mock_copy): image_collector.collect_image_products() assert mock_run.call_count == 1 + @patch("shutil.copy2") + def test_aux_file_to_staging(self, mock_copy): + image_collector.aux_file_to_staging() + assert mock_copy.call_count == 1 + def test_create_artifacts_name(self): expected_name = "pipeline_artifacts_" + parameters["processingStart"] -- GitLab