Cache for reading annotation

This commit is contained in:
sebastien committed 2026-10-24 10:22:41 +02:00
1 parent 55d5cf16c9
commit ff7496b113
12 files changed
+466 -13

No files matched your search

+9 -3
View File
@@ -4,7 +4,7 @@ import argparse
import re
import sys
from collections import defaultdict
from collections.abc import Sequence
from collections.abc import Collection, Sequence
from pathlib import Path
from copienator import (
@@ -77,8 +77,12 @@ def _annotation_source(
def update_named_return_answers(
workspace: EvaluationWorkspace,
annotation_dir_name: str,
*,
copy_ids: Collection[str] | None = None,
) -> ExitCode:
"""Refresh only answers/ in existing returns, preserving manual names."""
"""Refresh answers/ in existing returns, optionally only successful rereads."""
if copy_ids is not None and (not copy_ids or not workspace.return_dir.is_dir()):
return ExitCode.SUCCESS
workspace.require_directories(annotation_dir_name, "A Rendre")
had_errors = False
found = False
@@ -86,6 +90,8 @@ def update_named_return_answers(
if not destination.is_dir():
continue
match = RETURN_COPY_ID.search(destination.name)
if copy_ids is not None and (match is None or match.group(1) not in copy_ids):
continue
if match is None:
print(
f"Warning: cannot identify a copy ID in {destination.name!r}; skipped",
@@ -116,7 +122,7 @@ def update_named_return_answers(
except (OSError, TypeError, ValueError) as exc:
print(f"Error updating answers for {destination.name}: {exc}", file=sys.stderr)
had_errors = True
if not found:
if not found and copy_ids is None:
print("Warning: no identifiable student folders found in A Rendre", file=sys.stderr)
had_errors = True
return ExitCode.PARTIAL if had_errors else ExitCode.SUCCESS