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

Failed and passed test for RestoreProductFinder

parent 225d23aa
No related branches found
No related tags found
No related merge requests found
Showing
with 32 additions and 3 deletions
......@@ -131,7 +131,7 @@ class RestoreProductFinder(ProductFinder):
def parse_metadata(self) -> ProductMetadata:
metadata_file = json.loads((self.dir / "metadata.json").read_bytes())
project_metadata = metadata_file["projectMetadata"]
casa_log_path = list(self.dir.glob("*/working/casa-*.log"))
casa_log_path = list(self.dir.glob("./working/casa-*.log"))
assert len(casa_log_path) == 1
casa_log_name = casa_log_path[0].name
start_timestamp_match = re.match(r"^casa-(?P<timestamp>[0-9]+-[0-9]+).log$", casa_log_name)
......@@ -139,7 +139,7 @@ class RestoreProductFinder(ProductFinder):
start_timestamp = pendulum.from_format(start_timestamp_match.group("timestamp"), "YYYYMMDD-HHmmss")
start_mjd = convert_datetime_to_mjd(start_timestamp)
return ProductMetadata(
project_metadata["telescope"], project_metadata["project_code"], "restored_cms", None, None, str(start_mjd)
project_metadata["telescope"], project_metadata["projectCode"], "restored_cms", None, None, str(start_mjd)
)
@property
......
......@@ -17,6 +17,7 @@
# along with Workspaces. If not, see <https://www.gnu.org/licenses/>.
import pathlib
import re
from dataclasses import dataclass
from typing import Tuple, Union
import chevron
......@@ -25,6 +26,7 @@ from .deliverer import Destination
from .destinations.interfaces import ProductMetadataIF, SpooledProduct
@dataclass
class ProductMetadata(ProductMetadataIF):
"""
Represents the metadata about a given product.
......
......@@ -24,8 +24,11 @@ from delivery.destinations.interfaces import (
Destination,
DestinationTempFile,
)
from delivery.finder import RestoreProductFinder
from delivery.products import Calibration, ProductMetadata, RestoreProduct
TEST_RESTORE_METADATA = ProductMetadata("EVLA", "17B-403", "restored_cms", None, None, "60468.6349189817")
class FakeDestination(Destination):
def __init__(self):
......@@ -81,7 +84,6 @@ def test_web_calibration(resource_path_root):
def test_restore(resource_path_root):
TEST_RESTORE_METADATA = ProductMetadata("EVLA", "17B-403", "restore", None, None, "60468.635023148265")
restore = RestoreProduct(resource_path_root / "restores" / "tmpfpjeptku", TEST_RESTORE_METADATA)
# OK now let's make sure that we're delivering properly
......@@ -128,3 +130,10 @@ def test_restore(resource_path_root):
assert file in expected_files or any(
file.startswith(expected_dir) for expected_dir in expected_dirs_to_file_counts.keys()
)
def test_restore_product_finder_parse_metadata(resource_path_root):
expected_metadata = TEST_RESTORE_METADATA
finder = RestoreProductFinder(resource_path_root / "restores" / "tmpfpjeptku")
actual_metadata = finder.parse_metadata()
assert actual_metadata == expected_metadata
{
"systemId": "163677",
"fileSetIds": ["17B-403.sb34574962.eb34577590_000.58035.544146898144", "17B-403_2017_10_09_T16_25_18.256.tar"],
"creationTime": "2024-06-07T15:13:05",
"workflowName": "restore_cms",
"providedFiles": "['PPR.xml']",
"productLocator": "uid://evla/execblock/4faf6c86-e326-4a40-846e-c8ed61a9a6bf",
"projectMetadata": {
"title": "Monitoring of the Extremely High Energy Neutrino IceCube-170922A Error Field ",
"observer": "Gregory Sivakoff",
"startTime": "58035.544171875",
"telescope": "EVLA",
"projectCode": "17B-403"
},
"calProductLocator": "uid://evla/calibration/1af77b76-193f-45ee-aae9-2abf5bc3a1c0",
"destinationDirectory": "/lustre/aoc/cluster/pipeline/dsoc-dev/workspaces/spool/tmpfpjeptku",
"casaHome": "/home/casa/packages/pipeline/production"
}
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