From dab7fd406b8e3669921d2d7bc2eeb24cc316f13d Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 14 Feb 2024 15:39:09 -0700 Subject: [PATCH 01/18] remove ray.init() --- scos_actions/actions/acquire_sea_data_product.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scos_actions/actions/acquire_sea_data_product.py b/scos_actions/actions/acquire_sea_data_product.py index 3409699a..e0120c53 100644 --- a/scos_actions/actions/acquire_sea_data_product.py +++ b/scos_actions/actions/acquire_sea_data_product.py @@ -79,9 +79,6 @@ env = Env() logger = logging.getLogger(__name__) -if not ray.is_initialized(): - # Dashboard is only enabled if ray[default] is installed - ray.init() # Define parameter keys RF_PATH = "rf_path" From 2a9c76cf317be133bcba71b4c8d376315e870c08 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 12:45:53 -0700 Subject: [PATCH 02/18] Add RuntimeException action. --- scos_actions/actions/RuntimeException.py | 32 ++++++++++++++++++++++++ scos_actions/discover/__init__.py | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 scos_actions/actions/RuntimeException.py diff --git a/scos_actions/actions/RuntimeException.py b/scos_actions/actions/RuntimeException.py new file mode 100644 index 00000000..9bb15341 --- /dev/null +++ b/scos_actions/actions/RuntimeException.py @@ -0,0 +1,32 @@ +"""A simple example action that logs a message.""" + +import logging +from typing import Optional + +from scos_actions.actions.interfaces.action import Action +from scos_actions.hardware.sensor import Sensor + +logger = logging.getLogger(__name__) + +LOGLVL_INFO = 20 +LOGLVL_ERROR = 40 + + +class RuntimeException(Action): + """Raise a runtime exception". + + This is useful for testing and debugging. + + """ + + def __init__(self, loglvl=LOGLVL_INFO): + super().__init__(parameters={"name": "RuntimeException"}) + self.loglvl = loglvl + + def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): + msg = "Raising runtime exception {name}/{tid}" + schedule_entry_name = schedule_entry["name"] + logger.log( + level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) + ) + raise RuntimeException("RuntimeException produced by RuntimeException action. ") diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 84ba8e6e..28642a33 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,11 +1,12 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger +from scos_actions.actions.RuntimeException import RuntimeException from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer from scos_actions.actions.sync_gps import SyncGps from scos_actions.discover.yaml import load_from_yaml from scos_actions.settings import ACTION_DEFINITIONS_DIR -actions = {"logger": Logger()} +actions = {"logger": Logger(), "RuntimeException": RuntimeException()} test_actions = { "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), "test_monitor_sigan": MonitorSignalAnalyzer( From d8b9fc2b4774499519adec8f835727d0cee8cf9b Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 12:54:37 -0700 Subject: [PATCH 03/18] add SystemExitAction --- scos_actions/actions/SystemExitAction.py | 32 ++++++++++++++++++++++++ scos_actions/discover/__init__.py | 5 +++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 scos_actions/actions/SystemExitAction.py diff --git a/scos_actions/actions/SystemExitAction.py b/scos_actions/actions/SystemExitAction.py new file mode 100644 index 00000000..b3079027 --- /dev/null +++ b/scos_actions/actions/SystemExitAction.py @@ -0,0 +1,32 @@ +"""A simple action that raises SystemExit""" + +import logging +from typing import Optional + +from scos_actions.actions.interfaces.action import Action +from scos_actions.hardware.sensor import Sensor + +logger = logging.getLogger(__name__) + +LOGLVL_INFO = 20 +LOGLVL_ERROR = 40 + + +class SystemExitAction(Action): + """Raise a SystemExit". + + This is useful for testing and debugging. + + """ + + def __init__(self, loglvl=LOGLVL_INFO): + super().__init__(parameters={"name": "SystemExit"}) + self.loglvl = loglvl + + def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): + msg = "Raising runtime exception {name}/{tid}" + schedule_entry_name = schedule_entry["name"] + logger.log( + level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) + ) + raise SystemExit("SystemExit produced by SystemExitAction. ") diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 28642a33..488d5ab5 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,12 +1,15 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger from scos_actions.actions.RuntimeException import RuntimeException +from scos_actions.actions.SystemExitAction import SystemExitAction from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer from scos_actions.actions.sync_gps import SyncGps from scos_actions.discover.yaml import load_from_yaml from scos_actions.settings import ACTION_DEFINITIONS_DIR -actions = {"logger": Logger(), "RuntimeException": RuntimeException()} +actions = {"logger": Logger(), + "RuntimeException": RuntimeException(), + "SystemExit": SystemExitAction()} test_actions = { "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), "test_monitor_sigan": MonitorSignalAnalyzer( From a7db8f551e7544135b325147a40a6e22244fa879 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 13:08:42 -0700 Subject: [PATCH 04/18] rename RuntimeException and SystemExitAction files. --- .../actions/{RuntimeException.py => runtime_exception.py} | 0 .../actions/{SystemExitAction.py => system_exit_action.py} | 0 scos_actions/discover/__init__.py | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename scos_actions/actions/{RuntimeException.py => runtime_exception.py} (100%) rename scos_actions/actions/{SystemExitAction.py => system_exit_action.py} (100%) diff --git a/scos_actions/actions/RuntimeException.py b/scos_actions/actions/runtime_exception.py similarity index 100% rename from scos_actions/actions/RuntimeException.py rename to scos_actions/actions/runtime_exception.py diff --git a/scos_actions/actions/SystemExitAction.py b/scos_actions/actions/system_exit_action.py similarity index 100% rename from scos_actions/actions/SystemExitAction.py rename to scos_actions/actions/system_exit_action.py diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 488d5ab5..81ed21c5 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,7 +1,7 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger -from scos_actions.actions.RuntimeException import RuntimeException -from scos_actions.actions.SystemExitAction import SystemExitAction +from scos_actions.actions.runtime_exception import RuntimeException +from scos_actions.actions.system_exit_action import SystemExitAction from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer from scos_actions.actions.sync_gps import SyncGps from scos_actions.discover.yaml import load_from_yaml From bf450247d20c55590dba2e43da5010f80cdeffdc Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 13:50:09 -0700 Subject: [PATCH 05/18] fix RuntimeError. --- scos_actions/actions/runtime_exception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/actions/runtime_exception.py b/scos_actions/actions/runtime_exception.py index 9bb15341..eb7750ab 100644 --- a/scos_actions/actions/runtime_exception.py +++ b/scos_actions/actions/runtime_exception.py @@ -29,4 +29,4 @@ def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int) logger.log( level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) ) - raise RuntimeException("RuntimeException produced by RuntimeException action. ") + raise RuntimeError("RuntimeError from RuntimeErrorAction") From dd8518b7a18cabfda617148eb002ccbde1996070 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 14:13:04 -0700 Subject: [PATCH 06/18] change call to runtime error --- scos_actions/actions/runtime_exception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/actions/runtime_exception.py b/scos_actions/actions/runtime_exception.py index eb7750ab..29911e42 100644 --- a/scos_actions/actions/runtime_exception.py +++ b/scos_actions/actions/runtime_exception.py @@ -29,4 +29,4 @@ def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int) logger.log( level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) ) - raise RuntimeError("RuntimeError from RuntimeErrorAction") + RuntimeError("RuntimeError from RuntimeErrorAction") From 5ec8eb65e99bf1f16cc46d84eff11e42c222707d Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 14:20:01 -0700 Subject: [PATCH 07/18] return to raising RuntimeError. --- scos_actions/actions/runtime_exception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/actions/runtime_exception.py b/scos_actions/actions/runtime_exception.py index 29911e42..eb7750ab 100644 --- a/scos_actions/actions/runtime_exception.py +++ b/scos_actions/actions/runtime_exception.py @@ -29,4 +29,4 @@ def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int) logger.log( level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) ) - RuntimeError("RuntimeError from RuntimeErrorAction") + raise RuntimeError("RuntimeError from RuntimeErrorAction") From ec4527b33f0f8ca1e2837da50bcff0182da1f9c9 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 14:34:11 -0700 Subject: [PATCH 08/18] add seg fault action. --- scos_actions/actions/seg_fault.py | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scos_actions/actions/seg_fault.py diff --git a/scos_actions/actions/seg_fault.py b/scos_actions/actions/seg_fault.py new file mode 100644 index 00000000..8c574357 --- /dev/null +++ b/scos_actions/actions/seg_fault.py @@ -0,0 +1,33 @@ +"""A simple action to create a segfault.""" +import ctypes +import logging +from typing import Optional + +from scos_actions.actions.interfaces.action import Action +from scos_actions.hardware.sensor import Sensor + +logger = logging.getLogger(__name__) + +LOGLVL_INFO = 20 +LOGLVL_ERROR = 40 + + +class SegFault(Action): + """Raise a runtime exception". + + This is useful for testing and debugging. + + """ + + def __init__(self, loglvl=LOGLVL_INFO): + super().__init__(parameters={"name": "RuntimeException"}) + self.loglvl = loglvl + + def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): + i = ctypes.c_char('a') + j = ctypes.pointer(i) + c = 0 + while True: + j[c] = 'a' + c += 1 + j From 2157a5299ba107396d41670294fed6712968c54f Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 15 Feb 2024 14:46:03 -0700 Subject: [PATCH 09/18] change segfault action. --- scos_actions/actions/seg_fault.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/scos_actions/actions/seg_fault.py b/scos_actions/actions/seg_fault.py index 8c574357..9add5962 100644 --- a/scos_actions/actions/seg_fault.py +++ b/scos_actions/actions/seg_fault.py @@ -1,6 +1,7 @@ """A simple action to create a segfault.""" -import ctypes + import logging +import sys from typing import Optional from scos_actions.actions.interfaces.action import Action @@ -24,10 +25,6 @@ def __init__(self, loglvl=LOGLVL_INFO): self.loglvl = loglvl def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): - i = ctypes.c_char('a') - j = ctypes.pointer(i) - c = 0 - while True: - j[c] = 'a' - c += 1 - j + sys.setrecursionlimit(1 << 30) + f = lambda f: f(f) + f(f) From c69cd04318487c138147d0cb338ba0fbb81b2955 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 28 Feb 2024 09:23:07 -0700 Subject: [PATCH 10/18] Remove seg_fault action. --- scos_actions/actions/__init__.py | 2 +- scos_actions/actions/seg_fault.py | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 scos_actions/actions/seg_fault.py diff --git a/scos_actions/actions/__init__.py b/scos_actions/actions/__init__.py index e22cbee2..d1180ae3 100644 --- a/scos_actions/actions/__init__.py +++ b/scos_actions/actions/__init__.py @@ -11,5 +11,5 @@ "stepped_frequency_time_domain_iq": SteppedFrequencyTimeDomainIqAcquisition, "single_frequency_time_domain_iq": SingleFrequencyTimeDomainIqAcquisition, "y_factor_cal": YFactorCalibration, - "nasctn_sea_data_product": NasctnSeaDataProduct, + "nasctn_sea_data_product": NasctnSeaDataProduct } diff --git a/scos_actions/actions/seg_fault.py b/scos_actions/actions/seg_fault.py deleted file mode 100644 index 9add5962..00000000 --- a/scos_actions/actions/seg_fault.py +++ /dev/null @@ -1,30 +0,0 @@ -"""A simple action to create a segfault.""" - -import logging -import sys -from typing import Optional - -from scos_actions.actions.interfaces.action import Action -from scos_actions.hardware.sensor import Sensor - -logger = logging.getLogger(__name__) - -LOGLVL_INFO = 20 -LOGLVL_ERROR = 40 - - -class SegFault(Action): - """Raise a runtime exception". - - This is useful for testing and debugging. - - """ - - def __init__(self, loglvl=LOGLVL_INFO): - super().__init__(parameters={"name": "RuntimeException"}) - self.loglvl = loglvl - - def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): - sys.setrecursionlimit(1 << 30) - f = lambda f: f(f) - f(f) From 394eec577e8174e5cbd60f4e19a4d8eb3baf5a6f Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 28 Feb 2024 09:29:50 -0700 Subject: [PATCH 11/18] run pre-commit. --- scos_actions/actions/__init__.py | 2 +- scos_actions/actions/acquire_single_freq_fft.py | 1 + .../actions/acquire_single_freq_tdomain_iq.py | 4 ++-- .../actions/acquire_stepped_freq_tdomain_iq.py | 4 ++-- scos_actions/actions/calibrate_y_factor.py | 4 ++-- .../actions/interfaces/measurement_action.py | 1 + scos_actions/discover/__init__.py | 12 +++++++----- scos_actions/hardware/sigan_iface.py | 1 + scos_actions/signal_processing/calibration.py | 1 + 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scos_actions/actions/__init__.py b/scos_actions/actions/__init__.py index d1180ae3..e22cbee2 100644 --- a/scos_actions/actions/__init__.py +++ b/scos_actions/actions/__init__.py @@ -11,5 +11,5 @@ "stepped_frequency_time_domain_iq": SteppedFrequencyTimeDomainIqAcquisition, "single_frequency_time_domain_iq": SingleFrequencyTimeDomainIqAcquisition, "y_factor_cal": YFactorCalibration, - "nasctn_sea_data_product": NasctnSeaDataProduct + "nasctn_sea_data_product": NasctnSeaDataProduct, } diff --git a/scos_actions/actions/acquire_single_freq_fft.py b/scos_actions/actions/acquire_single_freq_fft.py index aa6f16ba..cf31ae8f 100644 --- a/scos_actions/actions/acquire_single_freq_fft.py +++ b/scos_actions/actions/acquire_single_freq_fft.py @@ -89,6 +89,7 @@ import logging from numpy import float32, ndarray + from scos_actions.actions.interfaces.measurement_action import MeasurementAction from scos_actions.hardware.mocks.mock_gps import MockGPS from scos_actions.metadata.structs import ntia_algorithm diff --git a/scos_actions/actions/acquire_single_freq_tdomain_iq.py b/scos_actions/actions/acquire_single_freq_tdomain_iq.py index 0eb55655..fb505090 100644 --- a/scos_actions/actions/acquire_single_freq_tdomain_iq.py +++ b/scos_actions/actions/acquire_single_freq_tdomain_iq.py @@ -34,12 +34,12 @@ import logging from numpy import complex64 + +from scos_actions import utils from scos_actions.actions.interfaces.measurement_action import MeasurementAction from scos_actions.hardware.mocks.mock_gps import MockGPS from scos_actions.utils import get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) # Define parameter keys diff --git a/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py b/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py index 495be7e2..39575f8b 100644 --- a/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py +++ b/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py @@ -38,6 +38,8 @@ import logging import numpy as np + +from scos_actions import utils from scos_actions.actions.acquire_single_freq_tdomain_iq import ( CAL_ADJUST, DURATION_MS, @@ -51,8 +53,6 @@ from scos_actions.signals import measurement_action_completed from scos_actions.utils import get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) diff --git a/scos_actions/actions/calibrate_y_factor.py b/scos_actions/actions/calibrate_y_factor.py index d26bb743..15cf9fd9 100644 --- a/scos_actions/actions/calibrate_y_factor.py +++ b/scos_actions/actions/calibrate_y_factor.py @@ -75,6 +75,8 @@ import numpy as np from scipy.constants import Boltzmann from scipy.signal import sosfilt + +from scos_actions import utils from scos_actions.actions.interfaces.action import Action from scos_actions.hardware.sensor import Sensor from scos_actions.hardware.sigan_iface import SIGAN_SETTINGS_KEYS @@ -92,8 +94,6 @@ from scos_actions.signals import trigger_api_restart from scos_actions.utils import ParameterException, get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) # Define parameter keys diff --git a/scos_actions/actions/interfaces/measurement_action.py b/scos_actions/actions/interfaces/measurement_action.py index f0b06e54..88a0a239 100644 --- a/scos_actions/actions/interfaces/measurement_action.py +++ b/scos_actions/actions/interfaces/measurement_action.py @@ -3,6 +3,7 @@ from typing import Optional import numpy as np + from scos_actions.actions.interfaces.action import Action from scos_actions.hardware.sensor import Sensor from scos_actions.metadata.structs import ntia_sensor diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 81ed21c5..997c322b 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,15 +1,17 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger -from scos_actions.actions.runtime_exception import RuntimeException -from scos_actions.actions.system_exit_action import SystemExitAction from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer +from scos_actions.actions.runtime_exception import RuntimeException from scos_actions.actions.sync_gps import SyncGps +from scos_actions.actions.system_exit_action import SystemExitAction from scos_actions.discover.yaml import load_from_yaml from scos_actions.settings import ACTION_DEFINITIONS_DIR -actions = {"logger": Logger(), - "RuntimeException": RuntimeException(), - "SystemExit": SystemExitAction()} +actions = { + "logger": Logger(), + "RuntimeException": RuntimeException(), + "SystemExit": SystemExitAction(), +} test_actions = { "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), "test_monitor_sigan": MonitorSignalAnalyzer( diff --git a/scos_actions/hardware/sigan_iface.py b/scos_actions/hardware/sigan_iface.py index 7ed01d45..3b211113 100644 --- a/scos_actions/hardware/sigan_iface.py +++ b/scos_actions/hardware/sigan_iface.py @@ -4,6 +4,7 @@ from typing import Dict, Optional from its_preselector.web_relay import WebRelay + from scos_actions.calibration.calibration import Calibration from scos_actions.hardware.utils import power_cycle_sigan from scos_actions.utils import convert_string_to_millisecond_iso_format diff --git a/scos_actions/signal_processing/calibration.py b/scos_actions/signal_processing/calibration.py index 41ef5d71..785685d3 100644 --- a/scos_actions/signal_processing/calibration.py +++ b/scos_actions/signal_processing/calibration.py @@ -4,6 +4,7 @@ import numpy as np from its_preselector.preselector import Preselector from scipy.constants import Boltzmann + from scos_actions.signal_processing.unit_conversion import ( convert_celsius_to_fahrenheit, convert_celsius_to_kelvins, From 6cc1a71b551ead0e2bd9fec26c4a98b5429c8647 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 28 Feb 2024 09:51:17 -0700 Subject: [PATCH 12/18] Rename RuntimeErrorAction and cleanup. --- scos_actions/actions/runtime_error_action.py | 26 ++++++++++++++++++++ scos_actions/actions/system_exit_action.py | 18 +++++--------- 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 scos_actions/actions/runtime_error_action.py diff --git a/scos_actions/actions/runtime_error_action.py b/scos_actions/actions/runtime_error_action.py new file mode 100644 index 00000000..704df828 --- /dev/null +++ b/scos_actions/actions/runtime_error_action.py @@ -0,0 +1,26 @@ +"""A simple example action that raises a RuntimeError.""" + +import logging +from typing import Optional + +from scos_actions.actions.interfaces.action import Action +from scos_actions.hardware.sensor import Sensor + +logger = logging.getLogger(__name__) + + +class RuntimeErrorAction(Action): + """ + Raise a runtime error. + This is useful for testing and debugging. + + """ + + def __init__(self): + super().__init__(parameters={"name": "RuntimeErrorAction"}) + + def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): + msg = "Raising runtime exception {name}/{tid}" + schedule_entry_name = schedule_entry["name"] + logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id)) + raise RuntimeError("RuntimeError from RuntimeErrorAction") diff --git a/scos_actions/actions/system_exit_action.py b/scos_actions/actions/system_exit_action.py index b3079027..ea8b6727 100644 --- a/scos_actions/actions/system_exit_action.py +++ b/scos_actions/actions/system_exit_action.py @@ -8,25 +8,19 @@ logger = logging.getLogger(__name__) -LOGLVL_INFO = 20 -LOGLVL_ERROR = 40 - class SystemExitAction(Action): - """Raise a SystemExit". - + """ + Raise a SystemExit. This is useful for testing and debugging. """ - def __init__(self, loglvl=LOGLVL_INFO): - super().__init__(parameters={"name": "SystemExit"}) - self.loglvl = loglvl + def __init__(self): + super().__init__(parameters={"name": "SystemExitAction"}) def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): - msg = "Raising runtime exception {name}/{tid}" + msg = "Raising SystemExit {name}/{tid}" schedule_entry_name = schedule_entry["name"] - logger.log( - level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) - ) + logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id)) raise SystemExit("SystemExit produced by SystemExitAction. ") From b50487222e48d9f489a4a52bb074f5b2566f82bb Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 28 Feb 2024 10:05:11 -0700 Subject: [PATCH 13/18] Minor update to message logged in RuntimeErrorAction. --- scos_actions/actions/runtime_error_action.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/actions/runtime_error_action.py b/scos_actions/actions/runtime_error_action.py index 704df828..20d1917a 100644 --- a/scos_actions/actions/runtime_error_action.py +++ b/scos_actions/actions/runtime_error_action.py @@ -20,7 +20,7 @@ def __init__(self): super().__init__(parameters={"name": "RuntimeErrorAction"}) def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): - msg = "Raising runtime exception {name}/{tid}" + msg = "Raising RuntimeError {name}/{tid}" schedule_entry_name = schedule_entry["name"] logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id)) raise RuntimeError("RuntimeError from RuntimeErrorAction") From 3d45995bf5e1cd24499f5781b618681edaeed354 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 28 Feb 2024 10:12:00 -0700 Subject: [PATCH 14/18] Delete runtime_exception.py --- scos_actions/actions/runtime_exception.py | 32 ----------------------- scos_actions/discover/__init__.py | 6 +++-- 2 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 scos_actions/actions/runtime_exception.py diff --git a/scos_actions/actions/runtime_exception.py b/scos_actions/actions/runtime_exception.py deleted file mode 100644 index eb7750ab..00000000 --- a/scos_actions/actions/runtime_exception.py +++ /dev/null @@ -1,32 +0,0 @@ -"""A simple example action that logs a message.""" - -import logging -from typing import Optional - -from scos_actions.actions.interfaces.action import Action -from scos_actions.hardware.sensor import Sensor - -logger = logging.getLogger(__name__) - -LOGLVL_INFO = 20 -LOGLVL_ERROR = 40 - - -class RuntimeException(Action): - """Raise a runtime exception". - - This is useful for testing and debugging. - - """ - - def __init__(self, loglvl=LOGLVL_INFO): - super().__init__(parameters={"name": "RuntimeException"}) - self.loglvl = loglvl - - def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): - msg = "Raising runtime exception {name}/{tid}" - schedule_entry_name = schedule_entry["name"] - logger.log( - level=self.loglvl, msg=msg.format(name=schedule_entry_name, tid=task_id) - ) - raise RuntimeError("RuntimeError from RuntimeErrorAction") diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 997c322b..a27fdc11 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,7 +1,7 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer -from scos_actions.actions.runtime_exception import RuntimeException +from scos_actions.actions.runtime_error_action import RuntimeErrorAction from scos_actions.actions.sync_gps import SyncGps from scos_actions.actions.system_exit_action import SystemExitAction from scos_actions.discover.yaml import load_from_yaml @@ -9,7 +9,7 @@ actions = { "logger": Logger(), - "RuntimeException": RuntimeException(), + "RuntimeError": RuntimeErrorAction(), "SystemExit": SystemExitAction(), } test_actions = { @@ -18,6 +18,8 @@ parameters={"name": "test_monitor_sigan"} ), "logger": Logger(), + "RuntimeError": RuntimeErrorAction(), + "SystemExit": SystemExitAction(), } From 8f7d6e35213a4fc63d64e83866e61084c059fa99 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 29 Feb 2024 14:51:38 -0700 Subject: [PATCH 15/18] Add comment that actions must be manually added to use. --- scos_actions/actions/runtime_error_action.py | 4 +++- scos_actions/actions/system_exit_action.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scos_actions/actions/runtime_error_action.py b/scos_actions/actions/runtime_error_action.py index 20d1917a..13058bc9 100644 --- a/scos_actions/actions/runtime_error_action.py +++ b/scos_actions/actions/runtime_error_action.py @@ -12,7 +12,9 @@ class RuntimeErrorAction(Action): """ Raise a runtime error. - This is useful for testing and debugging. + This is useful for testing and debugging. Note: this action + is currently not loaded in any scenario and must be manually + added to use. """ diff --git a/scos_actions/actions/system_exit_action.py b/scos_actions/actions/system_exit_action.py index ea8b6727..f275be8a 100644 --- a/scos_actions/actions/system_exit_action.py +++ b/scos_actions/actions/system_exit_action.py @@ -12,7 +12,9 @@ class SystemExitAction(Action): """ Raise a SystemExit. - This is useful for testing and debugging. + This is useful for testing and debugging. Note: this action + is currently not loaded in any scenario and must be manually + added to use. """ From 6df86d0eaffc35c312e7e5bf18c29dba40967299 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 29 Feb 2024 14:57:05 -0700 Subject: [PATCH 16/18] Remove SystemExit and RuntimeError from discover. --- scos_actions/discover/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index a27fdc11..0fa0128f 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,16 +1,12 @@ from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer -from scos_actions.actions.runtime_error_action import RuntimeErrorAction from scos_actions.actions.sync_gps import SyncGps -from scos_actions.actions.system_exit_action import SystemExitAction from scos_actions.discover.yaml import load_from_yaml from scos_actions.settings import ACTION_DEFINITIONS_DIR actions = { "logger": Logger(), - "RuntimeError": RuntimeErrorAction(), - "SystemExit": SystemExitAction(), } test_actions = { "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), @@ -18,8 +14,6 @@ parameters={"name": "test_monitor_sigan"} ), "logger": Logger(), - "RuntimeError": RuntimeErrorAction(), - "SystemExit": SystemExitAction(), } From 3f7b554140667a8944e8a7edbf92233449b3c8d9 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Tue, 5 Mar 2024 07:20:26 -0700 Subject: [PATCH 17/18] Add ray initialization in sea action __call__ as a fail safe. --- scos_actions/actions/acquire_sea_data_product.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scos_actions/actions/acquire_sea_data_product.py b/scos_actions/actions/acquire_sea_data_product.py index e0120c53..20a684da 100644 --- a/scos_actions/actions/acquire_sea_data_product.py +++ b/scos_actions/actions/acquire_sea_data_product.py @@ -504,6 +504,13 @@ def __call__(self, sensor: Sensor, schedule_entry: dict, task_id: int): """This is the entrypoint function called by the scheduler.""" self._sensor = sensor action_start_tic = perf_counter() + # Ray should have already been initialized within scos-sensor, + # but check and initialize just in case. + if not ray.is_initialized(): + logger.info("Initializing ray.") + logger.info("Set RAY_INIT=true to avoid initializing within " + __name__) + # Dashboard is only enabled if ray[default] is installed + ray.init() _ = psutil.cpu_percent(interval=None) # Initialize CPU usage monitor self.test_required_components() From 06ab7e3034ce94e40278665fb1ad4fe6e72a7146 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 6 Mar 2024 09:18:48 -0700 Subject: [PATCH 18/18] Increment version. --- scos_actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/__init__.py b/scos_actions/__init__.py index 73d4c8be..9e17e009 100644 --- a/scos_actions/__init__.py +++ b/scos_actions/__init__.py @@ -1 +1 @@ -__version__ = "8.0.0" +__version__ = "8.0.1"