Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rtgs_lab_tools/device_monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ The monitoring script runs from the lab's shared workspace on Bryan's scrontab:
Paths are overridable from the scrontab environment (never from the credentials file):
DEVICEMON_BASE_DIR, DEVICEMON_WORK_DIR, DEVICEMON_LOG_DIR, DEVICEMON_CREDS_FILE,
DEVICEMON_RELEASE_FILE, DEVICEMON_SA_KEY, DEVICEMON_TOKEN_SECRET, DEVICEMON_PYTHON_MODULE
(default `python3/3.12.4_anaconda2024.06-1_libmamba`), DEVICEMON_PYTHON (absolute path).
(default `python3/3.12.4_anaconda2024.06-1_libmamba`), DEVICEMON_PYTHON (absolute path),
DEVICEMON_EMAIL (`1` sends the notification email after each run; off by default).

Ownership (the script refuses to run if the code side is group- or world-writable):
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# `module load python` left /usr/bin/python3 = 3.6.8 on PATH)
# DEVICEMON_PYTHON interpreter to build the venv with (absolute path); skips the
# module lookup
# DEVICEMON_EMAIL 1 = send the notification email after each run; default off
# (the dashboard is the place to look; Bryan, 2026-10-18)
#
# Paths (defaults = the lab's shared MSI workspace):
# DEVICEMON_BASE_DIR /projects/standard/runck014/shared/device_monitoring
Expand Down Expand Up @@ -379,6 +381,12 @@ MONITOR_ARGS=(monitor)
[ -z "$END_DATE" ] || MONITOR_ARGS+=("--end-date=$END_DATE")
[ -z "$NODE_IDS" ] || MONITOR_ARGS+=("--node-ids=$NODE_IDS")
[ "$PROJECT" = "ALL" ] || MONITOR_ARGS+=("--project=$PROJECT")
if [ "${DEVICEMON_EMAIL:-0}" = "1" ]; then
log "Notification email: on (DEVICEMON_EMAIL=1)"
else
MONITOR_ARGS+=("--no-email")
log "Notification email: off (set DEVICEMON_EMAIL=1 to send it)"
fi

# Pin one timestamp for the whole day and keep it across retries, so a retried
# report replaces the rows of the attempt it is repeating. UTC throughout.
Expand Down
18 changes: 18 additions & 0 deletions tests/device_monitoring/test_cron_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,24 @@ def test_builds_lean_venv_and_runs_the_devmon_cli(ws):
assert r.returncode == 0 and "-m pip" not in log.read_text()


def test_email_off_by_default_and_opt_in(ws):
sha = release_with_requirements(ws)
log = ws["tmp"] / "py.log"
pin = f"devmon-v0.0.2 {sha}\n"

def monitor_call(**extra):
log.write_text("")
r = run(ws, pin, DEVICEMON_PYTHON=str(stub_python(ws)), STUB_LOG=str(log), **extra)
assert r.returncode == 0, r.stdout + r.stderr
calls = [c.split(" ", 1)[1] for c in log.read_text().splitlines()]
return [c for c in calls if ".cli monitor" in c][0], r.stdout

call, out = monitor_call()
assert call.endswith("--no-email") and "Notification email: off" in out
call, out = monitor_call(DEVICEMON_EMAIL="1")
assert "--no-email" not in call and "Notification email: on" in out


def test_never_runs_install_sh_or_full_extras():
text = SCRIPT.read_text()
assert "bash install.sh" not in text and "[dev]" not in text and "[all]" not in text
Expand Down
Loading