Skip to content

Commit

Permalink
updateS
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Dec 14, 2023
1 parent c1afa7f commit 3242594
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pioreactor/background_jobs/stirring.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def start_stirring(self) -> None:
def kick_stirring(self) -> None:
self.logger.debug("Kicking stirring")
self.set_duty_cycle(100)
sleep(0.20)
sleep(0.10)
self.set_duty_cycle(
max(1.01 * self._previous_duty_cycle, 60)
) # DC should never be above 60. We want to avoid the death spiral to 100%.
) # DC should never need to be above 60 - simply not realistic. We want to avoid the death spiral to 100%.

def kick_stirring_but_avoid_od_reading(self) -> None:
"""
Expand Down
17 changes: 11 additions & 6 deletions pioreactor/cli/pio.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,8 @@ def update_app(
version_installed = source
commands_and_priority.append((f"sudo pip3 install --force-reinstall --no-index {source}", 1))
else:
raise click.Abort(
"Not a valid source file. Should be either a whl or release archive."
) # TODO: this doesn't print any message on error...
click.echo("Not a valid source file. Should be either a whl or release archive.")
raise click.Abort()

elif branch is not None:
cleaned_branch = quote(branch)
Expand All @@ -526,6 +525,12 @@ def update_app(
release_metadata = loads(response.body)
version_installed = release_metadata["tag_name"]
found_whl = False

# nuke all existing assets in /tmp
# TODO: just make a new tempdir, put all files there, and then nuke that temp dir......
# BETTER TODO: just download the release archive and run the script above.....
commands_and_priority.append(("rm -f /tmp/*update.sh /tmp/update.sql", -1))

for asset in release_metadata["assets"]:
# add the following files to the release. They should ideally be idempotent!

Expand All @@ -534,8 +539,6 @@ def update_app(
# update.sh runs (if exists)
# update.sql to update sqlite schema runs (if exists)
# post_update.sh runs (if exists)

# TODO: potential supply chain attack is to add malicious assets to releases
url = asset["browser_download_url"]
asset_name = asset["name"]

Expand Down Expand Up @@ -600,7 +603,9 @@ def update_app(
@click.option("-v", "--version", help="install a specific version, default is latest")
def update_firmware(version: Optional[str]) -> None:
"""
Update the RP2040 firmware
Update the RP2040 firmware.
# TODO: this needs accept a --source arg
"""
logger = create_logger("update-app", unit=whoami.get_unit_name(), experiment=whoami.UNIVERSAL_EXPERIMENT)
commands_and_priority: list[tuple[str, int]] = []
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/tests/test_dosing_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ def test_warning_is_logged_if_under_remove_waste() -> None:
experiment = "test_warning_is_logged_if_under_remove_waste"

class BadWasteRemoval(DosingAutomationJob):
automation_name = "bad_waste_removal"
automation_name = "_test_bad_waste_removal"

def remove_waste_from_bioreactor(self, unit, experiment, ml, source_of_event, mqtt_client):
return ml / 2
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_hardware_version() -> tuple[int, int] | tuple[int, int, str]:
text = f.read().rstrip("\x00")
return (int(text[-2]), int(text[-1]))
except FileNotFoundError:
# no eeprom? Probably dev board with no EEPROM, or testing env, or EEPROM not written.
# no eeprom? Probably dev board with no EEPROM, or testing env, or EEPROM not written, or cable exists between HAT and Pi -> signal degradation.
return (0, 0)


Expand Down
9 changes: 8 additions & 1 deletion update_scripts/23.12.11/update.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash

set -x
set -e

export LC_ALL=C

# Get the directory where the script is located
SCRIPT_DIR=$(dirname "$0")

# Attempt to download update_ui.sh
if ! wget -O "${SCRIPT_DIR}/update_ui.sh" https://github.com/Pioreactor/pioreactor/releases/download/23.12.11/update_ui.sh; then
echo "Failed to download update_ui.sh"
fi

# Ensure the script is executable
chmod +x "${SCRIPT_DIR}/update_ui.sh"

# Copy update_ui.sh from the script's directory
sudo cp "${SCRIPT_DIR}/update_ui.sh" /usr/local/bin/
1 change: 0 additions & 1 deletion update_scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Possible update scripts and their sequence:
- `post_update.sh` runs (if exists). Useful for restarting jobs, or rebooting RPis.



It's very important that update scripts are idempotent. Some tips:

- Use ChatGPT to assist psuedo-check if a script is idempotent, or making suggestions.
Expand Down

0 comments on commit 3242594

Please sign in to comment.