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

Updated casa_envoy to rename PPR's in restore mode

parent f077e24f
No related branches found
No related tags found
No related merge requests found
......@@ -19,3 +19,8 @@
Workspaces CASA functionality bridge
"""
__version__ = "2.8.5.dev1"
# The desired names for the calibration's and restore's PPR's in "restore" mode
# Neither will likely be named this way at launch time, but deliver needs to be able to distinguish them for users.
RESTORE_ORIG_CAL_PPR_NAME = "PPR_calibration.xml"
RESTORE_RESTORE_PPR_NAME = "PPR_restore.xml"
......@@ -28,6 +28,7 @@ import tarfile
from pathlib import Path
from typing import Optional
from casa_envoy import RESTORE_ORIG_CAL_PPR_NAME
from casa_envoy.interfaces import FoundationIF
from casa_envoy.schema import AbstractTextFile
......@@ -87,7 +88,7 @@ class GeneralFoundation(FoundationIF):
:return:
"""
# Copy files that need to exist next to the data into the rawdata directory
for file in Path(self.working_dir).glob('*flagtargetstemplate.txt'):
for file in Path(self.working_dir).glob("*flagtargetstemplate.txt"):
if Path(file).exists():
shutil.copy(file, self.rawdata_dir)
......@@ -145,14 +146,18 @@ class RestoreFoundation(FoundationIF):
calibration.extractall("./rawdata")
calibration.close()
src = "./rawdata/products"
src2 = "./rawdata/" + cal_name[:-4] + "/products"
src2: str = "./rawdata/" + cal_name[:-4] + "/products"
chosen_src = None
if Path(src).exists():
shutil.copytree(src, "./products/", dirs_exist_ok=True)
chosen_src = src
elif Path(src2).exists():
shutil.copytree(src2, "./products", dirs_exist_ok=True)
chosen_src = src2
else:
self.logger.error(f"ERROR: calibration tar file {cal_name} failed to extract correctly!")
sys.exit(1)
shutil.copytree(chosen_src, "./products", dirs_exist_ok=True)
# Rename the PPR.xml so that it's not clobbered by the restore's one in auditor.correct_for_condor
Path("./products/PPR.xml").rename(f"./products/{RESTORE_ORIG_CAL_PPR_NAME}")
else:
self.logger.error(f"ERROR: calibration tar file {cal_name} not found in rawdata!")
# abort since required data not found
......
......@@ -25,6 +25,7 @@ import subprocess
import sys
from typing import Dict, Optional, Union
from casa_envoy import RESTORE_RESTORE_PPR_NAME
from casa_envoy.auditor import AuditDirectories, AuditFiles
from casa_envoy.configure import (
CasaConfigure,
......@@ -144,6 +145,8 @@ class CalibrationLauncher(LauncherIF):
self.logger = logging.getLogger("casa_envoy")
self.parameters = parameters
self.ppr = get_abs_file(parameters.get("ppr")) if parameters.get("ppr") is not None else None
if self.ppr is not None and self.parameters["product_type"] == ProductType.RESTORE.value:
self.ppr.filename = RESTORE_RESTORE_PPR_NAME
self.metadata = get_abs_file(parameters.get("metadata"))
self.content = json.loads(self.metadata.content)
self.runner = determine_runner_type(parameters)
......
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