Skip to content

Commit

Permalink
Merge pull request #264 from Pioreactor/pi-to-pioreactor
Browse files Browse the repository at this point in the history
change user from pi to pioreactor
  • Loading branch information
CamDavidsonPilon authored Apr 11, 2022
2 parents 8e65181 + 772028c commit f8fb4d7
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 23 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
### Upcoming
### 22.4.0
- store more experiment metadata, like strain and media, in the database.
- adding temporary labels of Pioreactors into the database in `pioreactor_unit_labels` table
- renaming some tables, `alt_media_fraction` -> `alt_media_fractions`, `ir_led_intensity` -> `ir_led_intensities`
- pumps now throw a `CalibrationError` exception if their calibration is not defined.
- default user is no longer `pi`. It is now `pioreactor`. Any coded paths like `/home/pi/` should be updated to `home/pioreactor/`.
- new image metadata file added to `home/pioreactor/.pioreactor/.image_metadata`


### 22.3.0
- fixed memory leak in MQTT connections
Expand Down
20 changes: 12 additions & 8 deletions pioreactor/actions/leader/backup_database.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from time import sleep

import click

from pioreactor.config import config, get_active_workers_in_inventory
from pioreactor.config import config
from pioreactor.config import get_active_workers_in_inventory
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 publish_ready_to_disconnected_state
from pioreactor.utils.timing import current_utc_time
from pioreactor.utils import (
local_persistant_storage,
is_pio_job_running,
publish_ready_to_disconnected_state,
)
from pioreactor.whoami import get_unit_name, UNIVERSAL_EXPERIMENT
from pioreactor.whoami import get_unit_name
from pioreactor.whoami import UNIVERSAL_EXPERIMENT


def backup_database(output_file: str) -> None:
Expand Down Expand Up @@ -93,7 +95,9 @@ def progress(status: int, remaining: int, total: int) -> None:


@click.command(name="backup_database")
@click.option("--output", default="/home/pi/.pioreactor/storage/pioreactor.sqlite.backup")
@click.option(
"--output", default="/home/pioreactor/.pioreactor/storage/pioreactor.sqlite.backup"
)
def click_backup_database(output: str) -> None:
"""
(leader only) Backup db to workers.
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/actions/leader/export_experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def export_experiment_data(experiment: str, output: str, tables: list) -> None:

@click.command(name="export_experiment_data")
@click.option("--experiment", default=None)
@click.option("--output", default="/home/pi/exports/export.zip")
@click.option("--output", default="/home/pioreactor/exports/export.zip")
@click.option("--tables", multiple=True, default=[])
def click_export_experiment_data(experiment, output, tables):
"""
Expand Down
2 changes: 2 additions & 0 deletions pioreactor/background_jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ def lost(self) -> None:

def _cleanup(self):
# Explicitly cleanup resources...
# it's pretty slow to disconnect from MQTT. Takes up to ~1 second. We do it three times here:
# logger, sub_client, pub_client.

# clean up logger handlers
while len(self.logger.handlers) > 0:
Expand Down
12 changes: 6 additions & 6 deletions pioreactor/cli/pios.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def save_config_files_to_db(units: tuple[str, ...], shared: bool, specific: bool

if specific:
for unit in units:
with open(f"/home/pi/.pioreactor/config_{unit}.ini") as f:
with open(f"/home/pioreactor/.pioreactor/config_{unit}.ini") as f:
cur.execute(sql, (timestamp, f"config_{unit}.ini", f.read()))

if shared:
with open("/home/pi/.pioreactor/config.ini") as f:
with open("/home/pioreactor/.pioreactor/config.ini") as f:
cur.execute(sql, (timestamp, "config.ini", f.read()))

conn.commit()
Expand All @@ -74,16 +74,16 @@ def sync_config_files(ftp_client, unit: str, shared: bool, specific: bool) -> No
# there was a bug where if the leader == unit, the config.ini would get wiped
if (get_leader_hostname() != unit) and shared:
ftp_client.put(
localpath="/home/pi/.pioreactor/config.ini",
remotepath="/home/pi/.pioreactor/config.ini",
localpath="/home/pioreactor/.pioreactor/config.ini",
remotepath="/home/pioreactor/.pioreactor/config.ini",
)

# move the specific unit config.ini
if specific:
try:
ftp_client.put(
localpath=f"/home/pi/.pioreactor/config_{unit}.ini",
remotepath="/home/pi/.pioreactor/unit_config.ini",
localpath=f"/home/pioreactor/.pioreactor/config_{unit}.ini",
remotepath="/home/pioreactor/.pioreactor/unit_config.ini",
)
except Exception as e:
click.echo(
Expand Down
8 changes: 4 additions & 4 deletions pioreactor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def get_config():
global_config_path = "./config.dev.ini"
local_config_path = ""
else:
global_config_path = "/home/pi/.pioreactor/config.ini"
local_config_path = "/home/pi/.pioreactor/unit_config.ini"
global_config_path = "/home/pioreactor/.pioreactor/config.ini"
local_config_path = "/home/pioreactor/.pioreactor/unit_config.ini"
if not os.path.isfile(global_config_path):
raise FileNotFoundError(
"/home/pi/.pioreactor/config.ini is missing from this Pioreactor. Has it completed initializing? Does it need to connect to a leader?"
"/home/pioreactor/.pioreactor/config.ini is missing from this Pioreactor. Has it completed initializing? Does it need to connect to a leader?"
)

config_files = [global_config_path, local_config_path]
Expand All @@ -122,7 +122,7 @@ def get_config():
# pios sync tries to run, it uses a malformed unit_config.ini and hence the leader_config.ini can't be deployed
# to replace the malformed unit_config.ini.
print(
"Bad config state. Check /home/pi/.pioreactor/unit_config.ini on leader for malformed configuration?"
"Bad config state. Check /home/pioreactor/.pioreactor/unit_config.ini on leader for malformed configuration?"
)
raise e
except configparser.DuplicateSectionError as e:
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/plugin_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_plugins() -> dict[str, Plugin]:
if is_testing_env():
MODULE_DIR = "plugins_dev"
else:
MODULE_DIR = "/home/pi/.pioreactor/plugins"
MODULE_DIR = "/home/pioreactor/.pioreactor/plugins"

sys.path.append(MODULE_DIR)

Expand Down
2 changes: 1 addition & 1 deletion pioreactor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def local_persistant_storage(
if is_testing_env():
cache = ndbm.open(f".pioreactor/storage/{cache_name}", "c")
else:
cache = ndbm.open(f"/home/pi/.pioreactor/storage/{cache_name}", "c")
cache = ndbm.open(f"/home/pioreactor/.pioreactor/storage/{cache_name}", "c")
yield cache # type: ignore
finally:
cache.close()
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations


__version__ = "22.3.0"
__version__ = "22.4.0"


def _get_hardware_version() -> tuple[int, int]:
Expand Down

0 comments on commit f8fb4d7

Please sign in to comment.