From 15b9bbe4de08e453c0a1132ede9e1658d3b0663c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carolina=20Villal=C3=B3n?= Date: Mon, 25 Nov 2024 12:37:01 -0300 Subject: [PATCH 1/2] Add ignore feature for open/close mirror covers --- .../maintel/close_mirror_covers.py | 39 ++++++++++++++++++- .../maintel/open_mirror_covers.py | 39 ++++++++++++++++++- tests/test_maintel_close_mirror_covers.py | 15 +++++++ tests/test_maintel_open_mirror_covers.py | 15 +++++++ 4 files changed, 104 insertions(+), 4 deletions(-) diff --git a/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py b/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py index 9a57da2c1..fbc471dac 100644 --- a/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py +++ b/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py @@ -21,6 +21,7 @@ __all__ = ["CloseMirrorCovers"] +import yaml from lsst.ts import salobj from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages @@ -47,16 +48,50 @@ def __init__(self, index): @classmethod def get_schema(cls): - # This script does not require any configuration - return None + schema_yaml = """ + $schema: http://json-schema.org/draft-07/schema# + $id: https://github.com/lsst-ts/ts_standardscripts/maintel/close_mirror_covers.yaml + title: CloseMirrorCovers v1 + description: Configuration for CloseMirrorCovers. + type: object + properties: + ignore: + description: >- + CSCs from the group to ignore in status check. Name must + match those in self.group.components, e.g.; hexapod_1. + type: array + items: + type: string + additionalProperties: false + """ + return yaml.safe_load(schema_yaml) async def configure(self, config): + """Configure script. + + Parameters + ---------- + config : `types.SimpleNamespace` + Script configuration, as defined by `schema`. + """ + self.config = config if self.mtcs is None: self.mtcs = MTCS( domain=self.domain, intended_usage=MTCSUsages.All, log=self.log ) await self.mtcs.start_task + if hasattr(self.config, "ignore"): + for comp in self.config.ignore: + if comp not in self.mtcs.components_attr: + self.log.warning( + f"Component {comp} not in CSC Group. " + f"Must be one of {self.mtcs.components_attr}. Ignoring." + ) + else: + self.log.debug(f"Ignoring component {comp}.") + setattr(self.mtcs.check, comp, False) + def set_metadata(self, metadata): metadata.duration = self.mtcs.mirror_covers_timeout diff --git a/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py b/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py index e555437fa..c863d2229 100644 --- a/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py +++ b/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py @@ -21,6 +21,7 @@ __all__ = ["OpenMirrorCovers"] +import yaml from lsst.ts import salobj from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages @@ -47,16 +48,50 @@ def __init__(self, index): @classmethod def get_schema(cls): - # This script does not require any configuration - return None + schema_yaml = """ + $schema: http://json-schema.org/draft-07/schema# + $id: https://github.com/lsst-ts/ts_standardscripts/maintel/open_mirror_covers.yaml + title: OpenMirrorCovers v1 + description: Configuration for OpenMirrorCovers. + type: object + properties: + ignore: + description: >- + CSCs from the group to ignore in status check. Name must + match those in self.group.components, e.g.; hexapod_1. + type: array + items: + type: string + additionalProperties: false + """ + return yaml.safe_load(schema_yaml) async def configure(self, config): + """Configure script. + + Parameters + ---------- + config : `types.SimpleNamespace` + Script configuration, as defined by `schema`. + """ + self.config = config if self.mtcs is None: self.mtcs = MTCS( domain=self.domain, intended_usage=MTCSUsages.All, log=self.log ) await self.mtcs.start_task + if hasattr(self.config, "ignore"): + for comp in self.config.ignore: + if comp not in self.mtcs.components_attr: + self.log.warning( + f"Component {comp} not in CSC Group. " + f"Must be one of {self.mtcs.components_attr}. Ignoring." + ) + else: + self.log.debug(f"Ignoring component {comp}.") + setattr(self.mtcs.check, comp, False) + def set_metadata(self, metadata): metadata.duration = self.mtcs.mirror_covers_timeout diff --git a/tests/test_maintel_close_mirror_covers.py b/tests/test_maintel_close_mirror_covers.py index fcff88bd5..cdc155977 100644 --- a/tests/test_maintel_close_mirror_covers.py +++ b/tests/test_maintel_close_mirror_covers.py @@ -55,6 +55,21 @@ async def test_executable(self): script_path = scripts_dir / "maintel" / "close_mirror_covers.py" await self.check_executable(script_path) + async def test_configure_ignore(self): + async with self.make_script(): + components = ["mtptg"] + await self.configure_script(ignore=components) + + assert self.script.mtcs.check.mtptg is False + + async def test_configure_ignore_not_csc_component(self): + async with self.make_script(): + components = ["not_csc_comp", "mtptg"] + await self.configure_script(ignore=components) + + assert hasattr(self.script.mtcs, "not_csc_comp") is False + assert self.script.mtcs.check.mtptg is False + if __name__ == "__main__": unittest.main() diff --git a/tests/test_maintel_open_mirror_covers.py b/tests/test_maintel_open_mirror_covers.py index a5428568c..95c40d420 100644 --- a/tests/test_maintel_open_mirror_covers.py +++ b/tests/test_maintel_open_mirror_covers.py @@ -55,6 +55,21 @@ async def test_executable(self): script_path = scripts_dir / "maintel" / "open_mirror_covers.py" await self.check_executable(script_path) + async def test_configure_ignore(self): + async with self.make_script(): + components = ["mtptg"] + await self.configure_script(ignore=components) + + assert self.script.mtcs.check.mtptg is False + + async def test_configure_ignore_not_csc_component(self): + async with self.make_script(): + components = ["not_csc_comp", "mtptg"] + await self.configure_script(ignore=components) + + assert hasattr(self.script.mtcs, "not_csc_comp") is False + assert self.script.mtcs.check.mtptg is False + if __name__ == "__main__": unittest.main() From 63ac5a7c439124d25a31e7b17ba3f7456dd17426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carolina=20Villal=C3=B3n?= Date: Mon, 25 Nov 2024 12:47:39 -0300 Subject: [PATCH 2/2] Add news fragment --- doc/news/DM-47552.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/news/DM-47552.feature.rst diff --git a/doc/news/DM-47552.feature.rst b/doc/news/DM-47552.feature.rst new file mode 100644 index 000000000..5a9b65bde --- /dev/null +++ b/doc/news/DM-47552.feature.rst @@ -0,0 +1 @@ +Add support for ignoring ``MTCS`` components in open and close mirror covers operation.