adding: OUTPUT_FILENAME_PATTERN
This commit is contained in:
0
evaluator/output/__pycache__/legacy_exporter.cpython-313.pyc
Normal file → Executable file
0
evaluator/output/__pycache__/legacy_exporter.cpython-313.pyc
Normal file → Executable file
27
evaluator/output/legacy_exporter.py
Normal file → Executable file
27
evaluator/output/legacy_exporter.py
Normal file → Executable file
@@ -106,11 +106,36 @@ def _session_loop_map(rows) -> dict[str, int]:
|
||||
return {sid: max_consecutive_intent_streak(items) for sid, items in grouped.items()}
|
||||
|
||||
|
||||
def build_output_filename(
|
||||
agent_id: str,
|
||||
run_id: str,
|
||||
now_brt: datetime,
|
||||
pattern: str | None = None,
|
||||
) -> str:
|
||||
"""Build the export filename from the environment-configurable template."""
|
||||
template = pattern or settings.output_filename_pattern
|
||||
try:
|
||||
filename = template.format(
|
||||
agent_id=agent_id,
|
||||
run_id=run_id,
|
||||
timestamp=now_brt.strftime("%Y%m%d_%H%M%S"),
|
||||
)
|
||||
except KeyError as exc:
|
||||
raise ValueError(
|
||||
f"Unknown placeholder {exc} in OUTPUT_FILENAME_PATTERN. "
|
||||
"Supported placeholders: {agent_id}, {run_id}, {timestamp}."
|
||||
) from exc
|
||||
|
||||
if not filename or Path(filename).name != filename or filename in {".", ".."}:
|
||||
raise ValueError("OUTPUT_FILENAME_PATTERN must produce a filename without directories")
|
||||
return filename
|
||||
|
||||
|
||||
def export_legacy_txt_gz(repo: EvaluationRepository, run_id: str, agent_id: str) -> Path:
|
||||
output_dir = settings.path(settings.output_dir)
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
now_brt = datetime.now(ZoneInfo("America/Sao_Paulo"))
|
||||
path = output_dir / f"AGENTE_{agent_id}_LLM_JUDGE_{now_brt.strftime('%Y%m%d_%H%M%S')}.TXT.GZ"
|
||||
path = output_dir / build_output_filename(agent_id, run_id, now_brt)
|
||||
|
||||
with repo.store.connect() as conn:
|
||||
cur = conn.cursor()
|
||||
|
||||
Reference in New Issue
Block a user