Skip to content

Commit

Permalink
update scripts and fix cli #500
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed May 8, 2024
1 parent 70657c9 commit fa446a3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 13 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
- UI performance improvements.
- Upgraded to React 18
- Removed unused dependencies
- UI's code sections use syntax-highlighting and other nicer features for editing yaml and ini files.
- App performance improvements
- Upgrade paho-mqtt to 2.0
- faster `pio kill`
- faster startup from UI
- faster job start from UI
- fix `pio plugins` on workers


### 24.5.1

Expand Down
6 changes: 3 additions & 3 deletions pioreactor/actions/leader/experiment_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,12 @@ def execute_experiment_profile(profile_filename: str, experiment: str, dry_run:

else:
if dry_run:
logger.notice( # type: ignore
logger.info( # type: ignore
f"Finished executing DRY-RUN of profile {profile.experiment_profile_name}."
)

else:
logger.notice(f"Finished executing profile {profile.experiment_profile_name}.") # type: ignore
logger.info(f"Finished executing profile {profile.experiment_profile_name}.") # type: ignore

state.mqtt_client.publish(
f"pioreactor/{unit}/{experiment}/{action_name}/experiment_profile_name",
Expand Down Expand Up @@ -711,7 +711,7 @@ def click_experiment_profile():
@click.argument("filename", type=click.Path())
@click.argument("experiment", type=str)
@click.option("--dry-run", is_flag=True, help="Don't actually execute, just print to screen")
def click_execute_experiment_profile(filename: str, experiment, dry_run: bool) -> None:
def click_execute_experiment_profile(filename: str, experiment: str, dry_run: bool) -> None:
"""
(leader only) Run an experiment profile.
"""
Expand Down
6 changes: 4 additions & 2 deletions pioreactor/background_jobs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def check_heater_pcb_temperature(self) -> None:
from TMP1075 import TMP1075 # type: ignore
except ImportError:
# leader-only is a worker?
self.logger.warning(
self.logger.debug(
f"{self.unit} doesn't have TMP1075 software installed, but is acting as a worker."
)
return
Expand All @@ -390,7 +390,7 @@ def check_heater_pcb_temperature(self) -> None:
tmp_driver = TMP1075(address=TEMP)
except ValueError:
# No PCB detected using i2c - fine to exit.
self.logger.warning("Heater PCB is not detected.")
self.logger.debug("Heater PCB is not detected.")
return

observed_tmp = tmp_driver.get_temperature()
Expand Down Expand Up @@ -645,6 +645,8 @@ def run_job_on_machine(self, msg: MQTTMessage) -> None:
# make sure I'm assigned to the correct experiment
if experiment != assigned_experiment:
return
else:
assigned_experiment = whoami.UNIVERSAL_EXPERIMENT

payload = loads(msg.payload) if msg.payload else {"options": {}, "args": []}

Expand Down
7 changes: 4 additions & 3 deletions pioreactor/cli/pio.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@

if am_I_leader():
lazy_subcommands = {
"run": "pioreactor.cli.run.run",
"workers": "pioreactor.cli.workers.workers",
"run": "pioreactor.cli.run.run",
"plugins": "pioreactor.cli.plugins.plugins",
}
else:
lazy_subcommands = {
"run": "pioreactor.cli.run.run",
"plugins": "pioreactor.cli.plugins.plugins",
}


Expand Down Expand Up @@ -190,12 +191,12 @@ def version(verbose: bool) -> None:
from pioreactor.version import tuple_to_text
from pioreactor.version import get_firmware_version
from pioreactor.version import rpi_version_info
from pioreactor.version import get_product_from_id
from pioreactor.whoami import get_pioreactor_model_and_version

click.echo(f"Pioreactor software: {tuple_to_text(software_version_info)}")
click.echo(f"Pioreactor HAT: {tuple_to_text(hardware_version_info)}")
click.echo(f"Pioreactor firmware: {tuple_to_text(get_firmware_version())}")
click.echo(f"Model name: {get_product_from_id()}")
click.echo(f"Model name: {get_pioreactor_model_and_version()}")
click.echo(f"HAT serial number: {serial_number}")
click.echo(f"Operating system: {platform.platform()}")
click.echo(f"Raspberry Pi: {rpi_version_info}")
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/experiment_profiles/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def expr(self, p) -> bool | float | str:
return convert_string(value)

else:
raise ValueError(f"{p.UNIT_JOB_SETTING} does not exist for experiment {experiment}")
raise ValueError(f"{p.UNIT_JOB_SETTING} does not exist for experiment `{experiment}`")


def parse_profile_expression_to_bool(profile_string: str) -> bool:
Expand Down
6 changes: 5 additions & 1 deletion pioreactor/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,16 @@ def get_pioreactor_version() -> tuple[int, int]:


@cache
def get_pioreactor_model() -> tuple[str, str]:
def get_pioreactor_model() -> str:
from pioreactor.config import config

return config.get("pioreactor", "model")


def get_pioreactor_model_and_version() -> str:
return f"{get_pioreactor_model()} v{'.'.join(map(str, get_pioreactor_version()))}"


def get_image_git_hash() -> str:
try:
with open("/home/pioreactor/.pioreactor/.image_info") as f:
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_leader.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ flask==3.0.0
flup6==1.1.1
python-dotenv==1.0.0
huey==2.5.0
werkzeug==3.0.1
werkzeug==3.0.3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"flup6==1.1.1",
"python-dotenv==1.0.0",
"huey==2.5.0",
"werkzeug==3.0.1",
"werkzeug==3.0.3",
]


Expand Down
23 changes: 23 additions & 0 deletions update_scripts/upcoming/pre_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -xeu


export LC_ALL=C

# Lower bound version
min_version="24.5.1"

# Get the current version of pio
current_version=$(sudo -u pioreactor pio version)

# Use sorting to determine if the current version is less than the minimum version
is_valid=$(printf "%s\n%s" "$current_version" "$min_version" | sort -V | head -n1)

# If the smallest version isn't the minimum version, then current version is too low
if [ "$is_valid" != "$min_version" ]; then
sudo -u pioreactor pio log -l ERROR -m "Version error: installed version $current_version is lower than the minimum required version $min_version."
exit 1
fi

echo "Version check passed: $current_version"

0 comments on commit fa446a3

Please sign in to comment.