From 24dec6c56a8545603a2511a30b7a9b18ad23b1f3 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 4 Dec 2024 10:30:12 -0700 Subject: [PATCH 1/5] In maintel/mtcs.py, remove settling time after clearing slew flag (currently refered to as close booster valve in the code). --- python/lsst/ts/observatory/control/maintel/mtcs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/lsst/ts/observatory/control/maintel/mtcs.py b/python/lsst/ts/observatory/control/maintel/mtcs.py index 5ddb34ed..5c80b84d 100644 --- a/python/lsst/ts/observatory/control/maintel/mtcs.py +++ b/python/lsst/ts/observatory/control/maintel/mtcs.py @@ -2628,7 +2628,6 @@ async def close_m1m3_booster_valve(self) -> None: """Close M1M3 booster valves.""" if self.check.mtm1m3: await self._handle_m1m3_booster_valve(open=False) - await asyncio.sleep(self.fast_timeout) async def _handle_m1m3_booster_valve(self, open: bool) -> None: """Handle opening the M1M3 booster valves""" From c99f6c73d4c9708022ee654a3a74a88cd326bc6c Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Thu, 12 Dec 2024 14:45:07 -0700 Subject: [PATCH 2/5] In maintel/mtcs.py, add a context manager to ensure m1m3 is in engineering mode before/after some operation. --- .../lsst/ts/observatory/control/maintel/mtcs.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/python/lsst/ts/observatory/control/maintel/mtcs.py b/python/lsst/ts/observatory/control/maintel/mtcs.py index 5c80b84d..c8e35bc6 100644 --- a/python/lsst/ts/observatory/control/maintel/mtcs.py +++ b/python/lsst/ts/observatory/control/maintel/mtcs.py @@ -1707,6 +1707,22 @@ async def exit_m1m3_engineering_mode(self) -> None: else: self.log.warning("M1M3 not in engineering mode.") + @contextlib.asynccontextmanager + async def m1m3_in_engineering_mode(self) -> typing.AsyncIterator[None]: + """Context manager to ensure m1m3 enters and exists engineering + mode before/after an operation. + + If M1M3 is in engineering mode before, this context manager is a + nop, e.g. it will leave M1M3 in engineering mode afterwards. + """ + try: + m1m3_in_engineering_mode_before = await self.is_m1m3_in_engineering_mode() + await self.enter_m1m3_engineering_mode() + yield + finally: + if not m1m3_in_engineering_mode_before: + await self.exit_m1m3_engineering_mode() + async def run_m1m3_hard_point_test(self, hp: int) -> None: """Test an M1M3 hard point. From 66e9211e119e8a50883c4ac6d876449b64da38cf Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 13 Dec 2024 11:26:39 -0700 Subject: [PATCH 3/5] Add unit tests for the new MTCS.m1m3_in_engineering_mode context manager. --- tests/maintel/test_mtcs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/maintel/test_mtcs.py b/tests/maintel/test_mtcs.py index 9534c59f..cb470afa 100644 --- a/tests/maintel/test_mtcs.py +++ b/tests/maintel/test_mtcs.py @@ -2455,3 +2455,22 @@ async def assert_m1m3_slew_settings_applied( assert ( actual_settings[setting] == expected_value ), f"Setting {setting} expected to be {expected_value} but was {actual_settings[setting]}" + + async def test_m1m3_in_engineering_mode(self) -> None: + + async with self.mtcs.m1m3_in_engineering_mode(): + await asyncio.sleep(0) + + self.mtcs.rem.mtm1m3.cmd_enterEngineering.start.assert_awaited_once() + self.mtcs.rem.mtm1m3.cmd_exitEngineering.start.assert_awaited_once() + + async def test_m1m3_in_engineering_mode_with_failed_op(self) -> None: + + try: + async with self.mtcs.m1m3_in_engineering_mode(): + raise RuntimeError("This is a test.") + except RuntimeError: + pass + + self.mtcs.rem.mtm1m3.cmd_enterEngineering.start.assert_awaited_once() + self.mtcs.rem.mtm1m3.cmd_exitEngineering.start.assert_awaited_once() From 964ed3e372b3d9f83c9accc2be4fdba6743a2431 Mon Sep 17 00:00:00 2001 From: edennihy Date: Fri, 13 Dec 2024 11:42:06 -0700 Subject: [PATCH 4/5] Add news fragments. --- doc/news/DM-47890.feature.2.rst | 1 + doc/news/DM-47890.feature.3.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 doc/news/DM-47890.feature.2.rst create mode 100644 doc/news/DM-47890.feature.3.rst diff --git a/doc/news/DM-47890.feature.2.rst b/doc/news/DM-47890.feature.2.rst new file mode 100644 index 00000000..097b2e3f --- /dev/null +++ b/doc/news/DM-47890.feature.2.rst @@ -0,0 +1 @@ +In maintel/mtcs.py, remove settling time after clearing slew flag (currently refered to as close booster valve in the code). diff --git a/doc/news/DM-47890.feature.3.rst b/doc/news/DM-47890.feature.3.rst new file mode 100644 index 00000000..510dde6a --- /dev/null +++ b/doc/news/DM-47890.feature.3.rst @@ -0,0 +1 @@ +In maintel/mtcs.py, add a context manager to ensure m1m3 is in engineering mode before/after some operation and add unit tests. From c439a523a53dbe38824f3ff8c57e43643689ce89 Mon Sep 17 00:00:00 2001 From: edennihy Date: Wed, 18 Dec 2024 13:42:41 -0700 Subject: [PATCH 5/5] Update github lint workflow to include identify>=2.6. --- .github/workflows/lint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9a1f3247..aee2f966 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,8 +18,8 @@ jobs: - name: Install run: | $CONDA/bin/conda config --set solver classic - $CONDA/bin/conda install -c lsstts -c conda-forge pre-commit ts-pre-commit-config python=3.11 -y - $CONDA/bin/conda install -c conda-forge pre-commit -y + $CONDA/bin/conda install -c lsstts -c conda-forge pre-commit ts-pre-commit-config python=3.11 identify>=2.6 -y + $CONDA/bin/conda install -c conda-forge pre-commit identify>=2.6 -y $CONDA/bin/generate_pre_commit_conf --skip-pre-commit-install - name: Run pre commit checks