Skip to content

Commit

Permalink
add try except logic for ffindhing automations
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jul 10, 2024
1 parent 0483a2c commit 85d2b78
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
7 changes: 0 additions & 7 deletions pioreactor/automations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

# from . import dosing
# from . import events
# from . import led
# from . import temperature
1 change: 0 additions & 1 deletion pioreactor/background_jobs/dosing_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions pioreactor/background_jobs/led_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions pioreactor/background_jobs/temperature_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 85d2b78

Please sign in to comment.