Skip to content

Commit

Permalink
fix environ variables not being passed
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Oct 26, 2024
1 parent fae36a0 commit 827b6fc
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
6 changes: 3 additions & 3 deletions asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.a3dbeddd.css",
"main.js": "/static/js/main.26dd64ad.js",
"main.js": "/static/js/main.0ec97ce4.js",
"static/media/roboto-all-500-normal.woff": "/static/media/roboto-all-500-normal.0ab669b7a0d19b178f57.woff",
"static/media/roboto-all-700-normal.woff": "/static/media/roboto-all-700-normal.a457fde362a540fcadff.woff",
"static/media/roboto-all-400-normal.woff": "/static/media/roboto-all-400-normal.c5d001fa922fa66a147f.woff",
Expand Down Expand Up @@ -36,10 +36,10 @@
"static/media/roboto-greek-ext-700-normal.woff2": "/static/media/roboto-greek-ext-700-normal.bd9854c751441ccc1a70.woff2",
"index.html": "/index.html",
"main.a3dbeddd.css.map": "/static/css/main.a3dbeddd.css.map",
"main.26dd64ad.js.map": "/static/js/main.26dd64ad.js.map"
"main.0ec97ce4.js.map": "/static/js/main.0ec97ce4.js.map"
},
"entrypoints": [
"static/css/main.a3dbeddd.css",
"static/js/main.26dd64ad.js"
"static/js/main.0ec97ce4.js"
]
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.26dd64ad.js"></script><link href="/static/css/main.a3dbeddd.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.0ec97ce4.js"></script><link href="/static/css/main.a3dbeddd.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
65 changes: 47 additions & 18 deletions pioreactorui/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import logging
import os
from logging import handlers
from shlex import join
from subprocess import check_call as run_and_check_call
Expand Down Expand Up @@ -113,17 +114,42 @@ def update_app_from_release_archive_across_cluster(archive_location: str) -> boo


@huey.task()
def pio(*args: str, env: dict[str, str] | None = None) -> tuple[bool, str]:
def update_app_from_release_archive_on_specific_pioreactors(
archive_location: str, pioreactors: list[str]
) -> bool:
units_cli: tuple[str, ...] = sum((("--units", p) for p in pioreactors), tuple())

logger.info(f"Updating app and ui on unit {pioreactors} from {archive_location}")
distribute_archive_to_workers = [PIOS_EXECUTABLE, "cp", archive_location, "-y", *units_cli]
run(distribute_archive_to_workers)

update_app_across_all_workers = [
PIOS_EXECUTABLE,
"update",
"--source",
archive_location,
"-y",
*units_cli,
]
run(update_app_across_all_workers)

return True


@huey.task()
def pio(*args: str, env: dict[str, str] = {}) -> tuple[bool, str]:
logger.info(f'Executing `{join(("pio",) + args)}`, {env=}')
result = run((PIO_EXECUTABLE,) + args, capture_output=True, text=True, env=env)
result = run(
(PIO_EXECUTABLE,) + args, capture_output=True, text=True, env=dict(os.environ) | env
)
if result.returncode != 0:
return False, result.stderr.strip()
else:
return True, result.stdout.strip()


@huey.task()
def pio_run(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_run(*args: str, env: dict[str, str] = {}) -> bool:
# for long running pio run jobs where we don't care about the output / status
command = ("nohup", PIO_EXECUTABLE, "run") + args
env = {k: v for k, v in (env or {}).items() if k in ALLOWED_ENV}
Expand All @@ -134,9 +160,7 @@ def pio_run(*args: str, env: dict[str, str] | None = None) -> bool:

@huey.task()
@huey.lock_task("export-data-lock")
def pio_run_export_experiment_data(
*args: str, env: dict[str, str] | None = None
) -> tuple[bool, str]:
def pio_run_export_experiment_data(*args: str, env: dict[str, str] = {}) -> tuple[bool, str]:
logger.info(f'Executing `{join(("pio", "run", "export_experiment_data") + args)}`, {env=}')
result = run(
(PIO_EXECUTABLE, "run", "export_experiment_data") + args,
Expand All @@ -151,44 +175,44 @@ def pio_run_export_experiment_data(


@huey.task()
def pio_kill(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_kill(*args: str, env: dict[str, str] = {}) -> bool:
logger.info(f'Executing `{join(("pio", "kill") + args)}`, {env=}')
result = run((PIO_EXECUTABLE, "kill") + args, env=env)
result = run((PIO_EXECUTABLE, "kill") + args, env=dict(os.environ) | env)
return result.returncode == 0


@huey.task()
@huey.lock_task("plugins-lock")
def pio_plugins(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_plugins(*args: str, env: dict[str, str] = {}) -> bool:
# install / uninstall only
assert args[0] in ("install", "uninstall")
logger.info(f'Executing `{join(("pio", "plugins") + args)}`, {env=}')
result = run((PIO_EXECUTABLE, "plugins") + args, env=env)
result = run((PIO_EXECUTABLE, "plugins") + args, env=dict(os.environ) | env)
return result.returncode == 0


@huey.task()
@huey.lock_task("update-lock")
def pio_update_app(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_update_app(*args: str, env: dict[str, str] = {}) -> bool:
logger.info(f'Executing `{join(("pio", "update", "app") + args)}`, {env=}')
result = run((PIO_EXECUTABLE, "update", "app") + args, env=env)
result = run((PIO_EXECUTABLE, "update", "app") + args, env=dict(os.environ) | env)
return result.returncode == 0


@huey.task()
@huey.lock_task("update-lock")
def pio_update(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_update(*args: str, env: dict[str, str] = {}) -> bool:
logger.info(f'Executing `{join(("pio", "update") + args)}`, {env=}')
run((PIO_EXECUTABLE, "update") + args, env=env)
run((PIO_EXECUTABLE, "update") + args, env=dict(os.environ) | env)
# this always returns >0 because it kills huey, I think, so just return true
return True


@huey.task()
@huey.lock_task("update-lock")
def pio_update_ui(*args: str, env: dict[str, str] | None = None) -> bool:
def pio_update_ui(*args: str, env: dict[str, str] = {}) -> bool:
logger.info(f'Executing `{join(("pio", "update", "ui") + args)}`, {env=}')
run((PIO_EXECUTABLE, "update", "ui") + args, env=env)
run((PIO_EXECUTABLE, "update", "ui") + args, env=dict(os.environ) | env)
# this always returns >0 because it kills huey, I think, so just return true
return True

Expand All @@ -215,9 +239,14 @@ def reboot() -> bool:


@huey.task()
def pios(*args: str, env: dict[str, str] | None = None) -> tuple[bool, str]:
def pios(*args: str, env: dict[str, str] = {}) -> tuple[bool, str]:
logger.info(f'Executing `{join(("pios",) + args + ("-y",))}`, {env=}')
result = run((PIOS_EXECUTABLE,) + args + ("-y",), capture_output=True, text=True, env=env)
result = run(
(PIOS_EXECUTABLE,) + args + ("-y",),
capture_output=True,
text=True,
env=dict(os.environ) | env,
)
if result.returncode != 0:
return False, result.stderr.strip()
else:
Expand Down
6 changes: 3 additions & 3 deletions static/js/main.26dd64ad.js → static/js/main.0ec97ce4.js

Large diffs are not rendered by default.

File renamed without changes.

Large diffs are not rendered by default.

0 comments on commit 827b6fc

Please sign in to comment.