webapps / hmc /reference /scripts /epic /file_list.py
gdevenyi's picture
hmc: NiFreeze 3bcfb00 and QSIPrep 26.1.1 SHORELine reference runs on ds005577 sub-107 (part 9)
a4ba047 verified
Raw History Blame Contribute Delete
943 Bytes
"""List the files of one QSIPrep run that the M0 package needs, relative to the run dir.
Usage: python -I file_list.py RUN_DIR > list.txt
"""
import json
import sys
from pathlib import Path
run = Path(sys.argv[1]).resolve()
paths = set()
def walk(node):
if isinstance(node, dict):
for k, v in node.items():
if k == "path" and isinstance(v, str):
paths.add(Path(v))
else:
walk(v)
elif isinstance(node, list):
for v in node:
walk(v)
walk(json.loads((run / "collected/manifest.json").read_text()))
for top in ("collected", "out"):
paths.update(p for p in (run / top).rglob("*") if p.is_file())
for name in ("command.txt", "timing.txt", "qsiprep.log"):
paths.add(run / name)
paths.update(run.glob("work/*/config.toml"))
for p in sorted(paths):
p = p if p.is_absolute() else run / p
if p.is_file():
print(p.relative_to(run))