Skip to content

Commit

Permalink
Merge pull request #73 from lsst-ts/tickets/DM-33401
Browse files Browse the repository at this point in the history
DM-33401: In MTAOS remove backward compatibility with xml <19
  • Loading branch information
tribeiro authored Sep 5, 2023
2 parents d675274 + 72bfc84 commit 98f0d86
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ pytest_session.txt
.flake8
.isort.cfg
.mypy.ini
.clang-format
.ruff.toml
7 changes: 5 additions & 2 deletions .ts_pre_commit_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
check-yaml: true
check-xml: true
black: true
check-xml: true
check-yaml: true
clang-format: true
flake8: true
format-xmllint: true
isort: true
mypy: false
ruff: true
6 changes: 6 additions & 0 deletions doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Version History
===============

v0.13.0
-------

* Remove compatibility with xml<19.
* Update to ts-pre-commit-config 0.6.

v0.12.2
-------

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/mtaos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, config):
Source of the configuration. Either object received in configure
CSC call, or string for a filename.
"""
if type(config) == str:
if isinstance(config, str):
data = yaml.safe_load(open(config).read())
self.configObj = namedtuple("configObj", data.keys())(*data.values())
else:
Expand Down
19 changes: 4 additions & 15 deletions python/lsst/ts/mtaos/mtaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ def __init__(

cscName = utility.getCscName()

compatibility_commands = dict(
offsetDOF=self._do_offset_dof,
resetOffsetDOF=self._do_reset_offset_dof,
)

if utility.support_offset_dof_cmd():
for command_name, command_method in compatibility_commands.items():
setattr(self, f"do_{command_name}", command_method)

super().__init__(
cscName,
index=0,
Expand Down Expand Up @@ -631,7 +622,7 @@ async def do_interruptWEP(self, data: salobj.type_hints.BaseDdsDataType) -> None

await self.model.interrupt_wep_process()

async def _do_offset_dof(self, data: salobj.type_hints.BaseDdsDataType) -> None:
async def do_offsetDOF(self, data: salobj.type_hints.BaseDdsDataType) -> None:
"""Implement command offsetDOF.
Parameters
Expand All @@ -648,9 +639,7 @@ async def _do_offset_dof(self, data: salobj.type_hints.BaseDdsDataType) -> None:

raise NotImplementedError("Command offsetDOF not implemented.")

async def _do_reset_offset_dof(
self, data: salobj.type_hints.BaseDdsDataType
) -> None:
async def do_resetOffsetDOF(self, data: salobj.type_hints.BaseDdsDataType) -> None:
"""Implement command reset offset dof.
Parameters
Expand All @@ -671,7 +660,7 @@ async def handle_corrections(self):
"""Handle applying the corrections to all components.
If one or more correction fail to apply to method will try to undo the
successfull corrections. If any of those fails to undo, it will
successful corrections. If any of those fails to undo, it will
continue and generate a report at the end.
Raises
Expand Down Expand Up @@ -713,7 +702,7 @@ async def handle_undo_corrections(self, issued_corrections):
"""Handle undoing corrections.
The method will inspect the `issued_corrections` list of tasks, will
undo all the successful corrections and log the unsuccesful. If any
undo all the successful corrections and log the unsuccessful. If any
successful correction fail to be undone, it will log the issue and skip
the error.
Expand Down
43 changes: 0 additions & 43 deletions python/lsst/ts/mtaos/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"getCscName",
"addRotFileHandler",
"timeit",
"support_interrupt_wep_cmd",
"get_formatted_corner_wavefront_sensors_ids",
"define_visit",
]
Expand All @@ -49,8 +48,6 @@
from lsst.daf.butler import Butler
from lsst.obs.base import DefineVisitsTask, Instrument
from lsst.obs.lsst.translators.lsstCam import LsstCamTranslator
from lsst.ts.idl import get_idl_dir
from lsst.ts.salobj import parse_idl
from lsst.ts.wep.utility import CamType
from lsst.utils import getPackageDir

Expand Down Expand Up @@ -297,46 +294,6 @@ def timed(*args, **kwargs):
return timed


# TODO: Remove when xml 11 is available (DM-33401).
def support_interrupt_wep_cmd() -> bool:
"""Check if interruptWEP command is defined in MTAOS idl file.
This is a workaround to provide backward compatibility with xml 10.2
and will be removed in the future (DM-33401).
Returns
-------
`bool`
True if CSC interfaces defines the command "interruptWEP", False
otherwise.
"""
csc_name = getCscName()

idl_metadata = parse_idl(csc_name, get_idl_dir() / f"sal_revCoded_{csc_name}.idl")

return "command_interruptWEP" in idl_metadata.topic_info


# TODO: Remove when xml 19 is available (DM-33401).
def support_offset_dof_cmd() -> bool:
"""Check if offsetDOF command is defined in MTAOS idl file.
This is a workaround to provide backward compatibility with xml 19
and will be removed in the future.
Returns
-------
`bool`
True if CSC interfaces defines the command "offsetDOF", False
otherwise.
"""
csc_name = getCscName()

idl_metadata = parse_idl(csc_name, get_idl_dir() / f"sal_revCoded_{csc_name}.idl")

return "command_offsetDOF" in idl_metadata.topic_info


def get_formatted_corner_wavefront_sensors_ids() -> str:
"""Return a list of ids for the corner wavefront sensors for LSSTCam.
Expand Down
5 changes: 0 additions & 5 deletions tests/test_mtaosCsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,6 @@ async def test_run_wep_lsst_cwfs(self):
timeout=SHORT_TIMEOUT,
)

# TODO: Remove skipIf when xml 11 is available (DM-33401).
@unittest.skipIf(
not mtaos.utility.support_interrupt_wep_cmd(),
"interruptWEP command not defined. See DM-33401.",
)
@pytest.mark.csc_integtest
async def test_interruptWEP(self):
async with self.make_csc(
Expand Down

0 comments on commit 98f0d86

Please sign in to comment.