Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize ray in scos-sensor #112

Merged
merged 18 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add SystemExitAction
  • Loading branch information
dboulware committed Feb 15, 2024
commit d8b9fc2b4774499519adec8f835727d0cee8cf9b
32 changes: 32 additions & 0 deletions scos_actions/actions/SystemExitAction.py
Original file line number Diff line number Diff line change
@@ -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. ")
5 changes: 4 additions & 1 deletion scos_actions/discover/__init__.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down