Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); print the report before exiting 1 on an unreadable archive, naming the file
This commit is contained in:
@@ -18,13 +18,21 @@ class FinishedChunk:
|
||||
def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Failure:
|
||||
found = []
|
||||
try:
|
||||
for folder in sorted(path for path in project_archive.glob("*") if path.is_dir()):
|
||||
copies = sorted((stamps[-1], outcomes) for outcomes in chunk_outcomes(folder) if (stamps := FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))))
|
||||
if copies:
|
||||
finished, outcomes = copies[-1]
|
||||
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), sorted(folder.glob("session/*/subagents/*.jsonl"))))
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
folders = sorted(path for path in project_archive.glob("*") if path.is_dir())
|
||||
except OSError as failure:
|
||||
return Failure(f"could not read the archive {project_archive}: {failure}")
|
||||
for folder in folders:
|
||||
copies = []
|
||||
for outcomes in chunk_outcomes(folder):
|
||||
try:
|
||||
stamps = FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read the archive file {outcomes}: {failure}")
|
||||
if stamps:
|
||||
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"))))
|
||||
return sorted(found, key=lambda chunk: (chunk.finished, chunk.folder))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user