INNER CODE UNIT · Python
_latest_run_dir
416rehman/DeepZero · src/deepzero/cli.py:87
def _latest_run_dir(base: Path) -> Path | None:
"""Pick the most recent corpus run directory under a pipeline's base dir.
Runs are namespaced per corpus (``<base>/<corpus-key>/``), so ``status`` and
``report`` with only ``--pipeline`` resolve to the newest run. A ``run.json``
directly in ``base`` (e.g. ``--work-dir`` pointed straight at a run) also works.
"""
if not base.exists():
return None
runs = [d for d in base.iterdir() if d.is_dir() and (d / "run.json").exists()]
if runs:
return max(runs, key=lambda d: (d / "run.json").stat().st_mtime)
return base if (base / "run.json").exists() else None
def _setup_logging(verbose: bool) -> None:
level = logging.DEBUG if verbose else logging.INFO
handler = RichHandler(