From b467fb9317f75831d12be609d513c8e7c84580fe Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Tue, 20 Feb 2024 11:14:35 -0700 Subject: [PATCH 01/16] change scos-actions, scos-tekrsa versions, don't check usb if using mock, load test actions from all plugins --- src/initialization/__init__.py | 2 +- src/initialization/action_loader.py | 29 ++++++++++++++--------------- src/requirements-dev.txt | 8 +++----- src/requirements.in | 2 +- src/requirements.txt | 4 ++-- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/initialization/__init__.py b/src/initialization/__init__.py index e97def1e..5166c4a3 100644 --- a/src/initialization/__init__.py +++ b/src/initialization/__init__.py @@ -20,7 +20,7 @@ def get_usb_device_exists() -> bool: logger.debug("Checking for USB...") - if not settings.RUNNING_TESTS and settings.USB_DEVICE is not None: + if not settings.RUNNING_TESTS and settings.USB_DEVICE is not None and not settings.MOCK_SIGAN: usb_devices = check_output("lsusb").decode(sys.stdout.encoding) logger.debug("Checking for " + settings.USB_DEVICE) logger.debug("Found " + usb_devices) diff --git a/src/initialization/action_loader.py b/src/initialization/action_loader.py index f94fb5a1..a8cf8cec 100644 --- a/src/initialization/action_loader.py +++ b/src/initialization/action_loader.py @@ -95,21 +95,20 @@ def load_actions( } logger.debug(discovered_plugins) actions = {} - if mock_sigan or running_tests: - logger.debug(f"Loading {len(test_actions)} test actions.") - actions.update(test_actions) - else: - for name, module in discovered_plugins.items(): - logger.debug("Looking for actions in " + name + ": " + str(module)) - discover = importlib.import_module(name + ".discover") - if hasattr(discover, "actions"): - logger.debug(f"loading {len(discover.actions)} actions.") - actions.update(discover.actions) - if ( - hasattr(discover, "action_classes") - and discover.action_classes is not None - ): - action_classes.update(discover.action_classes) + for name, module in discovered_plugins.items(): + logger.debug("Looking for actions in " + name + ": " + str(module)) + discover = importlib.import_module(name + ".discover") + if (mock_sigan or running_tests) and hasattr(discover, "test_actions"): + logger.debug(f"loading {len(discover.test_actions)} test actions.") + actions.update(discover.test_actions) + elif hasattr(discover, "actions"): + logger.debug(f"loading {len(discover.actions)} actions.") + actions.update(discover.actions) + if ( + hasattr(discover, "action_classes") + and discover.action_classes is not None + ): + action_classes.update(discover.action_classes) logger.debug(f"Loading actions in {action_dir}") yaml_actions, yaml_test_actions = init( diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index e6587fc2..754cb131 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -59,9 +59,7 @@ colorama==0.4.6 colorful==0.5.5 # via ray coverage[toml]==7.3.2 - # via - # coverage - # pytest-cov + # via pytest-cov cryptography==41.0.7 # via -r requirements.txt defusedxml==0.7.1 @@ -315,11 +313,11 @@ scipy==1.10.1 # via # -r requirements.txt # scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@8.0.0 +scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading # via # -r requirements.txt # scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@5.0.0 +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.txt sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via diff --git a/src/requirements.in b/src/requirements.in index bc87c3d5..84156e31 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -11,7 +11,7 @@ packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 requests_oauthlib>=1.0, <2.0 -scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@5.0.0 +scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # The following are sub-dependencies for which SCOS Sensor enforces a # higher minimum patch version than the dependencies which require them. diff --git a/src/requirements.txt b/src/requirements.txt index fffdf660..109cd6fb 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -149,9 +149,9 @@ ruamel-yaml-clib==0.2.8 # via ruamel-yaml scipy==1.10.1 # via scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@8.0.0 +scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading # via scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@5.0.0 +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.in sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via scos-actions From 370625dbfba90757b981f6e3fb0e4c423b061fd7 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Thu, 29 Feb 2024 13:24:16 -0700 Subject: [PATCH 02/16] include scos-actions in plugins, use scos_actions test actions for tests, load all test actions when using mock, load gps object, requirements updated for testing scos_usrp --- docker-compose.yml | 2 ++ src/initialization/action_loader.py | 34 ++++++++++++++++------------- src/initialization/sensor_loader.py | 13 +++++++++++ src/requirements-dev.txt | 13 +++++------ src/requirements.in | 2 +- src/requirements.txt | 11 +++++----- src/sensor/settings.py | 4 ++++ 7 files changed, 49 insertions(+), 30 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index db9f3a60..3de0c0c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,6 +48,8 @@ services: - ENCRYPTION_KEY - FQDN - GIT_BRANCH + - GPS_MODULE + - GPS_CLASS - GUNICORN_LOG_LEVEL - IN_DOCKER=1 - IPS diff --git a/src/initialization/action_loader.py b/src/initialization/action_loader.py index a8cf8cec..3e99568b 100644 --- a/src/initialization/action_loader.py +++ b/src/initialization/action_loader.py @@ -91,24 +91,28 @@ def load_actions( discovered_plugins = { name: importlib.import_module(name) for finder, name, ispkg in pkgutil.iter_modules() - if name.startswith("scos_") and name != "scos_actions" + if name.startswith("scos_") } logger.debug(discovered_plugins) actions = {} - for name, module in discovered_plugins.items(): - logger.debug("Looking for actions in " + name + ": " + str(module)) - discover = importlib.import_module(name + ".discover") - if (mock_sigan or running_tests) and hasattr(discover, "test_actions"): - logger.debug(f"loading {len(discover.test_actions)} test actions.") - actions.update(discover.test_actions) - elif hasattr(discover, "actions"): - logger.debug(f"loading {len(discover.actions)} actions.") - actions.update(discover.actions) - if ( - hasattr(discover, "action_classes") - and discover.action_classes is not None - ): - action_classes.update(discover.action_classes) + if running_tests: + logger.debug(f"Loading {len(test_actions)} test actions.") + actions.update(test_actions) + else: + for name, module in discovered_plugins.items(): + logger.debug("Looking for actions in " + name + ": " + str(module)) + discover = importlib.import_module(name + ".discover") + if mock_sigan and hasattr(discover, "test_actions"): + logger.debug(f"loading {len(discover.test_actions)} test actions.") + actions.update(discover.test_actions) + elif hasattr(discover, "actions"): + logger.debug(f"loading {len(discover.actions)} actions.") + actions.update(discover.actions) + if ( + hasattr(discover, "action_classes") + and discover.action_classes is not None + ): + action_classes.update(discover.action_classes) logger.debug(f"Loading actions in {action_dir}") yaml_actions, yaml_test_actions = init( diff --git a/src/initialization/sensor_loader.py b/src/initialization/sensor_loader.py index 4ce54936..0ebb7cb9 100644 --- a/src/initialization/sensor_loader.py +++ b/src/initialization/sensor_loader.py @@ -70,6 +70,7 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: ) sigan = None + gps = None try: if not settings.RUNNING_MIGRATIONS: check_for_required_sigan_settings() @@ -83,6 +84,17 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: sensor_cal=sensor_cal, sigan_cal=sigan_cal, switches=switches ) register_component_with_status.send(sigan, component=sigan) + + if settings.GPS_MODULE and settings.GPS_CLASS: + gps_module_setting = settings.GPS_MODULE + gps_module = importlib.import_module(gps_module_setting) + logger.info( + "Creating " + settings.GPS_CLASS + " from " + settings.GPS_MODULE + ) + gps_constructor = getattr(gps_module, settings.GPS_CLASS) + gps = gps_constructor( + sigan=sigan + ) else: logger.info("Running migrations. Not loading signal analyzer.") except Exception as ex: @@ -94,6 +106,7 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: preselector=preselector, switches=switches, location=location, + gps=gps ) return sensor diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index 754cb131..29efb35c 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -76,6 +76,7 @@ django==3.2.23 # drf-yasg # jsonfield # scos-actions + # scos-usrp django-session-timeout==0.1.0 # via -r requirements.txt djangorestframework==3.14.0 @@ -88,7 +89,7 @@ environs==9.5.0 # via # -r requirements.txt # scos-actions - # scos-tekrsa + # scos-usrp exceptiongroup==1.2.0 # via pytest filelock==3.13.1 @@ -178,8 +179,8 @@ numpy==1.24.4 # ray # scipy # scos-actions + # scos-usrp # sigmf - # tekrsa-api-wrap nvidia-ml-py==12.535.133 # via gpustat oauthlib==3.2.2 @@ -316,8 +317,8 @@ scipy==1.10.1 scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading # via # -r requirements.txt - # scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading + # scos-usrp +scos-usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading # via -r requirements.txt sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via @@ -337,10 +338,6 @@ sqlparse==0.4.4 # via # -r requirements.txt # django -tekrsa-api-wrap==1.3.2 - # via - # -r requirements.txt - # scos-tekrsa tomli==2.0.1 # via # coverage diff --git a/src/requirements.in b/src/requirements.in index 84156e31..10d0f007 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -11,7 +11,7 @@ packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 requests_oauthlib>=1.0, <2.0 -scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading +scos_usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading # The following are sub-dependencies for which SCOS Sensor enforces a # higher minimum patch version than the dependencies which require them. diff --git a/src/requirements.txt b/src/requirements.txt index 109cd6fb..b8a086af 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -32,6 +32,7 @@ django==3.2.23 # drf-yasg # jsonfield # scos-actions + # scos-usrp django-session-timeout==0.1.0 # via -r requirements.in djangorestframework==3.14.0 @@ -44,7 +45,7 @@ environs==9.5.0 # via # -r requirements.in # scos-actions - # scos-tekrsa + # scos-usrp filelock==3.13.1 # via # -r requirements.in @@ -89,8 +90,8 @@ numpy==1.24.4 # ray # scipy # scos-actions + # scos-usrp # sigmf - # tekrsa-api-wrap oauthlib==3.2.2 # via requests-oauthlib packaging==23.2 @@ -150,8 +151,8 @@ ruamel-yaml-clib==0.2.8 scipy==1.10.1 # via scos-actions scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading - # via scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading + # via scos-usrp +scos-usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading # via -r requirements.in sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via scos-actions @@ -163,8 +164,6 @@ six==1.16.0 # sigmf sqlparse==0.4.4 # via django -tekrsa-api-wrap==1.3.2 - # via scos-tekrsa typing-extensions==4.8.0 # via asgiref uritemplate==4.1.1 diff --git a/src/sensor/settings.py b/src/sensor/settings.py index 1bc97746..a2e0fe27 100644 --- a/src/sensor/settings.py +++ b/src/sensor/settings.py @@ -334,6 +334,8 @@ DEVICE_MODEL = env("DEVICE_MODEL", default="RSA507A") SIGAN_MODULE = "scos_actions.hardware.mocks.mock_sigan" SIGAN_CLASS = "MockSignalAnalyzer" + GPS_MODULE = "scos_actions.hardware.mocks.mock_gps" + GPS_CLASS = "MockGPS" else: DATABASES = { "default": { @@ -348,6 +350,8 @@ DEVICE_MODEL = env("DEVICE_MODEL", default=None) SIGAN_MODULE = env.str("SIGAN_MODULE", default=None) SIGAN_CLASS = env.str("SIGAN_CLASS", default=None) + GPS_MODULE = env.str("GPS_MODULE", default=None) + GPS_CLASS = env.str("GPS_CLASS", default=None) if not IN_DOCKER: DATABASES["default"]["HOST"] = "localhost" From 15fb770ed391d8b2eed4378b12d6ca67260b2370 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Thu, 29 Feb 2024 13:44:35 -0700 Subject: [PATCH 03/16] add GPS to env.template --- env.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/env.template b/env.template index f78e123e..df5cc452 100644 --- a/env.template +++ b/env.template @@ -49,6 +49,8 @@ ENCRYPTION_KEY="$(python3 -c 'import secrets; import base64; print(base64.b64enc FQDN="$(hostname -f)" GIT_BRANCH="git:$(git rev-parse --abbrev-ref HEAD)@$(git rev-parse --short HEAD)" +GPS_MODULE="" +GPS_CLASS="" IPS="$(hostname -I) 127.0.0.1" From d3e69262f32571a3bd550f08530e19f90ea3e3ce Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Tue, 5 Mar 2024 10:48:46 -0700 Subject: [PATCH 04/16] switch plugin to scos-tekrsa, autoformat files --- docs/openapi.json | 2 +- gunicorn/config.py | 1 - src/handlers/apps.py | 5 +---- src/initialization/__init__.py | 6 +++++- src/initialization/sensor_loader.py | 6 ++---- src/requirements-dev.txt | 17 +++++++++-------- src/requirements.in | 2 +- src/requirements.txt | 11 ++++++----- src/sensor/utils.py | 2 -- src/sensor/wsgi.py | 2 +- src/tasks/__init__.py | 2 -- src/utils/signals.py | 4 ++-- 12 files changed, 28 insertions(+), 32 deletions(-) diff --git a/docs/openapi.json b/docs/openapi.json index feee0bb5..58cf9ab7 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1645,9 +1645,9 @@ "type": "string", "enum": [ "logger", + "test_SEA_CBRS_Measure_Baseline", "test_monitor_sigan", "test_multi_frequency_iq_action", - "test_nasctn_sea_data_product", "test_single_frequency_iq_action", "test_single_frequency_m4s_action", "test_survey_iq_action", diff --git a/gunicorn/config.py b/gunicorn/config.py index 5efc64fb..0b68ad33 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -2,7 +2,6 @@ import sys from multiprocessing import cpu_count - bind = ":8000" workers = 1 worker_class = "gthread" diff --git a/src/handlers/apps.py b/src/handlers/apps.py index 8afad0e2..3dffb135 100644 --- a/src/handlers/apps.py +++ b/src/handlers/apps.py @@ -5,7 +5,7 @@ from scos_actions.signals import ( location_action_completed, measurement_action_completed, - trigger_api_restart + trigger_api_restart, ) logger = logging.getLogger(__name__) @@ -20,7 +20,6 @@ def ready(self): db_location_deleted, db_location_updated, location_action_completed_callback, - ) from handlers.measurement_handler import measurement_action_completed_callback @@ -40,5 +39,3 @@ def ready(self): trigger_api_restart.connect(trigger_api_restart_callback) logger.debug("trigger_api_restart_callback registered to trigger_api_restart") - - diff --git a/src/initialization/__init__.py b/src/initialization/__init__.py index 5166c4a3..3868aae3 100644 --- a/src/initialization/__init__.py +++ b/src/initialization/__init__.py @@ -20,7 +20,11 @@ def get_usb_device_exists() -> bool: logger.debug("Checking for USB...") - if not settings.RUNNING_TESTS and settings.USB_DEVICE is not None and not settings.MOCK_SIGAN: + if ( + not settings.RUNNING_TESTS + and settings.USB_DEVICE is not None + and not settings.MOCK_SIGAN + ): usb_devices = check_output("lsusb").decode(sys.stdout.encoding) logger.debug("Checking for " + settings.USB_DEVICE) logger.debug("Found " + usb_devices) diff --git a/src/initialization/sensor_loader.py b/src/initialization/sensor_loader.py index 0ebb7cb9..f0d1504d 100644 --- a/src/initialization/sensor_loader.py +++ b/src/initialization/sensor_loader.py @@ -92,9 +92,7 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: "Creating " + settings.GPS_CLASS + " from " + settings.GPS_MODULE ) gps_constructor = getattr(gps_module, settings.GPS_CLASS) - gps = gps_constructor( - sigan=sigan - ) + gps = gps_constructor(sigan=sigan) else: logger.info("Running migrations. Not loading signal analyzer.") except Exception as ex: @@ -106,7 +104,7 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: preselector=preselector, switches=switches, location=location, - gps=gps + gps=gps, ) return sensor diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index ca33da0e..b5249c97 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -59,9 +59,7 @@ colorama==0.4.6 colorful==0.5.5 # via ray coverage[toml]==7.3.2 - # via - # coverage - # pytest-cov + # via pytest-cov cryptography==42.0.4 # via -r requirements.txt defusedxml==0.7.1 @@ -78,7 +76,6 @@ django==3.2.24 # drf-yasg # jsonfield # scos-actions - # scos-usrp django-session-timeout==0.1.0 # via -r requirements.txt djangorestframework==3.14.0 @@ -91,7 +88,7 @@ environs==9.5.0 # via # -r requirements.txt # scos-actions - # scos-usrp + # scos-tekrsa exceptiongroup==1.2.0 # via pytest filelock==3.13.1 @@ -181,8 +178,8 @@ numpy==1.24.4 # ray # scipy # scos-actions - # scos-usrp # sigmf + # tekrsa-api-wrap nvidia-ml-py==12.535.133 # via gpustat oauthlib==3.2.2 @@ -319,8 +316,8 @@ scipy==1.10.1 scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading # via # -r requirements.txt - # scos-usrp -scos-usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading + # scos-tekrsa +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.txt sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via @@ -340,6 +337,10 @@ sqlparse==0.4.4 # via # -r requirements.txt # django +tekrsa-api-wrap==1.3.2 + # via + # -r requirements.txt + # scos-tekrsa tomli==2.0.1 # via # coverage diff --git a/src/requirements.in b/src/requirements.in index 7354f4ae..838c42b7 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -11,7 +11,7 @@ packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 requests_oauthlib>=1.0, <2.0 -scos_usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading +scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # The following are sub-dependencies for which SCOS Sensor enforces a # higher minimum patch version than the dependencies which require them. diff --git a/src/requirements.txt b/src/requirements.txt index 7ecd0a93..da90c967 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -32,7 +32,6 @@ django==3.2.24 # drf-yasg # jsonfield # scos-actions - # scos-usrp django-session-timeout==0.1.0 # via -r requirements.in djangorestframework==3.14.0 @@ -45,7 +44,7 @@ environs==9.5.0 # via # -r requirements.in # scos-actions - # scos-usrp + # scos-tekrsa filelock==3.13.1 # via # -r requirements.in @@ -90,8 +89,8 @@ numpy==1.24.4 # ray # scipy # scos-actions - # scos-usrp # sigmf + # tekrsa-api-wrap oauthlib==3.2.2 # via requests-oauthlib packaging==23.2 @@ -151,8 +150,8 @@ ruamel-yaml-clib==0.2.8 scipy==1.10.1 # via scos-actions scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading - # via scos-usrp -scos-usrp @ git+https://github.com/NTIA/scos-usrp@SEA-178_test_actions_loading + # via scos-tekrsa +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.in sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via scos-actions @@ -164,6 +163,8 @@ six==1.16.0 # sigmf sqlparse==0.4.4 # via django +tekrsa-api-wrap==1.3.2 + # via scos-tekrsa typing-extensions==4.8.0 # via asgiref uritemplate==4.1.1 diff --git a/src/sensor/utils.py b/src/sensor/utils.py index 3b2cd92d..b71ad05b 100644 --- a/src/sensor/utils.py +++ b/src/sensor/utils.py @@ -17,5 +17,3 @@ def get_timestamp_from_datetime(dt: datetime) -> int: def parse_datetime_str(d: str) -> datetime: return datetime.strptime(d, settings.DATETIME_FORMAT) - - diff --git a/src/sensor/wsgi.py b/src/sensor/wsgi.py index 610456e7..703f9628 100644 --- a/src/sensor/wsgi.py +++ b/src/sensor/wsgi.py @@ -30,4 +30,4 @@ if not settings.IN_DOCKER: # Normally scheduler is started by gunicorn worker process - scheduler.thread.start() \ No newline at end of file + scheduler.thread.start() diff --git a/src/tasks/__init__.py b/src/tasks/__init__.py index 8302e1a6..725c1d12 100644 --- a/src/tasks/__init__.py +++ b/src/tasks/__init__.py @@ -1,6 +1,4 @@ import logging - logger = logging.getLogger(__name__) logger.debug("********** Initializing tasks **********") - diff --git a/src/utils/signals.py b/src/utils/signals.py index 225298b5..c6753f6a 100644 --- a/src/utils/signals.py +++ b/src/utils/signals.py @@ -1,4 +1,4 @@ from django.dispatch import Signal -#provides component -register_component_with_status = Signal() \ No newline at end of file +# provides component +register_component_with_status = Signal() From 9409fa070274a472e57084894fbc51d46af8a703 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Mon, 11 Mar 2024 10:05:28 -0600 Subject: [PATCH 05/16] fix scos_sigan_plugin software version --- src/status/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/status/views.py b/src/status/views.py index 64878835..b142514e 100644 --- a/src/status/views.py +++ b/src/status/views.py @@ -69,7 +69,10 @@ def get_software_version(): if sensor_loader.sensor.signal_analyzer.api_version is not None: software_version["sigan_api_version"] = sensor_loader.sensor.signal_analyzer.api_version if sensor_loader.sensor.signal_analyzer.plugin_version is not None: - software_version["scos_sigan_plugin"] = sensor_loader.sensor.signal_analyzer.plugin_version + software_version["scos_sigan_plugin"] = { + "name": sensor_loader.sensor.signal_analyzer.plugin_name, + "version": sensor_loader.sensor.signal_analyzer.plugin_version + } logger.debug(software_version) return software_version From a3e41ea7ca30409ee11a3ed633f9c7010c2cfdfd Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Fri, 15 Mar 2024 11:26:08 -0600 Subject: [PATCH 06/16] fix double import of scos_actions --- src/initialization/action_loader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/initialization/action_loader.py b/src/initialization/action_loader.py index 3e99568b..cba1479e 100644 --- a/src/initialization/action_loader.py +++ b/src/initialization/action_loader.py @@ -91,7 +91,7 @@ def load_actions( discovered_plugins = { name: importlib.import_module(name) for finder, name, ispkg in pkgutil.iter_modules() - if name.startswith("scos_") + if name.startswith("scos_")and name != "scos_actions" } logger.debug(discovered_plugins) actions = {} @@ -105,6 +105,8 @@ def load_actions( if mock_sigan and hasattr(discover, "test_actions"): logger.debug(f"loading {len(discover.test_actions)} test actions.") actions.update(discover.test_actions) + # add scos-actions test_actions for scos-actions mock sigan + actions.update(test_actions) elif hasattr(discover, "actions"): logger.debug(f"loading {len(discover.actions)} actions.") actions.update(discover.actions) From 554a090f87a4ccf4aff2ca5c3cf2d6e5e2d5d9b5 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Thu, 4 Apr 2024 12:19:55 -0600 Subject: [PATCH 07/16] remove sigan from gps constructor --- src/initialization/sensor_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initialization/sensor_loader.py b/src/initialization/sensor_loader.py index f0d1504d..9ddc3045 100644 --- a/src/initialization/sensor_loader.py +++ b/src/initialization/sensor_loader.py @@ -92,7 +92,7 @@ def load_sensor(sensor_capabilities: dict) -> Sensor: "Creating " + settings.GPS_CLASS + " from " + settings.GPS_MODULE ) gps_constructor = getattr(gps_module, settings.GPS_CLASS) - gps = gps_constructor(sigan=sigan) + gps = gps_constructor() else: logger.info("Running migrations. Not loading signal analyzer.") except Exception as ex: From 903750d52506ca368321fa40177e9e0ee9bcbd46 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Mon, 8 Apr 2024 14:47:13 -0600 Subject: [PATCH 08/16] formatting, always load scos_actions test actions when using mock, load scos-sensor test actions when using mock --- src/initialization/action_loader.py | 16 ++++++++++++---- src/initialization/sensor_loader.py | 5 ++++- src/status/views.py | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/initialization/action_loader.py b/src/initialization/action_loader.py index cba1479e..9ba65fc6 100644 --- a/src/initialization/action_loader.py +++ b/src/initialization/action_loader.py @@ -91,7 +91,7 @@ def load_actions( discovered_plugins = { name: importlib.import_module(name) for finder, name, ispkg in pkgutil.iter_modules() - if name.startswith("scos_")and name != "scos_actions" + if name.startswith("scos_") and name != "scos_actions" } logger.debug(discovered_plugins) actions = {} @@ -99,14 +99,17 @@ def load_actions( logger.debug(f"Loading {len(test_actions)} test actions.") actions.update(test_actions) else: + # load scos-actions test_actions + if mock_sigan: + logger.debug(f"Loading {len(test_actions)} test actions.") + actions.update(test_actions) + # load other plugin actions for name, module in discovered_plugins.items(): logger.debug("Looking for actions in " + name + ": " + str(module)) discover = importlib.import_module(name + ".discover") if mock_sigan and hasattr(discover, "test_actions"): logger.debug(f"loading {len(discover.test_actions)} test actions.") actions.update(discover.test_actions) - # add scos-actions test_actions for scos-actions mock sigan - actions.update(test_actions) elif hasattr(discover, "actions"): logger.debug(f"loading {len(discover.actions)} actions.") actions.update(discover.actions) @@ -116,10 +119,15 @@ def load_actions( ): action_classes.update(discover.action_classes) + # load scos-sensor configs/actions logger.debug(f"Loading actions in {action_dir}") yaml_actions, yaml_test_actions = init( action_classes=action_classes, yaml_dir=action_dir ) + if mock_sigan: + actions.update(yaml_test_actions) + else: + actions.update(yaml_actions) actions.update(yaml_actions) - logger.debug("Finished loading and registering actions") + logger.debug("Finished loading and registering actions") return actions diff --git a/src/initialization/sensor_loader.py b/src/initialization/sensor_loader.py index 4f7dc8a9..49f73d6b 100644 --- a/src/initialization/sensor_loader.py +++ b/src/initialization/sensor_loader.py @@ -75,7 +75,10 @@ def load_sensor( gps_module_setting = settings.GPS_MODULE gps_module = importlib.import_module(gps_module_setting) logger.info( - "Creating " + settings.GPS_CLASS + " from " + settings.GPS_MODULE + "Creating " + + settings.GPS_CLASS + + " from " + + settings.GPS_MODULE ) gps_constructor = getattr(gps_module, settings.GPS_CLASS) gps = gps_constructor() diff --git a/src/status/views.py b/src/status/views.py index 64a5c313..c64b2789 100644 --- a/src/status/views.py +++ b/src/status/views.py @@ -70,7 +70,7 @@ def get_software_version(): if sensor_loader.sensor.signal_analyzer.plugin_version is not None: software_version["scos_sigan_plugin"] = { "name": sensor_loader.sensor.signal_analyzer.plugin_name, - "version": sensor_loader.sensor.signal_analyzer.plugin_version + "version": sensor_loader.sensor.signal_analyzer.plugin_version, } logger.debug(software_version) From 6c73123064bd522dba5dc0114bd029be87aba93b Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Mon, 8 Apr 2024 15:43:03 -0600 Subject: [PATCH 09/16] separate gps loading from sigan loading in sensor_loader --- src/initialization/sensor_loader.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/initialization/sensor_loader.py b/src/initialization/sensor_loader.py index 49f73d6b..c0eba4ce 100644 --- a/src/initialization/sensor_loader.py +++ b/src/initialization/sensor_loader.py @@ -70,18 +70,6 @@ def load_sensor( sigan_constructor = getattr(sigan_module, settings.SIGAN_CLASS) sigan = sigan_constructor(switches=switches) register_component_with_status.send(sigan, component=sigan) - - if settings.GPS_MODULE and settings.GPS_CLASS: - gps_module_setting = settings.GPS_MODULE - gps_module = importlib.import_module(gps_module_setting) - logger.info( - "Creating " - + settings.GPS_CLASS - + " from " - + settings.GPS_MODULE - ) - gps_constructor = getattr(gps_module, settings.GPS_CLASS) - gps = gps_constructor() else: logger.warning("Required USB Device does not exist.") else: @@ -90,6 +78,20 @@ def load_sensor( logger.warning(f"unable to create signal analyzer: {ex}") set_container_unhealthy() + try: + if settings.GPS_MODULE and settings.GPS_CLASS: + gps_module_setting = settings.GPS_MODULE + gps_module = importlib.import_module(gps_module_setting) + logger.info( + "Creating " + settings.GPS_CLASS + " from " + settings.GPS_MODULE + ) + gps_constructor = getattr(gps_module, settings.GPS_CLASS) + gps = gps_constructor() + else: + logger.info("GPS_MODULE and/or GPS_CLASS not specified. Not loading GPS.") + except BaseException as ex: + logger.warning(f"unable to create GPS: {ex}") + # Create sensor before handling calibrations sensor = Sensor( signal_analyzer=sigan, From 0e823790c06c689073f44a088f17f91302db8852 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Thu, 11 Apr 2024 10:20:32 -0600 Subject: [PATCH 10/16] remove "clock_rate_lookup_by_sample_rate" from readme example --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 484caf8a..fafb58b9 100644 --- a/README.md +++ b/README.md @@ -477,7 +477,6 @@ level setting of -25. "frequency", "reference_level" ], - "clock_rate_lookup_by_sample_rate": [], "calibration_data": { "14000000.0": { "3545000000.0": { From 0ac1f8efeee89a47984ea8fced40b8a371098df0 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Tue, 16 Apr 2024 10:22:18 -0600 Subject: [PATCH 11/16] fix bug in action loader --- src/initialization/action_loader.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/initialization/action_loader.py b/src/initialization/action_loader.py index 9ba65fc6..6b06c966 100644 --- a/src/initialization/action_loader.py +++ b/src/initialization/action_loader.py @@ -128,6 +128,5 @@ def load_actions( actions.update(yaml_test_actions) else: actions.update(yaml_actions) - actions.update(yaml_actions) logger.debug("Finished loading and registering actions") return actions From 039aa4a2188c318a63c6948dc939424d6513c331 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Fri, 26 Apr 2024 13:55:18 -0600 Subject: [PATCH 12/16] In tests replace logger action with test_monitor_sigan, update scos-actions branch, remove logger action from openapi.json --- docs/openapi.json | 1 - src/requirements-dev.txt | 2 +- src/requirements.txt | 2 +- src/schedule/tests/test_models.py | 42 ++++---- src/schedule/tests/test_serializers.py | 132 +++++++++++++++---------- src/schedule/tests/utils.py | 6 +- src/scheduler/tests/test_scheduler.py | 42 ++++---- 7 files changed, 130 insertions(+), 97 deletions(-) diff --git a/docs/openapi.json b/docs/openapi.json index 58cf9ab7..2d860ebd 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1644,7 +1644,6 @@ "description": "[Required] The name of the action to be scheduled", "type": "string", "enum": [ - "logger", "test_SEA_CBRS_Measure_Baseline", "test_monitor_sigan", "test_multi_frequency_iq_action", diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index 4510d696..6626eb0b 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -313,7 +313,7 @@ scipy==1.10.1 # via # -r requirements.txt # scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading +scos-actions @ git+https://github.com/NTIA/scos-actions@revert-117-revert-110-SEA-178_test_actions_loading # via # -r requirements.txt # scos-tekrsa diff --git a/src/requirements.txt b/src/requirements.txt index 985445a7..c9b8f86d 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -149,7 +149,7 @@ ruamel-yaml-clib==0.2.8 # via ruamel-yaml scipy==1.10.1 # via scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@SEA-178_test_actions_loading +scos-actions @ git+https://github.com/NTIA/scos-actions@revert-117-revert-110-SEA-178_test_actions_loading # via scos-tekrsa scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.in diff --git a/src/schedule/tests/test_models.py b/src/schedule/tests/test_models.py index 4a8ed861..a16631c3 100644 --- a/src/schedule/tests/test_models.py +++ b/src/schedule/tests/test_models.py @@ -17,7 +17,7 @@ def test_take_until(test_input, future_t, expected): start, stop, interval = test_input entry = ScheduleEntry( - name="t", start=start, stop=stop, interval=interval, action="logger" + name="t", start=start, stop=stop, interval=interval, action="test_monitor_sigan" ) initial_times = list(entry.get_remaining_times()) r = [] @@ -32,32 +32,36 @@ def test_take_until(test_input, future_t, expected): def test_undefined_start_is_now(): - entry = ScheduleEntry(name="t", action="logger") + entry = ScheduleEntry(name="t", action="test_monitor_sigan") now = utils.timefn() assert entry.start in (now - 1, now, now + 1) def test_undefined_stop_is_never(): - entry = ScheduleEntry(name="t", action="logger", interval=1) + entry = ScheduleEntry(name="t", action="test_monitor_sigan", interval=1) assert entry.stop is None assert type(entry.get_remaining_times()) is itertools.count def test_relative_stop_becomes_absolute(): - e = ScheduleEntry(name="t", start=20, relative_stop=10, interval=1, action="logger") + e = ScheduleEntry( + name="t", start=20, relative_stop=10, interval=1, action="test_monitor_sigan" + ) assert e.start == 20 assert e.stop == 30 assert list(e.get_remaining_times()) == list(range(20, 30, 1)) def test_stop_before_start(): - e = ScheduleEntry(name="t", start=20, stop=10, interval=1, action="logger") + e = ScheduleEntry( + name="t", start=20, stop=10, interval=1, action="test_monitor_sigan" + ) assert list(e.get_remaining_times()) == list(range(0)) def test_no_interval_is_one_shot(): """Leaving `interval` blank should indicate "one-shot" entry.""" - e = ScheduleEntry(name="t", action="logger") + e = ScheduleEntry(name="t", action="test_monitor_sigan") remaining_times = list(e.get_remaining_times()) assert len(remaining_times) == 1 @@ -72,7 +76,7 @@ def test_no_interval_is_one_shot(): def test_no_interval_with_start_is_one_shot(): """Specifying start should not affect number of times.""" - e = ScheduleEntry(name="t", action="logger", start=1) + e = ScheduleEntry(name="t", action="test_monitor_sigan", start=1) remaining_times = list(e.get_remaining_times()) assert len(remaining_times) == 1 @@ -88,17 +92,19 @@ def test_no_interval_with_start_is_one_shot(): def test_no_interval_future_start(testclock): """One-shot entry should wait for start.""" # recall current t=0 so start=1 is 1 second in the future - e = ScheduleEntry(name="t", action="logger", start=1) + e = ScheduleEntry(name="t", action="test_monitor_sigan", start=1) assert not e.take_pending() def test_bad_interval_raises(): with pytest.raises(ValidationError): - ScheduleEntry(name="t", interval=-1, action="logger").clean_fields() + ScheduleEntry(name="t", interval=-1, action="test_monitor_sigan").clean_fields() with pytest.raises(ValidationError): - ScheduleEntry(name="t", interval=0, action="logger").clean_fields() + ScheduleEntry(name="t", interval=0, action="test_monitor_sigan").clean_fields() with pytest.raises(ValidationError): - ScheduleEntry(name="t", interval=0.1, action="logger").clean_fields() + ScheduleEntry( + name="t", interval=0.1, action="test_monitor_sigan" + ).clean_fields() def test_bad_action_raises(): @@ -108,22 +114,22 @@ def test_bad_action_raises(): def test_bad_name_raises(): with pytest.raises(ValidationError): # whitespace - ScheduleEntry(name="test 1", action="logger").clean_fields() + ScheduleEntry(name="test 1", action="test_monitor_sigan").clean_fields() with pytest.raises(ValidationError): # punctuation other than "_-" - ScheduleEntry(name="test1!", action="logger").clean_fields() + ScheduleEntry(name="test1!", action="test_monitor_sigan").clean_fields() # ok - ScheduleEntry(name="_test-Stuff123", action="logger").clean_fields() + ScheduleEntry(name="_test-Stuff123", action="test_monitor_sigan").clean_fields() def test_non_unique_name_raises(user): - ScheduleEntry(name="t", action="logger", owner=user).save() + ScheduleEntry(name="t", action="test_monitor_sigan", owner=user).save() with pytest.raises(ValidationError): - ScheduleEntry(name="t", action="logger", owner=user).full_clean() + ScheduleEntry(name="t", action="test_monitor_sigan", owner=user).full_clean() def test_defaults(): - entry = ScheduleEntry(name="t", action="logger") + entry = ScheduleEntry(name="t", action="test_monitor_sigan") assert entry.priority == DEFAULT_PRIORITY assert entry.start is not None assert entry.stop is None @@ -132,4 +138,4 @@ def test_defaults(): def test_str(): - str(ScheduleEntry(name="t", action="logger")) + str(ScheduleEntry(name="t", action="test_monitor_sigan")) diff --git a/src/schedule/tests/test_serializers.py b/src/schedule/tests/test_serializers.py index e7d0aa25..ce26fecc 100644 --- a/src/schedule/tests/test_serializers.py +++ b/src/schedule/tests/test_serializers.py @@ -17,39 +17,51 @@ [ # A name and action should be the minimum acceptable entry # i.e., (one-shot, ASAP) - {"name": "test", "action": "logger"}, + {"name": "test", "action": "test_monitor_sigan"}, # Stop 10 seconds after starting, start ASAP - {"name": "test", "action": "logger", "relative_stop": 10}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 10}, # Min integer interval ok - {"name": "test", "action": "logger", "interval": 10}, + {"name": "test", "action": "test_monitor_sigan", "interval": 10}, # Max priority ok - {"name": "test", "action": "logger", "priority": 19}, + {"name": "test", "action": "test_monitor_sigan", "priority": 19}, # Min user priority ok - {"name": "test", "action": "logger", "priority": 0}, + {"name": "test", "action": "test_monitor_sigan", "priority": 0}, # Stop 10 seconds after starting; start at absolute time { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25Z", "relative_stop": 10, }, # Start and stop at absolute time; equivalent to above { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25Z", "absolute_stop": "2018-03-16T17:12:35Z", }, # 'stop' and 'absolute_stop' are synonyms - {"name": "test", "action": "logger", "stop": "2018-03-16T17:12:35.0Z"}, + { + "name": "test", + "action": "test_monitor_sigan", + "stop": "2018-03-16T17:12:35.0Z", + }, # Subseconds are optional - {"name": "test", "action": "logger", "start": "2018-03-16T17:12:35Z"}, + { + "name": "test", + "action": "test_monitor_sigan", + "start": "2018-03-16T17:12:35Z", + }, # Sensor is timezone-aware - {"name": "test", "action": "logger", "start": "2018-03-22T13:53:25-06:00"}, + { + "name": "test", + "action": "test_monitor_sigan", + "start": "2018-03-22T13:53:25-06:00", + }, # All non-boolean, non-required fields accepts null to mean not defined { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": None, "absolute_stop": None, "relative_stop": None, @@ -60,7 +72,7 @@ "callback_url": None, }, # Explicit validate_only is valid - {"name": "test", "action": "logger", "validate_only": False}, + {"name": "test", "action": "test_monitor_sigan", "validate_only": False}, ], ) def test_valid_user_entries(entry_json, user): @@ -76,39 +88,51 @@ def test_valid_user_entries(entry_json, user): [ # A name and action should be the minimum acceptable entry # i.e., (one-shot, ASAP) - {"name": "test", "action": "logger"}, + {"name": "test", "action": "test_monitor_sigan"}, # Stop 10 seconds after starting, start ASAP - {"name": "test", "action": "logger", "relative_stop": 10}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 10}, # Min integer interval ok - {"name": "test", "action": "logger", "interval": 10}, + {"name": "test", "action": "test_monitor_sigan", "interval": 10}, # Max priority ok - {"name": "test", "action": "logger", "priority": 19}, + {"name": "test", "action": "test_monitor_sigan", "priority": 19}, # Min admin priority ok - {"name": "test", "action": "logger", "priority": -20}, + {"name": "test", "action": "test_monitor_sigan", "priority": -20}, # Stop 10 seconds after starting; start at absolute time { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25Z", "relative_stop": 10, }, # Start and stop at absolute time; equivalent to above { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25Z", "absolute_stop": "2018-03-16T17:12:35Z", }, # 'stop' and 'absolute_stop' are synonyms - {"name": "test", "action": "logger", "stop": "2018-03-16T17:12:35.0Z"}, + { + "name": "test", + "action": "test_monitor_sigan", + "stop": "2018-03-16T17:12:35.0Z", + }, # Subseconds are optional - {"name": "test", "action": "logger", "start": "2018-03-16T17:12:35Z"}, + { + "name": "test", + "action": "test_monitor_sigan", + "start": "2018-03-16T17:12:35Z", + }, # Sensor is timezone-aware - {"name": "test", "action": "logger", "start": "2018-03-22T13:53:25-06:00"}, + { + "name": "test", + "action": "test_monitor_sigan", + "start": "2018-03-22T13:53:25-06:00", + }, # All non-boolean, non-required fields accepts null to mean not defined { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": None, "absolute_stop": None, "relative_stop": None, @@ -119,9 +143,9 @@ def test_valid_user_entries(entry_json, user): "callback_url": None, }, # Explicit validate_only is valid - {"name": "test", "action": "logger", "validate_only": False}, + {"name": "test", "action": "test_monitor_sigan", "validate_only": False}, # Admin can create private entries - {"name": "test", "action": "logger"}, + {"name": "test", "action": "test_monitor_sigan"}, ], ) def test_valid_admin_entries(entry_json, user): @@ -136,44 +160,44 @@ def test_valid_admin_entries(entry_json, user): "entry_json", [ # name is a required field - {"action": "logger"}, + {"action": "test_monitor_sigan"}, # action is a required field {"name": "test"}, # non-integer priority - {"name": "test", "action": "logger", "priority": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "priority": 3.14}, # priority greater than max (19) - {"name": "test", "action": "logger", "priority": 20}, + {"name": "test", "action": "test_monitor_sigan", "priority": 20}, # non-integer interval - {"name": "test", "action": "logger", "interval": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "interval": 3.14}, # zero interval - {"name": "test", "action": "logger", "interval": 0}, + {"name": "test", "action": "test_monitor_sigan", "interval": 0}, # negative interval - {"name": "test", "action": "logger", "interval": -1}, + {"name": "test", "action": "test_monitor_sigan", "interval": -1}, # can't interpret both absolute and relative stop { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25.0Z", "absolute_stop": "2018-03-16T17:12:35.0Z", "relative_stop": 10, }, # 0 relative_stop - {"name": "test", "action": "logger", "relative_stop": 0}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 0}, # negative relative_stop - {"name": "test", "action": "logger", "relative_stop": -10}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": -10}, # non-integer relative_stop - {"name": "test", "action": "logger", "relative_stop": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 3.14}, # stop is before start { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:35Z", "stop": "2018-03-16T17:12:30Z", }, # stop is same as start { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:35Z", "stop": "2018-03-16T17:12:35Z", }, @@ -190,46 +214,46 @@ def test_invalid_user_entries(entry_json): "entry_json", [ # name is a required field - {"action": "logger"}, + {"action": "test_monitor_sigan"}, # action is a required field {"name": "test"}, # non-integer priority - {"name": "test", "action": "logger", "priority": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "priority": 3.14}, # priority less than min (for admin) - {"name": "test", "action": "logger", "priority": -21}, + {"name": "test", "action": "test_monitor_sigan", "priority": -21}, # priority greater than max (19) - {"name": "test", "action": "logger", "priority": 20}, + {"name": "test", "action": "test_monitor_sigan", "priority": 20}, # non-integer interval - {"name": "test", "action": "logger", "interval": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "interval": 3.14}, # zero interval - {"name": "test", "action": "logger", "interval": 0}, + {"name": "test", "action": "test_monitor_sigan", "interval": 0}, # negative interval - {"name": "test", "action": "logger", "interval": -1}, + {"name": "test", "action": "test_monitor_sigan", "interval": -1}, # can't interpret both absolute and relative stop { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:25.0Z", "absolute_stop": "2018-03-16T17:12:35.0Z", "relative_stop": 10, }, # 0 relative_stop - {"name": "test", "action": "logger", "relative_stop": 0}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 0}, # negative relative_stop - {"name": "test", "action": "logger", "relative_stop": -10}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": -10}, # non-integer relative_stop - {"name": "test", "action": "logger", "relative_stop": 3.14}, + {"name": "test", "action": "test_monitor_sigan", "relative_stop": 3.14}, # stop is before start { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:35Z", "stop": "2018-03-16T17:12:30Z", }, # stop is same as start { "name": "test", - "action": "logger", + "action": "test_monitor_sigan", "start": "2018-03-16T17:12:35Z", "stop": "2018-03-16T17:12:35Z", }, @@ -247,7 +271,9 @@ def test_invalid_admin_entries(entry_json): def test_serialized_fields(admin_client): """Certain fields on the schedule entry model should be serialized.""" - rjson = post_schedule(admin_client, {"name": "test", "action": "logger"}) + rjson = post_schedule( + admin_client, {"name": "test", "action": "test_monitor_sigan"} + ) # nullable fields assert "interval" in rjson @@ -274,6 +300,8 @@ def test_serialized_fields(admin_client): def test_non_serialized_fields(admin_client): """Certain fields on the schedule entry model should not be serialized.""" - rjson = post_schedule(admin_client, {"name": "test", "action": "logger"}) + rjson = post_schedule( + admin_client, {"name": "test", "action": "test_monitor_sigan"} + ) assert "relative_stop" not in rjson diff --git a/src/schedule/tests/utils.py b/src/schedule/tests/utils.py index ac8304be..3aa6b015 100644 --- a/src/schedule/tests/utils.py +++ b/src/schedule/tests/utils.py @@ -8,15 +8,15 @@ EMPTY_SCHEDULE_RESPONSE = [] -TEST_SCHEDULE_ENTRY = {"name": "test", "action": "logger"} +TEST_SCHEDULE_ENTRY = {"name": "test", "action": "test_monitor_sigan"} TEST_ALTERNATE_SCHEDULE_ENTRY = { "name": "test_alternate", - "action": "logger", + "action": "test_monitor_sigan", "priority": 5, } -TEST_PRIVATE_SCHEDULE_ENTRY = {"name": "test_private", "action": "logger"} +TEST_PRIVATE_SCHEDULE_ENTRY = {"name": "test_private", "action": "test_monitor_sigan"} def post_schedule(client, entry, expected_status=status.HTTP_201_CREATED): diff --git a/src/scheduler/tests/test_scheduler.py b/src/scheduler/tests/test_scheduler.py index 0dbede07..26577cf5 100644 --- a/src/scheduler/tests/test_scheduler.py +++ b/src/scheduler/tests/test_scheduler.py @@ -21,7 +21,7 @@ @pytest.mark.django_db def test_populate_queue(test_scheduler): """An entry in the schedule should be added to a read-only task queue.""" - create_entry("test", 1, 0, 5, 1, "logger") + create_entry("test", 1, 0, 5, 1, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) # now=0, so task with time 0 is run assert [e.time for e in s.task_queue] == [1, 2, 3, 4] @@ -32,8 +32,8 @@ def test_priority(test_scheduler): """A task with lower priority number should sort higher in task queue.""" lopri = 20 hipri = 10 - create_entry("lopri", lopri, 0, 5, 1, "logger") - create_entry("hipri", hipri, 0, 5, 1, "logger") + create_entry("lopri", lopri, 0, 5, 1, "test_monitor_sigan") + create_entry("hipri", hipri, 0, 5, 1, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) q = s.task_queue.to_list() @@ -45,7 +45,7 @@ def test_priority(test_scheduler): @pytest.mark.django_db def test_future_start(test_scheduler): """An entry with start time in future should remain in schedule.""" - create_entry("t", 1, 50, 100, 1, "logger") + create_entry("t", 1, 50, 100, 1, "test_monitor_sigan") test_scheduler.run(blocking=False) s = test_scheduler assert len(s.task_queue) == 0 @@ -75,11 +75,11 @@ def test_calls_actions(test_scheduler): @pytest.mark.django_db def test_add_entry(test_scheduler): """Creating a new entry instance adds it to the current schedule.""" - create_entry("t1", 10, 1, 100, 5, "logger") + create_entry("t1", 10, 1, 100, 5, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) advance_testclock(s.timefn, 49) - create_entry("t2", 20, 50, 300, 5, "logger") + create_entry("t2", 20, 50, 300, 5, "test_monitor_sigan") s.run(blocking=False) assert len(s.task_queue) == 20 assert s.task_queue[0].priority == 20 @@ -88,8 +88,8 @@ def test_add_entry(test_scheduler): @pytest.mark.django_db def test_remove_entry_by_delete(test_scheduler): """An entry is removed from schedule if it's deleted.""" - e1 = create_entry("t1", 10, 1, 300, 5, "logger") - e2 = create_entry("t2", 20, 50, 300, 5, "logger") + e1 = create_entry("t1", 10, 1, 300, 5, "test_monitor_sigan") + e2 = create_entry("t2", 20, 50, 300, 5, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) advance_testclock(s.timefn, 10) @@ -102,8 +102,8 @@ def test_remove_entry_by_delete(test_scheduler): @pytest.mark.django_db def test_remove_entry_by_cancel(test_scheduler): """scheduler.cancel removes an entry from schedule without deleting it.""" - e1 = create_entry("t1", 10, 1, 300, 5, "logger") - e2 = create_entry("t2", 20, 50, 300, 5, "logger") + e1 = create_entry("t1", 10, 1, 300, 5, "test_monitor_sigan") + e2 = create_entry("t2", 20, 50, 300, 5, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) advance_testclock(s.timefn, 10) @@ -116,7 +116,7 @@ def test_remove_entry_by_cancel(test_scheduler): @pytest.mark.django_db def test_start_stop(test_scheduler): """Calling stop on started scheduler thread should cause thread exit.""" - create_entry("t", 1, 1, 100, 5, "logger") + create_entry("t", 1, 1, 100, 5, "test_monitor_sigan") s = test_scheduler s.start() time.sleep(0.02) # hit minimum_duration @@ -130,7 +130,7 @@ def test_start_stop(test_scheduler): @pytest.mark.django_db def test_run_completes(test_scheduler): """The scheduler should return to idle state after schedule completes.""" - create_entry("t", 1, None, None, None, "logger") + create_entry("t", 1, None, None, None, "test_monitor_sigan") s = test_scheduler s.start() time.sleep(0.1) # hit minimum_duration @@ -159,7 +159,7 @@ def test_survives_failed_action(test_scheduler): @pytest.mark.django_db def test_compress_past_times(test_scheduler): """Multiple task times in the past should be compressed to one.""" - create_entry("t", 1, -10, 5, 1, "logger") + create_entry("t", 1, -10, 5, 1, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) # past times -10 through 0 are compressed and a single task is run, @@ -170,7 +170,7 @@ def test_compress_past_times(test_scheduler): @pytest.mark.django_db def test_compress_past_times_offset(test_scheduler): """Multiple task times in the past should be compressed to one.""" - create_entry("t", 1, -2, 14, 4, "logger") + create_entry("t", 1, -2, 14, 4, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) # past time -2 is run, then 2, 6, and 10 are queued @@ -182,7 +182,7 @@ def test_compress_past_times_offset(test_scheduler): @pytest.mark.django_db def test_next_task_time_value_when_start_changes(test_scheduler): """When an entry's start value changes, update `next_task_time`.""" - entry = create_entry("t", 1, 1, 10, 1, "logger") + entry = create_entry("t", 1, 1, 10, 1, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) assert entry.next_task_time == 1 @@ -218,7 +218,7 @@ def test_next_task_time_value_when_start_changes(test_scheduler): @pytest.mark.django_db def test_next_task_time_value_when_interval_changes(test_scheduler): """When an entry's interval value changes, update `next_task_time`.""" - entry = create_entry("t", 1, 1, 100, 1, "logger") + entry = create_entry("t", 1, 1, 100, 1, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) assert entry.next_task_time == 1 @@ -246,7 +246,7 @@ def test_next_task_time_value_when_interval_changes(test_scheduler): @pytest.mark.django_db def test_one_shot(test_scheduler): """If no start or interval given, entry should be run once and removed.""" - create_entry("t", 1, None, None, None, "logger") + create_entry("t", 1, None, None, None, "test_monitor_sigan") s = test_scheduler advance_testclock(s.timefn, 1) s.run(blocking=False) @@ -257,7 +257,7 @@ def test_one_shot(test_scheduler): @pytest.mark.django_db def test_task_queue(test_scheduler): """The scheduler should maintain a queue of upcoming tasks.""" - e = create_entry("t", 1, 1, 100, 5, "logger") + e = create_entry("t", 1, 1, 100, 5, "test_monitor_sigan") s = test_scheduler # upcoming tasks are queued @@ -282,7 +282,7 @@ def test_task_queue(test_scheduler): @pytest.mark.django_db def test_clearing_schedule_clears_task_queue(test_scheduler): """The scheduler should empty task_queue when schedule is deleted.""" - create_entry("t", 1, 1, 100, 5, "logger") + create_entry("t", 1, 1, 100, 5, "test_monitor_sigan") s = test_scheduler s.run(blocking=False) # queue first 10 tasks assert len(s.task_queue) == 10 @@ -416,7 +416,7 @@ def cb_request_handler(sess, resp): def test_notification_failed_status_unknown_host(test_scheduler): with requests_mock.Mocker() as m: callback_url = "https://results" - entry = create_entry("t", 1, 1, 100, 5, "logger", callback_url) + entry = create_entry("t", 1, 1, 100, 5, "test_monitor_sigan", callback_url) entry.save() token = entry.owner.auth_token m.post( @@ -437,7 +437,7 @@ def test_notification_failed_status_unknown_host(test_scheduler): @pytest.mark.django_db def test_notification_failed_status_request_ok_false(test_scheduler): - entry = create_entry("t", 1, 1, 100, 5, "logger") + entry = create_entry("t", 1, 1, 100, 5, "test_monitor_sigan") entry.save() entry.refresh_from_db() print("entry = " + entry.name) From ba07fe13822907fd077ea1d0f57a8385188786a5 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Mon, 29 Apr 2024 13:00:19 -0600 Subject: [PATCH 13/16] update requirements --- src/requirements-dev.txt | 2 +- src/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index 6626eb0b..32513a6f 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -313,7 +313,7 @@ scipy==1.10.1 # via # -r requirements.txt # scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@revert-117-revert-110-SEA-178_test_actions_loading +scos-actions @ git+https://github.com/NTIA/scos-actions@fix_test_cbrs_measure # via # -r requirements.txt # scos-tekrsa diff --git a/src/requirements.txt b/src/requirements.txt index c9b8f86d..e7469696 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -149,7 +149,7 @@ ruamel-yaml-clib==0.2.8 # via ruamel-yaml scipy==1.10.1 # via scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@revert-117-revert-110-SEA-178_test_actions_loading +scos-actions @ git+https://github.com/NTIA/scos-actions@fix_test_cbrs_measure # via scos-tekrsa scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.in From 30d32964467c930269098572036e94ca3b74023f Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Wed, 1 May 2024 14:47:14 -0600 Subject: [PATCH 14/16] remove oauthlib packages from requirements --- src/requirements-dev.txt | 9 +-------- src/requirements.in | 1 - src/requirements.txt | 7 +------ 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index 32513a6f..c1b16d90 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -182,10 +182,6 @@ numpy==1.24.4 # tekrsa-api-wrap nvidia-ml-py==12.535.133 # via gpustat -oauthlib==3.2.2 - # via - # -r requirements.txt - # requests-oauthlib opencensus==0.11.3 # via ray opencensus-context==0.1.3 @@ -289,11 +285,8 @@ requests==2.31.0 # its-preselector # ray # requests-mock - # requests-oauthlib requests-mock==1.11.0 # via -r requirements.txt -requests-oauthlib==1.3.1 - # via -r requirements.txt rpds-py==0.13.2 # via # -r requirements.txt @@ -313,7 +306,7 @@ scipy==1.10.1 # via # -r requirements.txt # scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@fix_test_cbrs_measure +scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 # via # -r requirements.txt # scos-tekrsa diff --git a/src/requirements.in b/src/requirements.in index a6643b74..e86fd5ae 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -10,7 +10,6 @@ jsonfield>=3.0, <4.0 packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 -requests_oauthlib>=1.0, <2.0 scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # The following are sub-dependencies for which SCOS Sensor enforces a diff --git a/src/requirements.txt b/src/requirements.txt index e7469696..09affb99 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -91,8 +91,6 @@ numpy==1.24.4 # scos-actions # sigmf # tekrsa-api-wrap -oauthlib==3.2.2 - # via requests-oauthlib packaging==23.2 # via # -r requirements.in @@ -134,11 +132,8 @@ requests==2.31.0 # its-preselector # ray # requests-mock - # requests-oauthlib requests-mock==1.11.0 # via -r requirements.in -requests-oauthlib==1.3.1 - # via -r requirements.in rpds-py==0.13.2 # via # jsonschema @@ -149,7 +144,7 @@ ruamel-yaml-clib==0.2.8 # via ruamel-yaml scipy==1.10.1 # via scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@fix_test_cbrs_measure +scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 # via scos-tekrsa scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading # via -r requirements.in From e817ddcccfb1ded71d07de51cace9969c469d15f Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Thu, 9 May 2024 10:56:00 -0600 Subject: [PATCH 15/16] update scos-tekrsa version --- src/requirements-dev.txt | 4 ++-- src/requirements.in | 2 +- src/requirements.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index c1b16d90..995d738f 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -310,7 +310,7 @@ scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 # via # -r requirements.txt # scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 # via -r requirements.txt sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via @@ -330,7 +330,7 @@ sqlparse==0.4.4 # via # -r requirements.txt # django -tekrsa-api-wrap==1.3.2 +tekrsa-api-wrap==1.3.3 # via # -r requirements.txt # scos-tekrsa diff --git a/src/requirements.in b/src/requirements.in index e86fd5ae..93d2a9d2 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -10,7 +10,7 @@ jsonfield>=3.0, <4.0 packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 -scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading +scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 # The following are sub-dependencies for which SCOS Sensor enforces a # higher minimum patch version than the dependencies which require them. diff --git a/src/requirements.txt b/src/requirements.txt index 09affb99..5057ede0 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -146,7 +146,7 @@ scipy==1.10.1 # via scos-actions scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 # via scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@SEA-178_test_actions_loading +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 # via -r requirements.in sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via scos-actions @@ -158,7 +158,7 @@ six==1.16.0 # sigmf sqlparse==0.4.4 # via django -tekrsa-api-wrap==1.3.2 +tekrsa-api-wrap==1.3.3 # via scos-tekrsa typing-extensions==4.8.0 # via asgiref From 39d6c812d19d88118c8e702a62192fcbaeb26183 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Wed, 15 May 2024 11:33:05 -0600 Subject: [PATCH 16/16] update scos-tekrsa to 7.0.1, scos-actions to 10.0.2 --- src/requirements-dev.txt | 4 ++-- src/requirements.in | 2 +- src/requirements.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/requirements-dev.txt b/src/requirements-dev.txt index 995d738f..b10ec7f7 100644 --- a/src/requirements-dev.txt +++ b/src/requirements-dev.txt @@ -306,11 +306,11 @@ scipy==1.10.1 # via # -r requirements.txt # scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 +scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.2 # via # -r requirements.txt # scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.1 # via -r requirements.txt sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via diff --git a/src/requirements.in b/src/requirements.in index 93d2a9d2..62399ff5 100644 --- a/src/requirements.in +++ b/src/requirements.in @@ -10,7 +10,7 @@ jsonfield>=3.0, <4.0 packaging>=23.0, <24.0 psycopg2-binary>=2.0, <3.0 requests-mock>=1.0, <2.0 -scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 +scos_tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.1 # The following are sub-dependencies for which SCOS Sensor enforces a # higher minimum patch version than the dependencies which require them. diff --git a/src/requirements.txt b/src/requirements.txt index 5057ede0..2959a014 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -144,9 +144,9 @@ ruamel-yaml-clib==0.2.8 # via ruamel-yaml scipy==1.10.1 # via scos-actions -scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.1 +scos-actions @ git+https://github.com/NTIA/scos-actions@10.0.2 # via scos-tekrsa -scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.0 +scos-tekrsa @ git+https://github.com/NTIA/scos-tekrsa@7.0.1 # via -r requirements.in sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive # via scos-actions