From 393900eab1463086e36d3aea4d0e40a9c5b55a66 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Mon, 26 Feb 2024 13:55:18 -0700 Subject: [PATCH 1/6] Removed the MTM1M3 items from configs/maintel_state_transition_configs.py. --- .../configs/maintel_state_transition_configs.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/configs/maintel_state_transition_configs.py b/python/lsst/ts/IntegrationTests/configs/maintel_state_transition_configs.py index 58560f4d..30207dbd 100644 --- a/python/lsst/ts/IntegrationTests/configs/maintel_state_transition_configs.py +++ b/python/lsst/ts/IntegrationTests/configs/maintel_state_transition_configs.py @@ -38,7 +38,6 @@ - [MTHexapod:2, DISABLED] - [MTDome, DISABLED] - [MTDomeTrajectory, DISABLED] - - [MTM1M3, DISABLED, Default] - [MTM2, DISABLED] - [MTPtg, DISABLED] - [MTAOS, DISABLED] @@ -75,7 +74,6 @@ - [MTHexapod:2, ENABLED] - [MTDome, ENABLED] - [MTDomeTrajectory, ENABLED] - - [MTM1M3, ENABLED] - [MTM2, ENABLED] - [MTPtg, ENABLED] - [MTAOS, ENABLED] From 7f93ce4e72d4fdfe1fb49dc234a825d171ad80bd Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Mon, 26 Feb 2024 15:01:56 -0700 Subject: [PATCH 2/6] Added the csc_index argument to csc_state_transition.py in order to correctly handle indexed-CSCs. Updated the import location of the cscs and csc_states lists. Formatting and correct type annotations in csc_state_transition.py. --- .../IntegrationTests/csc_state_transition.py | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/csc_state_transition.py b/python/lsst/ts/IntegrationTests/csc_state_transition.py index 081e7061..96d4402d 100644 --- a/python/lsst/ts/IntegrationTests/csc_state_transition.py +++ b/python/lsst/ts/IntegrationTests/csc_state_transition.py @@ -28,6 +28,8 @@ import yaml from lsst.ts.IntegrationTests import BaseScript +import utils.py + class CSCStateTransition(BaseScript): """Execute the set_summary_state script for the given CSC, @@ -38,6 +40,8 @@ class CSCStateTransition(BaseScript): ---------- csc : `str` The name of the CSC to transition. Case-sensitive. + csc_index : `int` + The index value for the indexed-CSC. state : `str` The state to transition. additional_configuration : `str` @@ -53,10 +57,12 @@ def __init__( self, csc: str, state: str, - additional_configuration: str = None, + csc_index: int = 0, + additional_configuration: str = "", ) -> None: super().__init__() self.csc = csc + self.csc_index = csc_index self.state = state self.added_config = additional_configuration # Set the ScriptQueue index based on which telescope. @@ -66,7 +72,11 @@ def __init__( self.index = 1 # Construct the intermediate configuration list. # Convert the list to a string. - temp_config = [self.csc, self.state] + if self.csc_index: + full_csc_name = f"{self.csc}:{self.csc_index}" + else: + full_csc_name = self.csc + temp_config = [full_csc_name, self.state] if self.added_config: temp_config.append(self.added_config) config = ", ".join(str(i) for i in temp_config) @@ -86,9 +96,9 @@ def __init__( def csc_state_transition() -> None: # Define the lists of CSC and State options. - csc_list = list(BaseScript.cscs) + csc_list = list(utils.cscs) csc_list.sort() - state_list = list(BaseScript.csc_states) + state_list = list(utils.csc_states) state_list.sort() # Define the script arguments. parser = argparse.ArgumentParser() @@ -109,7 +119,16 @@ def csc_state_transition() -> None: help="Specify to which state to transition.", ) parser.add_argument( - "additional_configuration", + "-x", + "--csc_index", + metavar="index", + nargs="?", + type=int, + help="Define the index of the CSC, if applicable.", + ) + parser.add_argument( + "-a", + "--additional_configuration", nargs="?", type=str, help="Specify any additional configurations.", @@ -133,7 +152,7 @@ def csc_state_transition() -> None: f" state:\t{state_list}\n" ) exit() - if args.csc not in BaseScript.cscs: + if args.csc not in utils.cscs: print( f"Invalid CSC: {args.csc}. " f"Perhaps it is misspelled or not properly capitalized." From 032d24bbdb36808e26c749dc134264413b9f2946 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Mon, 26 Feb 2024 14:52:52 -0700 Subject: [PATCH 3/6] Moved the various lists in base_script.py to utils.py, to reduce clutter. Corrected the type annotation for the get_test_env_arg function return in utils.py. --- .../lsst/ts/IntegrationTests/base_script.py | 114 +----------------- python/lsst/ts/IntegrationTests/utils.py | 105 +++++++++++++++- 2 files changed, 108 insertions(+), 111 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/base_script.py b/python/lsst/ts/IntegrationTests/base_script.py index 04dcc0c5..8f51474c 100644 --- a/python/lsst/ts/IntegrationTests/base_script.py +++ b/python/lsst/ts/IntegrationTests/base_script.py @@ -30,6 +30,8 @@ from lsst.ts.idl.enums.Script import ScriptState from lsst.ts.idl.enums.ScriptQueue import Location, ScriptProcessState +import utils.py + class BaseScript: """Defines the common attributes and functions for an @@ -60,16 +62,6 @@ class BaseScript: A list of tuples. The tuple is the script name and a boolean. The boolean specifies the script as Standard (True) or External (False). - cscs : `frozenset` - An immutable set of CSCs. This is used to validate CSC state - transition commands. - csc_states : `frozenset` - An immutable set of CSC states. This is used to validate CSC state - transition commands. - processing_states : `frozenset` - An immutable set of the ScriptQueue processing states. - terminal_states : `frozenset` - An immutable set of the ScriptQueue terminal states. """ # See Attributes for the definition. @@ -79,104 +71,6 @@ class BaseScript: configs: tuple = () scripts: list = [] - # Define the list of CSCs. - # This is needed to validate the csc_state_transition configuration. - cscs = frozenset( - [ - "ATAOS", - "MTAirCompressor", - "ATBuilding", - "ATCamera", - "ATDome", - "ATDomeTrajectory", - "ATHeaderService", - "ATHexapod", - "ATMCS", - "ATMonochromator", - "ATOODS", - "ATPneumatics", - "ATPtg", - "ATSpectrograph", - "ATWhiteLight", - "Authorize", - "GCHeaderService", - "CCCamera", - "CCHeaderService", - "CCOODS", - "CBP", - "DIMM", - "DREAM", - "DSM", - "EAS", - "Electrometer", - "ESS", - "FiberSpectrograph", - "GenericCamera", - "GIS", - "Guider", - "HVAC", - "LaserTracker", - "LEDProjector", - "LinearStage", - "LOVE", - "MTAOS", - "MTCamera", - "MTDome", - "MTDomeTrajectory", - "MTEEC", - "MTHeaderService", - "MTHexapod", - "MTM1M3", - "MTM1M3TS", - "MTM2", - "MTMount", - "MTOODS", - "MTPtg", - "MTRotator", - "MTVMS", - "OCPS:2", - "OCPS:3", - "PMD", - "Scheduler", - "Script", - "ScriptQueue", - "SummitFacility", - "Test", - "TunableLaser", - "Watcher", - "WeatherForecast", - ] - ) - - # Define the list of CSC States. - csc_states = frozenset( - [ - "Offline", - "Standby", - "Disabled", - "Enabled", - ] - ) - # Define the set of script states that indicate the script is processing. - processing_states = frozenset( - ( - ScriptProcessState.UNKNOWN, - ScriptProcessState.LOADING, - ScriptProcessState.CONFIGURED, - ScriptProcessState.RUNNING, - ) - ) - - # Define the set of script states that indicate the script is complete. - terminal_states = frozenset( - ( - ScriptProcessState.DONE, - ScriptProcessState.LOADFAILED, - ScriptProcessState.CONFIGURE_FAILED, - ScriptProcessState.TERMINATED, - ) - ) - def __init__(self, queue_placement: str = "LAST") -> None: """Initialize the given Standard or External script, with the given Yaml configuration, placed in the @@ -244,7 +138,7 @@ async def wait_for_done(self, data: salobj.BaseMsgType) -> None: data : ``lsst.ts.salobj.BaseMsgType`` The object returned by the ScriptQueue Script Event (evt_script). """ - if data.processState in self.processing_states: + if data.processState in utils.processing_states: # Script initial, configuration and running states. print( f"Script processing state: " @@ -252,7 +146,7 @@ async def wait_for_done(self, data: salobj.BaseMsgType) -> None: ) return print(f"Waiting for script ID {self.temp_script_indexes[0]} to finish...") - if data.processState in self.terminal_states and data.timestampProcessEnd > 0: + if data.processState in utils.terminal_states and data.timestampProcessEnd > 0: print( f"Script {data.scriptSalIndex} terminal processing state: " f"{ScriptProcessState(data.processState).name}\n" diff --git a/python/lsst/ts/IntegrationTests/utils.py b/python/lsst/ts/IntegrationTests/utils.py index 35bbff4a..a64f359e 100644 --- a/python/lsst/ts/IntegrationTests/utils.py +++ b/python/lsst/ts/IntegrationTests/utils.py @@ -22,8 +22,111 @@ import argparse +from lsst.ts.idl.enums.ScriptQueue import ScriptProcessState -def get_test_env_arg() -> None: +# Define the various lists used by the modules in this package. + +# Define the list of CSCs. +# This is needed to validate the csc_state_transition configuration. +cscs = frozenset( + [ + "ATAOS", + "MTAirCompressor", + "ATBuilding", + "ATCamera", + "ATDome", + "ATDomeTrajectory", + "ATHeaderService", + "ATHexapod", + "ATMCS", + "ATMonochromator", + "ATOODS", + "ATPneumatics", + "ATPtg", + "ATSpectrograph", + "ATWhiteLight", + "Authorize", + "GCHeaderService", + "CCCamera", + "CCHeaderService", + "CCOODS", + "CBP", + "DIMM", + "DREAM", + "DSM", + "EAS", + "Electrometer", + "ESS", + "FiberSpectrograph", + "GenericCamera", + "GIS", + "Guider", + "HVAC", + "LaserTracker", + "LEDProjector", + "LinearStage", + "LOVE", + "MTAOS", + "MTCamera", + "MTDome", + "MTDomeTrajectory", + "MTEEC", + "MTHeaderService", + "MTHexapod", + "MTM1M3", + "MTM1M3TS", + "MTM2", + "MTMount", + "MTOODS", + "MTPtg", + "MTRotator", + "MTVMS", + "OCPS:2", + "OCPS:3", + "PMD", + "Scheduler", + "Script", + "ScriptQueue", + "SummitFacility", + "Test", + "TunableLaser", + "Watcher", + "WeatherForecast", + ] +) + +# Define the list of CSC States. +csc_states = frozenset( + [ + "Offline", + "Standby", + "Disabled", + "Enabled", + ] +) + +# Define the set of script states that indicate the script is processing. +processing_states = frozenset( + ( + ScriptProcessState.UNKNOWN, + ScriptProcessState.LOADING, + ScriptProcessState.CONFIGURED, + ScriptProcessState.RUNNING, + ) +) + +# Define the set of script states that indicate the script is complete. +terminal_states = frozenset( + ( + ScriptProcessState.DONE, + ScriptProcessState.LOADFAILED, + ScriptProcessState.CONFIGURE_FAILED, + ScriptProcessState.TERMINATED, + ) +) + + +def get_test_env_arg() -> argparse.Namespace: # Define the script arguments. parser = argparse.ArgumentParser() parser.add_argument( From 4cbc1369d14a2fe772e7ef247e74ba25f328f666 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Mon, 26 Feb 2024 17:13:21 -0700 Subject: [PATCH 4/6] Removed unnecessary argument from test_comcam_image_taking_verification.py. --- tests/test_comcam_image_taking_verification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_comcam_image_taking_verification.py b/tests/test_comcam_image_taking_verification.py index 94c54be8..6e2d6929 100644 --- a/tests/test_comcam_image_taking_verification.py +++ b/tests/test_comcam_image_taking_verification.py @@ -48,7 +48,7 @@ async def test_comcam_image_taking(self) -> None: Use the configuration stored in the image_taking_configs.py module. """ # Instantiate the ComCamImageTaking integration tests. - script_class = ComCamImageTaking(test_env="tts") + script_class = ComCamImageTaking() # Get number of scripts num_scripts = len(script_class.scripts) print( From 292e2a30423f0dd0fb7c4b86757f3a83866cf502 Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Mon, 26 Feb 2024 17:12:40 -0700 Subject: [PATCH 5/6] Corrected the formatting in image_taking_verification.py. Fixed isort formatting in base_script.py. Fixed isort formatting in csc_state_transition.py. --- python/lsst/ts/IntegrationTests/base_script.py | 3 +-- python/lsst/ts/IntegrationTests/csc_state_transition.py | 4 +--- python/lsst/ts/IntegrationTests/image_taking_verification.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/python/lsst/ts/IntegrationTests/base_script.py b/python/lsst/ts/IntegrationTests/base_script.py index 8f51474c..3de1c384 100644 --- a/python/lsst/ts/IntegrationTests/base_script.py +++ b/python/lsst/ts/IntegrationTests/base_script.py @@ -29,8 +29,7 @@ from lsst.ts import salobj from lsst.ts.idl.enums.Script import ScriptState from lsst.ts.idl.enums.ScriptQueue import Location, ScriptProcessState - -import utils.py +from lsst.ts.IntegrationTests import utils class BaseScript: diff --git a/python/lsst/ts/IntegrationTests/csc_state_transition.py b/python/lsst/ts/IntegrationTests/csc_state_transition.py index 96d4402d..74ec7d77 100644 --- a/python/lsst/ts/IntegrationTests/csc_state_transition.py +++ b/python/lsst/ts/IntegrationTests/csc_state_transition.py @@ -26,9 +26,7 @@ import asyncio import yaml -from lsst.ts.IntegrationTests import BaseScript - -import utils.py +from lsst.ts.IntegrationTests import BaseScript, utils class CSCStateTransition(BaseScript): diff --git a/python/lsst/ts/IntegrationTests/image_taking_verification.py b/python/lsst/ts/IntegrationTests/image_taking_verification.py index 0cbe59f3..139de187 100644 --- a/python/lsst/ts/IntegrationTests/image_taking_verification.py +++ b/python/lsst/ts/IntegrationTests/image_taking_verification.py @@ -64,7 +64,7 @@ class ComCamImageTaking(BaseScript): ("maintel/take_image_comcam.py", BaseScript.is_standard), ] - def __init__(self, test_env: str) -> None: + def __init__(self) -> None: super().__init__() From 574fc4c7206ddfe039f0aa67ba2865fc580a89cb Mon Sep 17 00:00:00 2001 From: Rob Bovill Date: Wed, 28 Feb 2024 14:02:41 -0700 Subject: [PATCH 6/6] Updated version-history. --- doc/version-history.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/version-history.rst b/doc/version-history.rst index 9674acaa..508b77b1 100644 --- a/doc/version-history.rst +++ b/doc/version-history.rst @@ -10,6 +10,13 @@ Version History .. No new work should be required in order to complete this section. .. Below is an example of a version history format. +v0.22.0 +------- +* Switched M1M3 to individual state transitions. +* Made the csc_state_transition.py script correctly handle indexed-CSCs. +* Moved the various lists in base_script.py to utils.py. +* Various formatting improvements. + v0.21.0 ------- * Added the 'and' into all instances of auxtel_telescope_and_dome_checkout.