Repository navigation
Expand file tree
/
Copy pathrun.py
More file actions
68 lines (54 loc) · 2.17 KB
/
Copy pathrun.py
File metadata and controls
68 lines (54 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
"""Run the Cflows workflow."""
from __future__ import annotations
import argparse
import csv
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
DATA = ROOT / "data"
RESULTS = ROOT / "results"
sys.path.insert(0, str(ROOT / "src"))
from common import sha256 # noqa: E402
def check_inputs() -> None:
with (DATA / "manifest.tsv").open(newline="", encoding="utf-8") as handle:
rows = list(csv.DictReader(handle, delimiter="\t"))
failures = []
for row in rows:
path = DATA / row["path"]
if not path.is_file():
failures.append(f"missing: {row['path']}")
elif path.stat().st_size != int(row["size_bytes"]):
failures.append(f"size mismatch: {row['path']}")
elif sha256(path) != row["sha256"]:
failures.append(f"checksum mismatch: {row['path']}")
if failures:
raise SystemExit("input bundle check failed:\n " + "\n ".join(failures))
print(f"input bundle: {len(rows)} files verified", flush=True)
def run(script: str) -> None:
command = [sys.executable, str(ROOT / "scripts" / script)]
print("\n$", " ".join(command), flush=True)
subprocess.run(command, cwd=ROOT, check=True)
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("branch", choices=("all", "in-vitro", "in-vivo"), nargs="?", default="all")
parser.add_argument("--n-jobs", type=int, default=-1,
help="CPU workers for the Granger tests (default: all cores)")
args = parser.parse_args()
cache = RESULTS / "cache"
(cache / "matplotlib").mkdir(parents=True, exist_ok=True)
(cache / "numba").mkdir(parents=True, exist_ok=True)
os.environ.setdefault("MPLCONFIGDIR", str(cache / "matplotlib"))
os.environ.setdefault("NUMBA_CACHE_DIR", str(cache / "numba"))
os.environ["CFLOWS_N_JOBS"] = str(args.n_jobs)
check_inputs()
if args.branch in ("all", "in-vitro"):
run("in_vitro.py")
if args.branch in ("all", "in-vivo"):
run("trajectories.py")
run("growth_filter.py")
run("in_vivo.py")
if __name__ == "__main__":
main()