Skip to content

Commit

Permalink
error message for automations
Browse files Browse the repository at this point in the history
  • Loading branch information
kellytr committed Jul 17, 2024
1 parent ba50c6d commit c980f69
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 24 deletions.
26 changes: 17 additions & 9 deletions pioreactor/background_jobs/dosing_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pioreactor.automations import events
from pioreactor.automations.base import AutomationJob
from pioreactor.config import config
from pioreactor.logging import create_logger
from pioreactor.utils import is_pio_job_running
from pioreactor.utils import local_persistant_storage
from pioreactor.utils import SummableDict
Expand Down Expand Up @@ -691,15 +692,22 @@ def start_dosing_automation(
raise KeyError(
f"Unable to find {automation_name}. Available automations are {list( available_dosing_automations.keys())}"
)

return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
skip_first_run=skip_first_run,
duration=duration,
**kwargs,
)

try:
return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
skip_first_run=skip_first_run,
duration=duration,
**kwargs,
)

except Exception as e:
logger = create_logger("dosing_automation")
logger.error(f"Error: {e}")
logger.debug(e, exc_info=True)
raise e


available_dosing_automations: dict[str, type[DosingAutomationJob]] = {}
Expand Down
25 changes: 16 additions & 9 deletions pioreactor/background_jobs/led_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pioreactor.automations import events
from pioreactor.automations.base import AutomationJob
from pioreactor.config import config
from pioreactor.logging import create_logger
from pioreactor.utils import is_pio_job_running
from pioreactor.utils import whoami
from pioreactor.utils.timing import current_utc_datetime
Expand Down Expand Up @@ -295,15 +296,21 @@ def start_led_automation(
f"Unable to find {automation_name}. Available automations are {list(available_led_automations.keys())}"
)

return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
skip_first_run=skip_first_run,
duration=duration,
**kwargs,
)

try:
return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
skip_first_run=skip_first_run,
duration=duration,
**kwargs,
)

except Exception as e:
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
20 changes: 14 additions & 6 deletions pioreactor/background_jobs/temperature_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pioreactor import types as pt
from pioreactor.automations.base import AutomationJob
from pioreactor.config import config
from pioreactor.logging import create_logger
from pioreactor.structs import Temperature
from pioreactor.utils import clamp
from pioreactor.utils import is_pio_job_running
Expand Down Expand Up @@ -645,12 +646,19 @@ def start_temperature_automation(
if "skip_first_run" in kwargs:
del kwargs["skip_first_run"]

return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
**kwargs,
)
try:
return klass(
unit=unit,
experiment=experiment,
automation_name=automation_name,
**kwargs,
)

except Exception as e:
logger = create_logger("temperature_automation")
logger.error(f"Error: {e}")
logger.debug(e, exc_info=True)
raise e


available_temperature_automations: dict[str, type[TemperatureAutomationJob]] = {}
Expand Down

0 comments on commit c980f69

Please sign in to comment.