Skip to content
Snippets Groups Projects
Commit 411ed5a5 authored by Sam Kagan's avatar Sam Kagan
Browse files

Added failing tests for partial curation with ManBuilder.manifest_dir

parent fa092afa
No related branches found
No related tags found
2 merge requests!1605Merge 2.8.2.3 work to main,!1505Implemented manifest generation for EB full curation in ingest_envoy
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
}, },
"reingest": { "reingest": {
"locator": "uid://I/am/a/locator", "locator": "uid://I/am/a/locator",
"type": "execution_block" "type": "execution_block",
"targets": null
}, },
"output_group": { "output_group": {
"science_products": [ "science_products": [
......
{
"parameters": {
"ngas_ingest": false,
"telescope": "EVLA",
"ingestion_path": "/lustre/aoc/cluster/pipeline/dsoc-prod/workspaces/spool/tmp8gfknlo9/19A-001/observation.54321.894327984569"
},
"reingest": {
"targets": ["subscans.dec"],
"locator": "uid://I/am/a/locator",
"type": "execution_block"
}
}
{
"parameters": {
"ngas_ingest": false,
"telescope": "EVLA"
},
"reingest": {
"targets": ["subscans.dec"],
"locator": "uid://I/am/a/locator",
"type": "execution_block"
}
}
...@@ -20,6 +20,7 @@ import shutil ...@@ -20,6 +20,7 @@ import shutil
import tarfile import tarfile
from pathlib import Path from pathlib import Path
import pytest
from conftest import ( from conftest import (
EVLA_EB_LOCATOR, EVLA_EB_LOCATOR,
EVLA_EB_NAME, EVLA_EB_NAME,
...@@ -47,7 +48,6 @@ def test_manifest_full_curation_eb_manifest_metadata(ingest_path: Path): ...@@ -47,7 +48,6 @@ def test_manifest_full_curation_eb_manifest_metadata(ingest_path: Path):
:param ingest_path: directory where curator's sources will be :param ingest_path: directory where curator's sources will be
""" """
eb_files = populate_fake_evla_eb_curator_source_path(ingest_path) eb_files = populate_fake_evla_eb_curator_source_path(ingest_path)
try: try:
assert len(eb_files) == 1 assert len(eb_files) == 1
...@@ -89,9 +89,7 @@ def test_manifest_full_curation_eb_manifest_file(ingest_path: Path): ...@@ -89,9 +89,7 @@ def test_manifest_full_curation_eb_manifest_file(ingest_path: Path):
"""Test serialization of manifest as well as its creation """Test serialization of manifest as well as its creation
:param ingest_path: directory where curator's sources will be :param ingest_path: directory where curator's sources will be
""" """
populate_fake_evla_eb_curator_source_path(ingest_path) populate_fake_evla_eb_curator_source_path(ingest_path)
try: try:
expected_manifest_file = find_example_manifest("full_curation_evla_eb_manifest") expected_manifest_file = find_example_manifest("full_curation_evla_eb_manifest")
with open(expected_manifest_file) as f: with open(expected_manifest_file) as f:
...@@ -146,6 +144,73 @@ def test_manifest_full_curation_eb_manifest_file(ingest_path: Path): ...@@ -146,6 +144,73 @@ def test_manifest_full_curation_eb_manifest_file(ingest_path: Path):
shutil.rmtree(ingest_path) shutil.rmtree(ingest_path)
@pytest.mark.parametrize("has_curation_source", [True, False])
def test_manifest_partial_curation_eb(has_curation_source: bool, ingest_path: Path):
"""Test full-curation manifest creation & serialization
:param ingest_path: directory where curator's sources will be
"""
curation_source = str(ingest_path)
expected_manifest_name = "partial_curation_evla_eb_manifest"
if not has_curation_source:
expected_manifest_name = "partial_curation_evla_eb_manifest_no_curation_source"
curation_source = None
eb_files = populate_fake_evla_eb_curator_source_path(ingest_path)
try:
assert len(eb_files) == 1
actual_manifest, actual_manifest_file = IngestionManifestBuilder(
telescope=Telescope.EVLA.value,
staging_source_dir=None,
sp_type=ScienceProductType.EXEC_BLOCK.value,
locator=EVLA_EB_LOCATOR,
filename=EVLA_EB_NAME,
curate=(CuratorType.PARTIAL, curation_source, ["subscans.dec"]),
manifest_dir=ingest_path,
).build()
# Check metadata
params = actual_manifest.parameters
assert params.ngas_ingest is False
assert params.telescope == Telescope.EVLA
if has_curation_source:
assert params.staging_source_dir == Path(curation_source)
else:
assert not hasattr(params, "staging_source_dir")
assert not hasattr(params, "calibrate")
assert not actual_manifest.input_group
assert not actual_manifest.output_group
reingest = actual_manifest.reingest
assert reingest
assert reingest.targets is not None
assert reingest.locator == EVLA_EB_LOCATOR
assert reingest.product_type == ScienceProductType.EXEC_BLOCK
# Check that manifest file exists on disk
with open(actual_manifest_file) as f:
actual_manifest_deser = json.load(f)
assert actual_manifest.to_dict() == actual_manifest_deser
# Check against expected manifest
expected_manifest_file = find_example_manifest(expected_manifest_name)
with open(expected_manifest_file) as f:
expected_manifest = json.load(f)
# ingestion_path depends on the ingest_path fixture, so ignore it
expected_params = expected_manifest["parameters"]
actual_params = actual_manifest_deser["parameters"]
assert actual_params["ngas_ingest"] == expected_params["ngas_ingest"]
assert actual_manifest_deser.get("input_group") == expected_manifest.get("input_group")
assert actual_manifest_deser.get("output_group") == expected_manifest.get("output_group")
assert actual_manifest_deser["reingest"] == expected_manifest["reingest"]
# Make sure there are no artifacts
artifacts_file = [file for file in ingest_path.glob("ingestion_artifacts*.tar")]
assert not artifacts_file
finally:
# Clean up
shutil.rmtree(ingest_path)
def test_reingest_block_json_well_formed_with_targets(): def test_reingest_block_json_well_formed_with_targets():
""" """
Make sure our ReingestGroup makes nice JSON when given targets Make sure our ReingestGroup makes nice JSON when given targets
......
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