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. diff --git a/python/lsst/ts/IntegrationTests/base_script.py b/python/lsst/ts/IntegrationTests/base_script.py index 04dcc0c5..3de1c384 100644 --- a/python/lsst/ts/IntegrationTests/base_script.py +++ b/python/lsst/ts/IntegrationTests/base_script.py @@ -29,6 +29,7 @@ from lsst.ts import salobj from lsst.ts.idl.enums.Script import ScriptState from lsst.ts.idl.enums.ScriptQueue import Location, ScriptProcessState +from lsst.ts.IntegrationTests import utils class BaseScript: @@ -60,16 +61,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 +70,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 +137,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 +145,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/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] diff --git a/python/lsst/ts/IntegrationTests/csc_state_transition.py b/python/lsst/ts/IntegrationTests/csc_state_transition.py index 081e7061..74ec7d77 100644 --- a/python/lsst/ts/IntegrationTests/csc_state_transition.py +++ b/python/lsst/ts/IntegrationTests/csc_state_transition.py @@ -26,7 +26,7 @@ import asyncio import yaml -from lsst.ts.IntegrationTests import BaseScript +from lsst.ts.IntegrationTests import BaseScript, utils class CSCStateTransition(BaseScript): @@ -38,6 +38,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 +55,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 +70,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 +94,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 +117,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 +150,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." 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__() 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( 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(