Skip to content

Commit

Permalink
don't fail hard when duplicate; testing requires that a HAT isnt present
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Dec 8, 2023
1 parent c12b671 commit 6b0df4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
4 changes: 2 additions & 2 deletions migration_scripts/export_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ echo "Starting export of all data. Don't run anything. The Pioreactor UI will be
# stop everything that might touch the database or config files...
pio kill --all-jobs > /dev/null
pio kill monitor mqtt_to_db_streaming watchdog
sudo systemctl stop lighttpd.service
sudo systemctl stop huey.service
sudo systemctl stop lighttpd.service || true
sudo systemctl stop huey.service || true

# check integrity, quickly
DB_CHECK=$(sqlite3 /home/pioreactor/.pioreactor/storage/pioreactor.sqlite "PRAGMA quick_check;")
Expand Down
21 changes: 4 additions & 17 deletions pioreactor/background_jobs/temperature_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ def __init__(
) -> None:
super().__init__(unit=unit, experiment=experiment)

if not hardware.is_HAT_present():
self.logger.error("Pioreactor HAT must be present.")
self.clean_up()
raise exc.HardwareNotFoundError("Pioreactor HAT must be present.")

if not hardware.is_heating_pcb_present():
self.logger.error("Heating PCB must be attached to Pioreactor HAT")
self.clean_up()
Expand Down Expand Up @@ -170,9 +165,7 @@ def __init__(
def seconds_since_last_active_heating() -> float:
with local_intermittent_storage("temperature_and_heating") as cache:
if "last_heating_timestamp" in cache:
return (
current_utc_datetime() - to_datetime(cache["last_heating_timestamp"])
).total_seconds()
return (current_utc_datetime() - to_datetime(cache["last_heating_timestamp"])).total_seconds()
else:
return 1_000_000

Expand Down Expand Up @@ -261,9 +254,7 @@ def set_automation(self, algo_metadata: TemperatureAutomation) -> None:
self.logger.debug(
"Bypassing changing automations, and just updating the setting on the existing Thermostat automation."
)
self.automation_job.set_target_temperature(
float(algo_metadata.args["target_temperature"])
)
self.automation_job.set_target_temperature(float(algo_metadata.args["target_temperature"]))
self.automation = algo_metadata
return

Expand Down Expand Up @@ -338,9 +329,7 @@ def _check_if_exceeds_max_temp(self, temp: float) -> float:
self._update_heater(0)

if self.automation_name != "only_record_temperature":
self.set_automation(
TemperatureAutomation(automation_name="only_record_temperature")
)
self.set_automation(TemperatureAutomation(automation_name="only_record_temperature"))

elif temp > self.MAX_TEMP_TO_REDUCE_HEATING:
self.logger.debug(
Expand Down Expand Up @@ -594,9 +583,7 @@ def click_temperature_control(ctx, automation_name: str) -> None:

os.nice(1)

kwargs = {
ctx.args[i][2:].replace("-", "_"): ctx.args[i + 1] for i in range(0, len(ctx.args), 2)
}
kwargs = {ctx.args[i][2:].replace("-", "_"): ctx.args[i + 1] for i in range(0, len(ctx.args), 2)}
if "skip_first_run" in kwargs:
del kwargs["skip_first_run"]

Expand Down
8 changes: 3 additions & 5 deletions pioreactor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_config() -> ConfigParserMod:
and `od_config.photodiode_channel_reverse`
"""
config = ConfigParserMod()
config = ConfigParserMod(strict=False)
from pioreactor.whoami import is_testing_env

if is_testing_env():
Expand Down Expand Up @@ -150,17 +150,15 @@ def get_config() -> ConfigParserMod:
raise e
except configparser.DuplicateSectionError as e:
print(e)
raise e
pass

# some helpful additions - see docs above
if "leds" in config:
config["leds_reverse"] = config.invert_section("leds")
if "PWM" in config:
config["PWM_reverse"] = config.invert_section("PWM")
if "od_config.photodiode_channel" in config:
config["od_config.photodiode_channel_reverse"] = config.invert_section(
"od_config.photodiode_channel"
)
config["od_config.photodiode_channel_reverse"] = config.invert_section("od_config.photodiode_channel")

return config

Expand Down

0 comments on commit 6b0df4f

Please sign in to comment.