diff --git a/apps/cli/executables/pexable/casa_envoy/casa_envoy/palaver.py b/apps/cli/executables/pexable/casa_envoy/casa_envoy/palaver.py index 076fd4a741d66064af8246a093547c74c88a008d..f72f2ff7e2affc6dd02ccce13fa9434ba4aedb33 100644 --- a/apps/cli/executables/pexable/casa_envoy/casa_envoy/palaver.py +++ b/apps/cli/executables/pexable/casa_envoy/casa_envoy/palaver.py @@ -56,7 +56,8 @@ def _get_settings(cwd: pathlib.Path, args: list) -> dict: processing_dir = str(cwd.name) metadata = args[0] - ppr = args[1] + # Restores don't always come with a PPR from the arguments, sometimes they want to use the PPR in the cal. + ppr = args[1] if len(args) > 1 else None return { "useCasa": use_casa, @@ -78,25 +79,38 @@ def _setup_launcher(path: pathlib.Path, args: argparse.Namespace) -> LauncherIF: :param args: arguments specifying type of processing requested :return: Launcher """ + if not ( + (args.standard_cal is not None) + ^ (args.vlass_cal is not None) + ^ (args.standard_img is not None) + ^ (args.vlass_img is not None) + ^ (args.restore is not None) + ^ (args.split is not None) + ): + raise ValueError( + "Expected exactly one of standard_cal, vlass_cal, standard_img, vlass_img, or restore arguments to be provided, found none or multiple" + ) parameters = {} if args.parallel is not None: parameters["requested_parallel"] = args.parallel - if args.standard_cal is not None or args.vlass_cal is not None: + if args.standard_cal is not None or args.vlass_cal is not None or args.restore is not None: if args.standard_cal: parameters = {**parameters, **_get_settings(path, args.standard_cal)} - if args.restore: - parameters["product_type"] = ProductType.RESTORE.value - else: - parameters["product_type"] = ProductType.STD_CAL.value - - if args.vlass_cal: + parameters["product_type"] = ProductType.STD_CAL.value + elif args.vlass_cal: parameters = { **parameters, **_get_settings(path, args.vlass_cal), "product_type": ProductType.VLASS_CAL.value, } + elif args.restore: + parameters = { + **parameters, + **_get_settings(path, args.restore), + "product_type": ProductType.RESTORE.value, + } return CalibrationLauncher(parameters) elif args.standard_img is not None or args.vlass_img is not None: @@ -175,9 +189,10 @@ def arg_parser() -> argparse.ArgumentParser: ) parser.add_argument( "--restore", + nargs="+", required=False, - action="store_true", - help="run the restore measurement set CASA pipeline, use in conjunction with '-c'", + action="store", + help="run the restore measurement set CASA pipeline", ) parser.add_argument( "--integrated", diff --git a/apps/cli/executables/pexable/casa_envoy/test/test_casa_envoy.py b/apps/cli/executables/pexable/casa_envoy/test/test_casa_envoy.py index d88f477ad051ab6459c1905b87333016a72defe9..50bc4d8f00a707d8078d5103e38e81ffed693158 100644 --- a/apps/cli/executables/pexable/casa_envoy/test/test_casa_envoy.py +++ b/apps/cli/executables/pexable/casa_envoy/test/test_casa_envoy.py @@ -182,9 +182,7 @@ class TestPalaver: :param mock_json: :return: """ - args.restore = [ - "test/input_files/restore.json", - ] + args.restore = ["test/input_files/restore.json", "test/input_files/PPR.xml"] with patch("argparse.ArgumentParser.parse_args", MagicMock(return_value=args)) as mock_args: with patch("casa_envoy.launchers.CalibrationLauncher.launch_casa") as cal_launcher: