Skip to content

Commit

Permalink
test imports
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jul 19, 2024
1 parent 802b9cb commit dfa6264
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
10 changes: 6 additions & 4 deletions pioreactor/background_jobs/dosing_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions pioreactor/background_jobs/led_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]] = {}


Expand Down
6 changes: 4 additions & 2 deletions pioreactor/background_jobs/temperature_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pioreactor/tests/test_automation_imports.py
Original file line number Diff line number Diff line change
@@ -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
):
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit dfa6264

Please sign in to comment.