Gzip loop-claude's archive and the review folders 30 days after each file was last written, and read gzipped files by their plain name
CI / tests (pull_request) Failing after 2m59s
CI / tests (pull_request) Failing after 2m59s
This commit is contained in:
@@ -4,6 +4,7 @@ import pathlib
|
||||
from transcript_archive.location import chunk_folder, FILE_SUFFIX, transcript_of
|
||||
from failure import Failure
|
||||
from transcript_archive.outcomes import FINISHED_AT, spent_stamps, workers
|
||||
from text_files.compressed import read_stored, stored_glob
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -32,7 +33,7 @@ def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Fail
|
||||
copies.append((stamps[-1], outcomes))
|
||||
if copies:
|
||||
finished, outcomes = max(copies)
|
||||
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), sorted(folder.glob("session/*/subagents/*.jsonl"))))
|
||||
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), subagent_transcripts(folder)))
|
||||
return sorted(found, key=lambda chunk: (chunk.finished, chunk.folder))
|
||||
|
||||
|
||||
@@ -44,6 +45,11 @@ def archived_outcomes(root: pathlib.Path) -> list[tuple[str, pathlib.Path]] | Fa
|
||||
return Failure(f"could not read the archive {root}: {failure}")
|
||||
|
||||
|
||||
def subagent_transcripts(folder: pathlib.Path) -> list[pathlib.Path]:
|
||||
"""The plain name of each subagent's transcript archived in a chunk's folder, kept plain or gzipped, sorted."""
|
||||
return [path for session in sorted(folder.glob("session/*/subagents")) for path in stored_glob(session, "*.jsonl")]
|
||||
|
||||
|
||||
def chunk_outcomes(folder: pathlib.Path) -> list[pathlib.Path]:
|
||||
"""The outcomes file of each transcript copy in a chunk's folder, sorted."""
|
||||
return sorted(folder.glob(f"*{FILE_SUFFIX}"))
|
||||
@@ -52,7 +58,7 @@ def chunk_outcomes(folder: pathlib.Path) -> list[pathlib.Path]:
|
||||
def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure:
|
||||
"""The worker's transcript, then each subagent's."""
|
||||
try:
|
||||
return [path.read_bytes() for path in (chunk.transcript, *chunk.subagents)]
|
||||
return [read_stored(path) for path in (chunk.transcript, *chunk.subagents)]
|
||||
except OSError as failure:
|
||||
return Failure(f"could not read {failure.filename}: {failure.strerror}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user