pcmt-artifact / scripts /render_manuscript_figures.sh
Faruk Alpay
Publish PCMT artifact as dataset tree
4146b47
Raw
History Blame Contribute Delete
2.29 kB
#!/usr/bin/env bash
set -euo pipefail
export MPLBACKEND="${MPLBACKEND:-Agg}"
export MPLCONFIGDIR="${MPLCONFIGDIR:-tmp/mpl}"
mkdir -p "$MPLCONFIGDIR"
python3 -m pcmt.cli figures --input runs/run-small/traces.csv --output figures
if [[ -f data/real_videos/sample-20s-360p.mp4 && -f runs/detector-video/traces.csv ]]; then
python3 -m pcmt.cli real-figures \
--video data/real_videos/sample-20s-360p.mp4 \
--traces runs/detector-video/traces.csv \
--output figures \
--use-gpu auto
fi
best_sweep="$(
python3 - <<'PY'
from pathlib import Path
import csv
candidates = [
Path("runs/remote_gpu/benchmark-sweep-gpu"),
Path("runs/remote_gpu/youcook2-scale2-sweep-gpu"),
Path("runs/remote_gpu/youcook2-batched-sweep-gpu"),
Path("runs/remote_gpu/ave-scale1-sweep-gpu"),
Path("runs/remote_gpu/youcook2-sweep"),
Path("runs/remote_gpu/sweep-detector-gpu-scale1"),
Path("runs/remote_gpu/sweep-detector-gpu"),
Path("runs/sweep-detector"),
]
def rows(path: Path) -> int:
with (path / "sweep_traces.csv").open(newline="") as handle:
return sum(1 for _ in csv.DictReader(handle))
valid = [path for path in candidates if (path / "sweep_traces.csv").exists() and (path / "sweep_metrics.json").exists()]
if valid:
print(max(valid, key=rows))
PY
)"
if [[ -n "$best_sweep" ]]; then
python3 -m pcmt.cli sweep-figures \
--traces "$best_sweep/sweep_traces.csv" \
--metrics "$best_sweep/sweep_metrics.json" \
--output figures
echo "publication_sweep_source=$best_sweep"
fi
if [[ -z "$best_sweep" ]]; then
echo "publication_sweep_source=run-small-fallback"
fi
best_robustness="$(
python3 - <<'PY'
from pathlib import Path
import csv
candidates = [
Path("runs/remote_gpu/robustness-atlas-gpu"),
Path("runs/robustness-atlas"),
]
def rows(path: Path) -> int:
with (path / "stability_phase_diagram_values.csv").open(newline="") as handle:
return sum(1 for _ in csv.DictReader(handle))
valid = [path for path in candidates if (path / "stability_phase_diagram_values.csv").exists()]
if valid:
print(max(valid, key=rows))
PY
)"
if [[ -n "$best_robustness" ]]; then
python3 -m pcmt.cli robustness-figures --input "$best_robustness" --output figures
echo "publication_robustness_source=$best_robustness"
fi