From 85d2b78ab6f995c87cb192c22157bdd91fefb67d Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Wed, 10 Jul 2024 15:10:56 -0400 Subject: [PATCH] add try except logic for ffindhing automations --- pioreactor/automations/__init__.py | 7 ------- pioreactor/background_jobs/dosing_automation.py | 1 - pioreactor/background_jobs/led_automation.py | 8 ++++++-- pioreactor/background_jobs/temperature_automation.py | 8 ++++++-- setup.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pioreactor/automations/__init__.py b/pioreactor/automations/__init__.py index 834a5acd8..e69de29bb 100644 --- a/pioreactor/automations/__init__.py +++ b/pioreactor/automations/__init__.py @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import annotations - -# from . import dosing -# from . import events -# from . import led -# from . import temperature diff --git a/pioreactor/background_jobs/dosing_automation.py b/pioreactor/background_jobs/dosing_automation.py index b12fe3f02..58d0821ff 100644 --- a/pioreactor/background_jobs/dosing_automation.py +++ b/pioreactor/background_jobs/dosing_automation.py @@ -736,7 +736,6 @@ def start_dosing_automation( experiment: Optional[str] = None, **kwargs, ) -> DosingAutomationJob: - # TODO: find the automation class from automation_name, set it to klass unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) klass = available_dosing_automations[automation_name] diff --git a/pioreactor/background_jobs/led_automation.py b/pioreactor/background_jobs/led_automation.py index dec6a4a64..6e8920368 100644 --- a/pioreactor/background_jobs/led_automation.py +++ b/pioreactor/background_jobs/led_automation.py @@ -324,10 +324,14 @@ def start_led_automation( experiment: Optional[str] = None, **kwargs, ) -> LEDAutomationJob: - # TODO: find the automation class from automation_name, set it to klass unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) - klass = available_led_automations[automation_name] + try: + klass = available_led_automations[automation_name] + except KeyError: + raise KeyError( + f"Unable to find {automation_name}. Available automations are {list(available_led_automations.keys())}" + ) return klass( unit=unit, diff --git a/pioreactor/background_jobs/temperature_automation.py b/pioreactor/background_jobs/temperature_automation.py index 423ab4fc0..ada9e1fb0 100644 --- a/pioreactor/background_jobs/temperature_automation.py +++ b/pioreactor/background_jobs/temperature_automation.py @@ -675,10 +675,14 @@ def start_temperature_automation( experiment: Optional[str] = None, **kwargs, ) -> TemperatureAutomationJob: - # TODO: find the automation class from automation_name, set it to klass unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) - klass = available_temperature_automations[automation_name] + try: + klass = available_temperature_automations[automation_name] + except KeyError: + raise KeyError( + f"Unable to find {automation_name}. Available automations are {list( available_temperature_automations.keys())}" + ) if "skip_first_run" in kwargs: del kwargs["skip_first_run"] diff --git a/setup.py b/setup.py index ab1d6ca1e..d5cb88cb4 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ LEADER_REQUIREMENTS = [ "blinker==1.8.2", - "Flask==3.0.2", + "flask==3.0.2", "flup6==1.1.1", "huey==2.5.0", "ifaddr==0.2.0",