Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…A-178_test_actions_loading
  • Loading branch information
jhazentia committed Mar 7, 2024
2 parents adb5383 + 07ef42b commit f7f08b3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scos_actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "8.0.0"
__version__ = "8.0.1"
10 changes: 7 additions & 3 deletions scos_actions/actions/acquire_sea_data_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -509,6 +506,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()
Expand Down
28 changes: 28 additions & 0 deletions scos_actions/actions/runtime_error_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""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. Note: this action
is currently not loaded in any scenario and must be manually
added to use.
"""

def __init__(self):
super().__init__(parameters={"name": "RuntimeErrorAction"})

def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int):
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")
28 changes: 28 additions & 0 deletions scos_actions/actions/system_exit_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""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__)


class SystemExitAction(Action):
"""
Raise a SystemExit.
This is useful for testing and debugging. Note: this action
is currently not loaded in any scenario and must be manually
added to use.
"""

def __init__(self):
super().__init__(parameters={"name": "SystemExitAction"})

def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int):
msg = "Raising SystemExit {name}/{tid}"
schedule_entry_name = schedule_entry["name"]
logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id))
raise SystemExit("SystemExit produced by SystemExitAction. ")

0 comments on commit f7f08b3

Please sign in to comment.