Measure each chunk's reading cost from its transcript and keep it in the comprehension history
This commit is contained in:
@@ -15,8 +15,7 @@ def archive(project_key: str, path: str, task: str, outcome: str, at: float, pat
|
||||
try:
|
||||
with open(path, "rb") as handle:
|
||||
raw = handle.read()
|
||||
# Each chunk's first timestamped line is its own: a finished chunk's session is deleted, so the next chunk's transcript starts afresh.
|
||||
folder = paths.transcript_archive / project_key / hashlib.sha256(first_timestamped_line(raw)).hexdigest()
|
||||
folder = paths.transcript_archive / project_key / chunk_of(raw)
|
||||
make_private(folder)
|
||||
except OSError as failure:
|
||||
return unarchived(failure.filename, failure.strerror)
|
||||
@@ -36,6 +35,11 @@ def archive(project_key: str, path: str, task: str, outcome: str, at: float, pat
|
||||
return None
|
||||
|
||||
|
||||
# Each chunk's first timestamped line is its own: a finished chunk's session is deleted, so the next chunk's transcript starts afresh.
|
||||
def chunk_of(raw: bytes) -> str:
|
||||
return hashlib.sha256(first_timestamped_line(raw)).hexdigest()
|
||||
|
||||
|
||||
def unarchived(where: object, why: str | None) -> Failure:
|
||||
return Failure(f"could not archive the transcript: {where}: {why}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user