diff --git a/apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py b/apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py index 16bf16856a42a26218cd3cb0da6d039cae9641fc..152edbacc89be40aa9513b6f939c94a4d1ed2800 100644 --- a/apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py +++ b/apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py @@ -1,21 +1,14 @@ """ Extracts workflow relevant metadata from the NRAO archive based on Science Product Locator. """ -import argparse import json import logging -import sys import pendulum from typing import List -from aat_wrest.observation_wrester import ObservationWrester from aat_wrest.utilities import PENDULUM_FORMAT, TIME_ZONE, MDDBConnector -logger = logging.getLogger("aat_wrest") -logger.setLevel(logging.INFO) -logger.addHandler(logging.StreamHandler(sys.stdout)) - class WrestWorkflowMetadata: """ @@ -26,19 +19,12 @@ class WrestWorkflowMetadata: self, connection: MDDBConnector, spl: List[str] = None, - fileset_id: str = None, sdm_id: str = None, ): self.logger = logging.getLogger("aat_wrest") self.conn = connection - if fileset_id is not None: - self.fileset_id = fileset_id - if sdm_id is not None: - self.sdm_id = sdm_id - if not spl and fileset_id: - self.spl = self.wrest_obs_metadata_from_fileset_id(fileset_id)["spl"] - else: - self.spl = spl + self.sdm_id = sdm_id + self.spl = spl def wrest_standard_cal_info(self) -> json: """ @@ -89,8 +75,8 @@ class WrestWorkflowMetadata: def wrest_standard_image_info(self) -> json: """ - Given an execution block science product locator, returns the required metadata to run - the standard calibration workflow + Given an execution block SDM ID, returns the required metadata to run + the standard imaging workflow :return: """ @@ -140,8 +126,6 @@ class WrestWorkflowMetadata: the required metadata to run the restore CMS workflow :return: """ - print(self.spl) - eb_sql = f""" SELECT ngas_fileset_id as filesetId, e.project_code as projectCode, @@ -190,94 +174,3 @@ class WrestWorkflowMetadata: finally: self.conn.close() return make_json - - def wrest_obs_metadata_from_fileset_id(self, fileset_id: str) -> str: - """ - Given a fileset_id, query the Metadata DB and return the corresponding science_product_locator - - :param fileset_id: - :return science_product_locator: - """ - metadata = { - "spl": None, - "bands": None, - "array_config": None, - "obs_start_time": None, - "obs_end_time": None, - } - sql = f""" - SELECT science_product_locator, band_code, configuration, starttime, endtime - FROM execution_blocks - WHERE ngas_fileset_id = %(fileset_id)s - """ - with self.conn.cursor() as cursor: - cursor.execute(sql, {"fileset_id": fileset_id}) - data = cursor.fetchall() - metadata["spl"] = data[0][0] - metadata["bands"] = data[0][1] - metadata["array_config"] = data[0][2] - metadata["obs_start_time"] = data[0][3] - metadata["obs_end_time"] = data[0][4] - - return metadata - - -def parser() -> argparse.ArgumentParser: - arg_parser = argparse.ArgumentParser( - description="Workspaces-to-Archive Metadata Exchange", - formatter_class=argparse.RawTextHelpFormatter, - ) - arg_parser.add_argument( - "-sc", - "--stdcals", - nargs=1, - action="store", - required=False, - help="Find workflow metadata for standard calibrations with provided product locator", - ) - arg_parser.add_argument( - "-si", - "--stdimg", - nargs=1, - action="store", - required=False, - help="Find workflow metadata for standard CMS imaging with provided SDM id", - ) - arg_parser.add_argument( - "-r", - "--restore", - nargs="+", - default=[], - required=False, - help="Find workflow metadata for Restores with provided EB product locator and Cal product locator", - ) - arg_parser.add_argument( - "-obs", - "--observation", - nargs=1, - action="store", - required=False, - help="Find display metadata for observations by product locator", - ) - return arg_parser - - -def determine_wrester(connection: MDDBConnector, args: argparse.Namespace): - if args.stdcals: - data = WrestWorkflowMetadata(connection, spl=args.stdcals[0]).wrest_standard_cal_info() - if args.stdimg: - data = WrestWorkflowMetadata(connection, sdm_id=args.stdimg[0]).wrest_standard_image_info() - if args.restore: - print(args) - data = WrestWorkflowMetadata(connection, spl=args.restore).wrest_restore_info() - if args.observation: - data = ObservationWrester(connection, spl=args.observation[0]).wrest_observation_info() - - print(data) - - -def main(): - args = parser().parse_args() - connection = MDDBConnector() - - determine_wrester(connection, args) diff --git a/apps/cli/utilities/aat_wrest/aat_wrest/observation_wrester.py b/apps/cli/utilities/aat_wrest/aat_wrest/observation_wrester.py index 7f05cbc71ac5d9a0034e039fb5dcefbd705fedc5..b42ce5ea7eeef6b070c5dc7b91b263ea601635eb 100644 --- a/apps/cli/utilities/aat_wrest/aat_wrest/observation_wrester.py +++ b/apps/cli/utilities/aat_wrest/aat_wrest/observation_wrester.py @@ -11,17 +11,60 @@ import pendulum from aat_wrest.utilities import MDDBConnector, TIME_ZONE, format_interval -class ObservationWrester: +class WrestObservationMetadata: """ Class for extracting observation metadata """ - def __init__(self, connection: MDDBConnector, spl: str): + def __init__(self, connection: MDDBConnector, sdm_id: str): self.logger = logging.getLogger("aat_wrest") self.conn = connection - self.spl = spl + self.sdm_id = sdm_id def wrest_observation_info(self) -> json: + """ + Given a sdm_id, query the Metadata DB for observation data related to an ingestion-complete event + + :param sdm_id: + :return science_product_locator: + """ + metadata = {} + sql = f""" + SELECT science_product_locator, + band_code, + configuration, + starttime, + endtime + FROM execution_blocks + WHERE ngas_fileset_id = %(sdm_id)s + """ + try: + cursor = self.conn.cursor() + cursor.execute(sql, {"sdm_id": self.sdm_id}) + data = cursor.fetchall() + if data: + metadata = json.dumps( + { + "spl": data[0][0], + "bands": data[0][1], + "array_config": data[0][2], + "obs_start_time": data[0][3], + "obs_end_time": data[0][4], + } + ) + else: + self.logger.error( + f"ERROR: aat-wrest query returned no results!" + f" The database appears to be missing information for SDM id {self.sdm_id}" + ) + finally: + self.conn.close() + return metadata + + # + # currently unused. Was intended for analyst list display of waiting capability requests/executions + # + def wrest_observation_time_info(self) -> json: """ Given a product locator, reports the project code, observation length, and time in queue for an incomplete observation. diff --git a/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py b/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py new file mode 100644 index 0000000000000000000000000000000000000000..c85b8f35ea97afeb505734a6c47c5a1cedd9a645 --- /dev/null +++ b/apps/cli/utilities/aat_wrest/aat_wrest/wrest.py @@ -0,0 +1,80 @@ +import argparse +import logging +import sys + +from aat_wrest.observation_wrester import WrestObservationMetadata +from aat_wrest.metadata_wrester import WrestWorkflowMetadata +from aat_wrest.utilities import MDDBConnector + +""" +AAT Wrest extract information from the NRAO Archive metadata database +""" + +logger = logging.getLogger("aat_wrest") +logger.setLevel(logging.INFO) +logger.addHandler(logging.StreamHandler(sys.stdout)) + + +def parser() -> argparse.ArgumentParser: + arg_parser = argparse.ArgumentParser( + description="Workspaces-to-Archive Metadata Exchange", + formatter_class=argparse.RawTextHelpFormatter, + ) + arg_parser.add_argument( + "-sc", + "--stdcals", + nargs=1, + action="store", + required=False, + help="Find workflow metadata for standard calibrations with provided product locator", + ) + arg_parser.add_argument( + "-si", + "--stdimg", + nargs=1, + action="store", + required=False, + help="Find workflow metadata for standard CMS imaging with provided SDM id", + ) + arg_parser.add_argument( + "-r", + "--restore", + nargs="+", + default=[], + required=False, + help="Find workflow metadata for Restores with provided EB product locator and Cal product locator", + ) + arg_parser.add_argument( + "-obs", + "--observation", + nargs=1, + action="store", + required=False, + help="Find display metadata for observations by SDM id", + ) + return arg_parser + + +def determine_wrester(connection: MDDBConnector, args: argparse.Namespace): + if args.stdcals: + data = WrestWorkflowMetadata(connection, spl=args.stdcals[0]).wrest_standard_cal_info() + elif args.stdimg: + data = WrestWorkflowMetadata(connection, sdm_id=args.stdimg[0]).wrest_standard_image_info() + elif args.restore: + print(args) + data = WrestWorkflowMetadata(connection, spl=args.restore).wrest_restore_info() + elif args.observation: + data = WrestObservationMetadata( + connection, sdm_id=args.observation[0] + ).wrest_observation_info() + else: + data = None + + print(data) + + +def main(): + args = parser().parse_args() + connection = MDDBConnector() + + determine_wrester(connection, args) diff --git a/apps/cli/utilities/aat_wrest/setup.py b/apps/cli/utilities/aat_wrest/setup.py index 03ee6029d670925e793568267361afe269c6f26b..e5a2ca9cddc8147039357de351fe2d6aef8421c6 100644 --- a/apps/cli/utilities/aat_wrest/setup.py +++ b/apps/cli/utilities/aat_wrest/setup.py @@ -23,5 +23,5 @@ setup( keywords=[], packages=["aat_wrest"], classifiers=["Programming Language :: Python :: 3.8"], - entry_points={"console_scripts": ["aat_wrest = aat_wrest.metadata_wrester:main"]}, + entry_points={"console_scripts": ["aat_wrest = aat_wrest.wrest:main"]}, ) diff --git a/apps/cli/utilities/aat_wrest/test/test_aat_wrest.py b/apps/cli/utilities/aat_wrest/test/test_aat_wrest.py index c7736d9ec47199b6d39d0b80406d7a3939c0b47a..47dc735e6abb137e5c5e42fbde3e6adc344bd812 100644 --- a/apps/cli/utilities/aat_wrest/test/test_aat_wrest.py +++ b/apps/cli/utilities/aat_wrest/test/test_aat_wrest.py @@ -43,35 +43,11 @@ def mock_wrester(args: argparse.Namespace) -> WrestWorkflowMetadata: return WrestWorkflowMetadata(connection=mock_connect, sdm_id=args.stdimg) -@pytest.fixture -def fake_obs_metadata() -> List[Tuple[str]]: - return [ - ( - "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", - "Ka", - "D", - "1234567", - "123598898", - ) - ] - - cal_wrester = mock_wrester(args_cal) img_wrester = mock_wrester(args_image) class TestAatWrest: - def test_init(self, fake_obs_metadata: List[Tuple[str]]): - fileset_id = "17B-197.sb34663512.eb34806505.58108.78427738426" - with patch("psycopg2.connect") as mock_connect: - mock_connect.cursor.return_value.__enter__.return_value.fetchall.return_value = ( - fake_obs_metadata - ) - wrester_no_spl = WrestWorkflowMetadata( - connection=mock_connect, spl=None, fileset_id=fileset_id - ) - assert wrester_no_spl.spl == "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba" - @patch("json.dumps", MagicMock(return_value=result_cal)) def test_wrest_standard_cal_info(self): cal_wrester.conn.cursor.return_value.fetchall.return_value = [ @@ -112,19 +88,3 @@ class TestAatWrest: ' "projectCode": "Operations", "title": "", "startTime": 58099.6710792824, ' '"observer": "VLA Operations", "telescope": "EVLA", "created_at": "2021-06-30T20:18:21"}' ) - - def test_wrest_obs_metadata_from_fileset_id(self, fake_obs_metadata: List[Tuple[str]]): - cal_wrester.conn.cursor.return_value.__enter__.return_value.fetchall.return_value = ( - fake_obs_metadata - ) - metadata = cal_wrester.wrest_obs_metadata_from_fileset_id( - "17B-197.sb34663512.eb34806505.58108.78427738426" - ) - - assert metadata == { - "spl": "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", - "bands": "Ka", - "array_config": "D", - "obs_start_time": "1234567", - "obs_end_time": "123598898", - } diff --git a/apps/cli/utilities/aat_wrest/test/test_observation_wrester.py b/apps/cli/utilities/aat_wrest/test/test_observation_wrester.py new file mode 100644 index 0000000000000000000000000000000000000000..f07a79be185fd483fb55710b6993569527179092 --- /dev/null +++ b/apps/cli/utilities/aat_wrest/test/test_observation_wrester.py @@ -0,0 +1,116 @@ +""" +Tests for aat_wrest.observation_wrester +""" + +import argparse +from enum import Enum +from unittest.mock import patch, MagicMock + +# pylint: disable=E0401, E0402 +import json +import pytest +from aat_wrest.observation_wrester import WrestObservationMetadata + + +class Keys(Enum): + """The things we're reporting""" + + PROJECT = "projectCode" + OBS_TIME = "timeObserved" + QUEUE_TIME = "timeInQueue" + + +PROJECT = Keys.PROJECT.value +OBS_TIME = Keys.OBS_TIME.value +QUEUE_TIME = Keys.QUEUE_TIME.value + + +_17A_109_SPL = "uid://evla/execblock/5c71ade0-d035-4fd5-a36f-0389e34db0e5" +_17A_109_ARGS = argparse.Namespace(spl=_17A_109_SPL) +_17A_109_EXPECTED = { + PROJECT: "17A-109", + OBS_TIME: "0 days, 0 hours, 4 minutes, 34 seconds", + QUEUE_TIME: "1125 days, 11 hours, 43 minutes, 58 seconds", +} + +args = argparse.Namespace(observation="17B-197.sb34663512.eb34806505.58108.78427738426") + +result_obs = ( + '{"spl": "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", ' + '"bands": "Ka", ' + '"array_config": "D", ' + '"obs_start_time": "1234567", ' + '"obs_end_time": "123598898" }' +) + + +def mock_wrester(args: argparse.Namespace) -> WrestObservationMetadata: + """ + Pretend to get the information from the MDDB. + + :param args: + :return: + """ + with patch("psycopg2.connect") as conn: + return WrestObservationMetadata(conn, args.observation) + + +wrester = mock_wrester(args) + + +class TestWrestObservationInfo: + @patch("json.dumps", MagicMock(return_value=result_obs)) + def test_wrest_observation_info(self): + wrester.conn.cursor.return_value.fetchall.return_value = [ + "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", + "Ka", + "D", + "1234567", + "123598898", + ] + + assert args.observation == "17B-197.sb34663512.eb34806505.58108.78427738426" + metadata = wrester.wrest_observation_info() + + assert ( + metadata == '{"spl": "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", ' + '"bands": "Ka", ' + '"array_config": "D", ' + '"obs_start_time": "1234567", ' + '"obs_end_time": "123598898" }' + ) + + @pytest.mark.skip("Dates are broken. Method superseded by wrest_observation_info") + @patch("json.dumps", MagicMock(return_value=_17A_109_EXPECTED)) + def test_gets_expected_observation_info(self): + """ + Does ObservationWrester wrest the expected data from the MDDB? + + :return: + """ + wrester = mock_wrester(_17A_109_ARGS) + assert wrester.spl == _17A_109_SPL + actual = wrester.wrest_observation_time_info() + assert actual == _17A_109_EXPECTED + + @pytest.mark.skip("... Dates are broken... Method superseded by wrest_observation_info") + def test_handles_evla_exec_block(self): + """ + Confirm we get what we expect when observing time is minimal. + :return: + """ + spl = "uid://evla/execblock/91c685b6-4527-44b1-9f91-3904e1125817" + args = argparse.Namespace(spl=spl) + expected = { + PROJECT: "19A-440", + OBS_TIME: "0 days, 0 hours, 0 minutes, 4 seconds", + QUEUE_TIME: "627 days, 22 hours, 43 minutes, 6 seconds", + } + + with patch("json.dumps", MagicMock(return_value=expected)): + wrester = mock_wrester(args) + actual = wrester.wrest_observation_time_info() + assert actual[PROJECT] == expected[PROJECT] + obs_parts = actual[OBS_TIME].split(", ") + seconds_part = obs_parts[3].split(" ") + assert int(seconds_part[0]) == 4 diff --git a/apps/cli/utilities/aat_wrest/test/test_wrest_pending_obs.py b/apps/cli/utilities/aat_wrest/test/test_wrest_pending_obs.py deleted file mode 100644 index 0328ac2c6e05bfb87c30c8ac374c52864484b0a7..0000000000000000000000000000000000000000 --- a/apps/cli/utilities/aat_wrest/test/test_wrest_pending_obs.py +++ /dev/null @@ -1,154 +0,0 @@ -""" WS-351: As a DA I want to see a list of capability requests per capability / WS-368 """ - -import argparse -import json -import logging -import os -import sys -from enum import Enum -from unittest.mock import patch, MagicMock - -# pylint: disable=E0401, E0402 -import pytest -from aat_wrest.observation_wrester import ObservationWrester - -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) -logger.addHandler(logging.StreamHandler(sys.stdout)) - - -class Keys(Enum): - """The things we're reporting""" - - PROJECT = "projectCode" - OBS_TIME = "timeObserved" - QUEUE_TIME = "timeInQueue" - - -PROJECT = Keys.PROJECT.value -OBS_TIME = Keys.OBS_TIME.value -QUEUE_TIME = Keys.QUEUE_TIME.value - - -_17A_109_SPL = "uid://evla/execblock/5c71ade0-d035-4fd5-a36f-0389e34db0e5" -_17A_109_ARGS = argparse.Namespace(spl=_17A_109_SPL) -_17A_109_EXPECTED = { - PROJECT: "17A-109", - OBS_TIME: "0 days, 0 hours, 4 minutes, 34 seconds", - QUEUE_TIME: "1125 days, 11 hours, 43 minutes, 58 seconds", -} - - -def mock_wrester(args: argparse.Namespace) -> ObservationWrester: - """ - Pretend to get the information from the MDDB. - - :param args: - :return: - """ - with patch("psycopg2.connect") as conn: - return ObservationWrester(conn, args.spl) - - -@pytest.mark.skip("... Dates are broken...") -@patch("json.dumps", MagicMock(return_value=_17A_109_EXPECTED)) -def test_gets_expected_observation_info(): - """ - Does ObservationWrester wrest the expected data from the MDDB? - - :return: - """ - wrester = mock_wrester(_17A_109_ARGS) - assert wrester.spl == _17A_109_SPL - actual = wrester.wrest_observation_info() - assert actual == _17A_109_EXPECTED - - -@pytest.mark.skip("actually hits the metadata database") -def test_really_pulls_observation_info(): - """ - Does ObservationWrester wrest the expected data from the MDDB 4 realz? - We're always going to skip this test, but let's keep it here - for degubbing porpoises. - - :return: - """ - - wrester = mock_wrester(_17A_109_ARGS) - json_str = ObservationWrester(wrester.conn, _17A_109_SPL).wrest_observation_info() - obsv_dict = json.loads(json_str) - assert obsv_dict[PROJECT] == _17A_109_EXPECTED[PROJECT] - time_obsvd = obsv_dict[OBS_TIME] - assert time_obsvd == "0 days, 0 hours, 4 minutes, 34 seconds" - time_in_queue = obsv_dict[QUEUE_TIME] - parts = time_in_queue.split(", ") - days_part = parts[0].split(" ") - assert int(days_part[0]) > 1124 - - -@pytest.mark.skip("... Dates are broken...") -def test_handles_evla_exec_block(): - """ - Confirm we get what we expect when observing time is minimal. - :return: - """ - spl = "uid://evla/execblock/91c685b6-4527-44b1-9f91-3904e1125817" - args = argparse.Namespace(spl=spl) - expected = { - PROJECT: "19A-440", - OBS_TIME: "0 days, 0 hours, 0 minutes, 4 seconds", - QUEUE_TIME: "627 days, 22 hours, 43 minutes, 6 seconds", - } - - with patch("json.dumps", MagicMock(return_value=expected)): - wrester = mock_wrester(args) - actual = wrester.wrest_observation_info() - assert actual[PROJECT] == expected[PROJECT] - obs_parts = actual[OBS_TIME].split(", ") - seconds_part = obs_parts[3].split(" ") - assert int(seconds_part[0]) == 4 - - -@pytest.mark.skip("... VLBA isn't calibratable...") -def test_handles_vlba_observation(): - """ - Confirm we get what we expect when observing time is at high end. - - :return: - """ - spl = "uid://evla/execblock/9fbb86eb-ba14-42e7-8fd7-5c45aff36725" - expected = { - PROJECT: "BM468", - OBS_TIME: "0 days, 11 hours, 59 minutes, 57 seconds", - QUEUE_TIME: "933 days, 11 hours, 48 minutes, 12 seconds", - } - with patch("json.dumps", MagicMock(return_value=expected)): - wrester = mock_wrester(argparse.Namespace(spl=spl)) - actual = wrester.wrest_observation_info() - assert actual[PROJECT] == expected[PROJECT] - obs_parts = actual[OBS_TIME].split(", ") - hours_part = obs_parts[1].split(" ") - assert int(hours_part[0]) == 11 - - -@pytest.mark.skip("... ALMA isn't calibratable...") -def test_handles_alma(): - """ - Can we report a pending ALMA observation? - - :return: - """ - spl = "uid://alma/execblock/a4154db4-a834-4020-896a-6fd4613bf986" - expected = { - PROJECT: "2019.1.01635.S", - OBS_TIME: "0 days, 1 hours, 57 minutes, 4 seconds", - QUEUE_TIME: "517 days, 2 hours, 5 minutes, 15 seconds", - } - - with patch("json.dumps", MagicMock(return_value=expected)): - wrester = mock_wrester(argparse.Namespace(spl=spl)) - actual = wrester.wrest_observation_info() - assert actual[PROJECT] == expected[PROJECT] - time_parts = actual[QUEUE_TIME].split(", ") - days_part = time_parts[0].split(" ") - assert int(days_part[0]) >= 517 diff --git a/shared/workspaces/test/test_archive_service.py b/shared/workspaces/test/test_archive_service.py index 277c95610bab8e2f38c4e41a13d4ad45e2b4b61a..e46c1d50237069e2ee45bcc1948f705891214c3b 100644 --- a/shared/workspaces/test/test_archive_service.py +++ b/shared/workspaces/test/test_archive_service.py @@ -1,13 +1,14 @@ from typing import Dict from unittest.mock import patch +import json import pytest from workspaces.products.services.archive_service import ArchiveService @pytest.fixture(scope="module") -def fake_metadata() -> Dict[str, str]: +def fake_metadata() -> json: return { "spl": "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba", "bands": "Ka", @@ -46,7 +47,7 @@ class TestArchiveService: expected_spl = "uid://evla/execblock/8fbfb54b-d141-42fe-b079-609339a69cba" with patch( - "workspaces.products.services.archive_service.WrestWorkflowMetadata.wrest_obs_metadata_from_fileset_id", + "workspaces.products.services.archive_service.WrestObservationMetadata.wrest_observation_info", ) as mock_wrest_obs_metadata: mock_wrest_obs_metadata.return_value = fake_metadata with patch("workspaces.products.services.archive_service.Router"): diff --git a/shared/workspaces/workspaces/products/services/archive_service.py b/shared/workspaces/workspaces/products/services/archive_service.py index ad383bca3d0bdf54ba44cacfc4b3fad6f094c8e4..ef9194d773dc624c373e437bdd0a7a3c916f532c 100644 --- a/shared/workspaces/workspaces/products/services/archive_service.py +++ b/shared/workspaces/workspaces/products/services/archive_service.py @@ -2,7 +2,8 @@ import logging from typing import Dict import requests -from aat_wrest.metadata_wrester import WrestWorkflowMetadata +from aat_wrest.observation_wrester import WrestObservationMetadata + from aat_wrest.utilities import MDDBConnector from messaging.router import Router, on_message from pycapo import CapoConfig @@ -36,12 +37,12 @@ class ArchiveService(ArchiveServiceIF): logger.info(f"ingestion-complete event: {logdata}") execblock_id = logdata["execblock_id"] - fileset_id = logdata["fileset_id"] + sdm_id = logdata["fileset_id"] project_code = logdata["project_code"] - wrester = WrestWorkflowMetadata(MDDBConnector(), spl=None, fileset_id=fileset_id) - metadata = wrester.wrest_obs_metadata_from_fileset_id(fileset_id) - metadata["fileset_id"] = fileset_id + wrester = WrestObservationMetadata(MDDBConnector(), sdm_id=sdm_id) + metadata = wrester.wrest_observation_info() + metadata["sdm_id"] = sdm_id spl = metadata["spl"] del metadata["spl"] @@ -53,7 +54,7 @@ class ArchiveService(ArchiveServiceIF): type(response), response.content, ) - return spl, execblock_id, fileset_id, project_code + return spl, execblock_id, sdm_id, project_code @staticmethod def _create_std_calibration_request(spl: str, metadata: Dict[str, str]) -> Response: @@ -62,7 +63,7 @@ class ArchiveService(ArchiveServiceIF): :param spl: Science product locator of observation :param metadata: Dict with the following information inside: - - fileset_id: File Set ID + - sdm_id: SDM ID (sometimes called fileset id) - bands: Radio bands for observation - array_config: Configuration of array telescopes - obs_start_time: Start time of observation