Files
srbhr--resume-matcher/apps/backend/e2e_monitor/bundle.py
T
wehub-resource-sync 5bdf4cc89a
Publish Docker Image / publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:36 +08:00

51 lines
1.3 KiB
Python

"""Evidence-bundle directory layout + JSON helpers."""
from __future__ import annotations
import json
from dataclasses import dataclass
from pathlib import Path
from typing import Any
@dataclass
class Bundle:
"""One run's evidence bundle under ``artifacts/e2e-monitor/<run-id>/``."""
root: Path # artifacts/e2e-monitor
run_id: str
@property
def dir(self) -> Path:
return self.root / self.run_id
@property
def logs_dir(self) -> Path:
return self.dir / "logs"
@property
def data_dir(self) -> Path:
return self.dir / "data"
@property
def master_dir(self) -> Path:
return self.dir / "master"
def variation_dir(self, jd_key: str) -> Path:
d = self.dir / "variations" / jd_key
d.mkdir(parents=True, exist_ok=True)
return d
def ensure(self) -> None:
for d in (self.dir, self.logs_dir, self.data_dir, self.master_dir):
d.mkdir(parents=True, exist_ok=True)
@staticmethod
def write_json(path: Path, obj: Any) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(obj, ensure_ascii=False, indent=2), encoding="utf-8")
@staticmethod
def read_json(path: Path) -> Any:
return json.loads(path.read_text(encoding="utf-8"))