diff --git a/pioreactor/background_jobs/dosing_automation.py b/pioreactor/background_jobs/dosing_automation.py index afa5e8ab..f03fdc14 100644 --- a/pioreactor/background_jobs/dosing_automation.py +++ b/pioreactor/background_jobs/dosing_automation.py @@ -684,15 +684,17 @@ def start_dosing_automation( experiment: Optional[str] = None, **kwargs, ) -> DosingAutomationJob: + from pioreactor.automations import dosing # noqa: F401 + unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) try: klass = available_dosing_automations[automation_name] - except: + except KeyError: raise KeyError( f"Unable to find {automation_name}. Available automations are {list( available_dosing_automations.keys())}" ) - + try: return klass( unit=unit, @@ -702,9 +704,9 @@ def start_dosing_automation( duration=duration, **kwargs, ) - + except Exception as e: - logger = create_logger("dosing_automation") + logger = create_logger("dosing_automation") logger.error(f"Error: {e}") logger.debug(e, exc_info=True) raise e diff --git a/pioreactor/background_jobs/led_automation.py b/pioreactor/background_jobs/led_automation.py index f707706a..6493ade4 100644 --- a/pioreactor/background_jobs/led_automation.py +++ b/pioreactor/background_jobs/led_automation.py @@ -287,6 +287,8 @@ def start_led_automation( experiment: Optional[str] = None, **kwargs, ) -> LEDAutomationJob: + from pioreactor.automations import led # noqa: F401 + unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) try: @@ -305,13 +307,14 @@ def start_led_automation( duration=duration, **kwargs, ) - + except Exception as e: - logger = create_logger("led_automation") + logger = create_logger("led_automation") logger.error(f"Error: {e}") logger.debug(e, exc_info=True) raise e + available_led_automations: dict[str, type[LEDAutomationJob]] = {} diff --git a/pioreactor/background_jobs/temperature_automation.py b/pioreactor/background_jobs/temperature_automation.py index ae584a11..fb3e1913 100644 --- a/pioreactor/background_jobs/temperature_automation.py +++ b/pioreactor/background_jobs/temperature_automation.py @@ -634,6 +634,8 @@ def start_temperature_automation( experiment: Optional[str] = None, **kwargs, ) -> TemperatureAutomationJob: + from pioreactor.automations import temperature # noqa: F401 + unit = unit or whoami.get_unit_name() experiment = experiment or whoami.get_assigned_experiment_name(unit) try: @@ -653,9 +655,9 @@ def start_temperature_automation( automation_name=automation_name, **kwargs, ) - + except Exception as e: - logger = create_logger("temperature_automation") + logger = create_logger("temperature_automation") logger.error(f"Error: {e}") logger.debug(e, exc_info=True) raise e diff --git a/pioreactor/tests/test_automation_imports.py b/pioreactor/tests/test_automation_imports.py index 1409ca3d..be0f8119 100644 --- a/pioreactor/tests/test_automation_imports.py +++ b/pioreactor/tests/test_automation_imports.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- -# test_automation_imports from __future__ import annotations -from pioreactor.background_jobs.temperature_automation import start_temperature_automation - def test_start_temperature_automation() -> None: import importlib importlib.invalidate_caches() + + from pioreactor.background_jobs.temperature_automation import start_temperature_automation + with start_temperature_automation( "thermostat", "test", "test_start_temperature_automation", target_temperature=30 ): diff --git a/pioreactor/version.py b/pioreactor/version.py index ce6ac502..745b72f3 100644 --- a/pioreactor/version.py +++ b/pioreactor/version.py @@ -7,7 +7,7 @@ # Append ".dev0" if a dev version # Append "rc0" if a rc version # No zero padding! -__version__ = "24.7.18" +__version__ = "24.7.18.dev0" def get_hardware_version() -> tuple[int, int] | tuple[int, int, str]: