Skip to content
Snippets Groups Projects
Commit 5519caa8 authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

tweaks for manifest builder

parent d9366678
No related branches found
No related tags found
1 merge request!365WS-543: Addressed issues found in calibration ingestion testing
This commit is part of merge request !365. Comments created here will be created in the context of that merge request.
......@@ -69,15 +69,6 @@ class ManifestIF(ManifestComponentIF):
self.files_found = [file for file in self.staging_source_dir.iterdir()]
@abc.abstractmethod
def create(self):
"""
Build and write the manifest, which includes gathering various items in
ingestion_path to get info for the manifest.
:return:
"""
@abc.abstractmethod
def write(self):
"""
......@@ -111,13 +102,13 @@ class IngestionManifestBuilder:
def __init__(
self,
staging_source_dir: Path,
sp_type: ScienceProductType,
sp_type: str,
locator: str,
telescope: Telescope,
):
self.telescope = telescope
self.staging_source_dir = staging_source_dir
self.sp_type = sp_type
self.sp_type = ScienceProductType(sp_type)
self.locator = locator
self.files_found = [file for file in staging_source_dir.iterdir()]
if len(self.files_found) == 0:
......@@ -260,7 +251,7 @@ class IngestionManifestBuilder:
class IngestionManifest(ManifestIF):
"""needed for ingestion-launching interface"""
"""write ingestion manifest to file"""
def build_ingest_parameters(self):
"""
......@@ -279,34 +270,7 @@ class IngestionManifest(ManifestIF):
staging_source_dir=self.staging_source_dir,
)
def _build_input_group(self):
"""
Create the input group using the parameters.
:return:
"""
# N.B. this is sufficient for most types of ingestion,
# but ALMA CALs will have multiple EB SPs, identified only by locator,
# and VLBAs have no input group at all.
sp_in = InputScienceProduct(locator=self.locator)
return InputGroup([sp_in])
def _build_output_group(self) -> OutputGroup:
"""
Create the output group using the parameters.
:return:
"""
sp_tar = self._find_science_product_tar()
find_output_science_products(self.files_found, self.staging_source_dir)
sps_out = [OutputScienceProduct(self.sp_type, sp_tar.name)]
# find ancillary products, if any
ancillary_products = self._find_ancillary_products()
weblog = Path(self.ingestion_path / WEBLOG_FILENAME)
if weblog.exists():
ancillary_products.append(AncillaryProduct(type=WEBLOG_FILENAME, filename=str(weblog)))
return OutputGroup(sps_out)
# @property
def ingestion_path(self) -> Path:
return self.parameters.ingestion_path
......@@ -326,27 +290,6 @@ class IngestionManifest(ManifestIF):
return output_path
def create(self):
"""
Create the ingestion manifest in this directory for a product of this type,
identified by this locator.
:return:
"""
if self.sp_type != ScienceProductType.EVLA_CAL:
raise NotImplementedError(
f"Don't yet know how to handle {self.sp_type.value} ingestion"
)
builder = IngestionManifestBuilder(
staging_source_dir=Path(self.staging_source_dir),
sp_type=self.sp_type,
locator=self.locator,
telescope=self.telescope,
)
builder.build()
def to_json(self) -> JSON:
"""
Turn this object into a JSON string suitable for writing to a file
......
......@@ -9,6 +9,7 @@ from ingest_envoy.launchers import IngestCalibrationLauncher
parameters = {
"sdmId": "16B-069_sb32814386_1_001.57685.66193635417",
"telescope": "EVLA",
"workflowName": "std_calibration",
"spl": "uid://evla/execblock/48ba4c9d-d7c7-4a8f-9803-1115cd52459b",
"processingStart": "2021_07_06T21_50_48",
......@@ -21,7 +22,7 @@ parameters = {
class TestIngestCalibrationLauncher:
@pytest.mark.skip("Skip until manifest builder is complete")
@patch("ingest_envoy.ingestion_manifest.IngestionManifest.create")
@patch("ingest_envoy.ingestion_manifest.IngestionManifestBuilder.build")
@patch("subprocess.run")
def test_launch_ingestion(self, mock_run, mock_manifest):
IngestCalibrationLauncher(parameters).launch_ingestion()
......@@ -34,7 +35,7 @@ class TestIngestCalibrationLauncher:
assert mock_run.call_count == 1
@pytest.mark.skip("Skip until manifest builder is complete")
@patch("ingest_envoy.ingestion_manifest.IngestionManifest.create")
@patch("ingest_envoy.ingestion_manifest.IngestionManifestBuilder.build")
@patch("subprocess.run")
def test_prepare_for_ingest(self, mock_run, mock_manifest):
IngestCalibrationLauncher(parameters).prepare_for_ingest()
......@@ -47,7 +48,7 @@ class TestIngestCalibrationLauncher:
assert mock_run.call_count == 1
@pytest.mark.skip("Skip until manifest builder is complete")
@patch("ingest_envoy.ingestion_manifest.IngestionManifest.create")
@patch("ingest_envoy.ingestion_manifest.IngestionManifestBuilder.build")
def test_create_manifest(self, mock_manifest):
IngestCalibrationLauncher(parameters).create_manifest()
assert mock_manifest.call_count == 1
......@@ -38,9 +38,9 @@ def test_entry_point_for_evla_cal(ingest_path: Path):
assert sp_tar
builder = IngestionManifestBuilder(
telescope=Telescope.EVLA,
telescope=Telescope.EVLA.value,
locator=locator,
sp_type=ScienceProductType.EVLA_CAL,
sp_type=ScienceProductType.EVLA_CAL.value,
staging_source_dir=ingest_path,
)
builder.build()
......
......@@ -509,7 +509,7 @@ class WorkflowService(WorkflowServiceIF):
status = WorkflowRequestState.Complete.name
elif message["type"] == "workflow-failed":
status = WorkflowRequestState.Failed.name
elif message["type"] == "delivery":
elif message["type"] == "delivery" or message["type"] == "ingestion-complete":
status = WorkflowRequestState.Complete.name
else:
status = "Unknown"
......
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