-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the integration tests and unit tests for lsstcam_calibrations.
- Loading branch information
Showing
5 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# This file is part of ts_IntegrationTests. | ||
# | ||
# Developed for the Vera C. Rubin Observatory Telescope & Site Software system. | ||
# This product includes software developed by the Vera C. Rubin Observatory | ||
# Project (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
|
||
__all__ = ["LsstCamCalibrations", "run_lsstcam_calibrations"] | ||
|
||
import argparse | ||
import asyncio | ||
|
||
import yaml | ||
from lsst.ts.IntegrationTests import BaseScript | ||
|
||
from .configs.config_registry import registry | ||
|
||
|
||
class LsstCamCalibrations(BaseScript): | ||
"""Execute the given Standard or External script, | ||
with the given Yaml configuration, | ||
placed in the given ScriptQueue location. | ||
Parameters | ||
---------- | ||
calib_type : `str` | ||
Defines which set of calibrations to run. | ||
Choices are ["flat", "ptc"]. | ||
""" | ||
|
||
index: int = 1 | ||
configs: tuple = ([],) | ||
scripts: list = [ | ||
("maintel/make_lsstcam_calibrations.py", BaseScript.is_external), | ||
] | ||
|
||
def __init__(self, calib_type: str) -> None: | ||
super().__init__() | ||
self.calib_type = calib_type | ||
self.calib_configs = yaml.safe_load( | ||
registry[f"lsstcam_calibrations_{calib_type}"] | ||
) | ||
self.calib_configs["certify_calib_begin_date"] = super().get_current_date() | ||
self.calib_configs["calib_collection"] = self.calib_configs[ | ||
"calib_collection" | ||
].replace("replace_me", super().get_current_date("%Y%m%d")) | ||
self.calib_configs["calib_collection"] = self.calib_configs[ | ||
"calib_collection" | ||
].replace("calib_type", calib_type) | ||
self.configs = (yaml.safe_dump(self.calib_configs),) | ||
|
||
|
||
def run_lsstcam_calibrations() -> None: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"calib_type", | ||
type=str, | ||
choices=["flat", "ptc"], | ||
help="Specify which set of calibrations to run.", | ||
) | ||
args = parser.parse_args() | ||
script_class = LsstCamCalibrations(calib_type=args.calib_type) | ||
print( | ||
f"\nLSSTCam Calibrations; running the " | ||
f"master_{script_class.calib_type} calibrations" | ||
f"\nwith configuration;\n{script_class.configs}" | ||
) | ||
asyncio.run(script_class.run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# This file is part of ts_IntegrationTests. | ||
# | ||
# Developed for the Vera C. Rubin Observatory Telescope & Site Software system. | ||
# This product includes software developed by the Vera C. Rubin Observatory | ||
# Project (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import unittest | ||
from datetime import date | ||
|
||
from lsst.ts import salobj | ||
from lsst.ts.IntegrationTests import LSSTCamCalibrations, ScriptQueueController | ||
|
||
|
||
class LSSTCamCalibrationsTestCase(unittest.IsolatedAsyncioTestCase): | ||
""" | ||
Test the Make Latiss Configurations integration test scripts. | ||
""" | ||
|
||
async def asyncSetUp(self) -> None: | ||
# Set the LSST_DDS_PARTITION_PREFIX ENV_VAR. | ||
salobj.set_random_lsst_dds_partition_prefix() | ||
|
||
# Create the ScriptQueue Controller. | ||
self.controller = ScriptQueueController(index=1) | ||
|
||
# Start the controller and wait for it be ready. | ||
await self.controller.start_task | ||
|
||
async def test_lsstcam_calibrations_flat(self) -> None: | ||
"""Execute the LSSTCamCalibrations integration test script, | ||
which runs the ts_standardscripts/maintel/make_lsstcam_calibratons.py | ||
script. | ||
Use the configuration stored in the image_taking_configs.py module. | ||
""" | ||
# Instantiate the LSSTCamCalibrations integration tests. | ||
calib_type = "flat" | ||
script_class = LSSTCamCalibrations(calib_type=calib_type) | ||
# Assert configurations were updated with current date. | ||
self.assertEqual( | ||
script_class.calib_configs["certify_calib_begin_date"], | ||
date.today().strftime("%Y-%m-%d"), | ||
) | ||
self.assertEqual( | ||
script_class.calib_configs["calib_collection"], | ||
f"LSSTCam/calib/u/integrationtester/daily." | ||
f"{date.today().strftime('%Y%m%d')}.{calib_type}", | ||
) | ||
# Get number of scripts | ||
num_scripts = len(script_class.scripts) | ||
print( | ||
f"AuxTel Make Latiss Configurations. " | ||
f"Running the {script_class.scripts[0][0]} script " | ||
f"for the master_{calib_type} calibrations," | ||
f"\nwith configuration;\n{script_class.configs}" | ||
) | ||
# Execute the scripts. | ||
await script_class.run() | ||
# Assert script was added to ScriptQueue. | ||
self.assertEqual(len(self.controller.queue_list), num_scripts) | ||
# Assert scripts passed. | ||
self.assertEqual(script_class.script_states, [8]) |