Improve web finalisation navigation, caching and Anot support
This commit is contained in:
1 parent
5de70dbc0d
commit
b069805988
21 files changed
+339
-58
No files matched your search
@@ -8,6 +8,26 @@ from copienator.commands.reading_grouped_annotations import apply_actions_and_re
|
||||
def run(workspace: EvaluationWorkspace, mode: str, *, incremental: bool = False):
|
||||
directories = sorted((p for p in (workspace.root / mode).glob('Copie*')
|
||||
if p.is_dir() and p.name[5:].isdigit() and (p / 'score.json').is_file()))
|
||||
# Legacy Anot outputs predate saved rendering inputs; create them without
|
||||
# replacing any existing score or annotated image.
|
||||
missing = [d for d in directories if not (d / FILENAME).is_file()]
|
||||
if mode == 'Anot' and missing:
|
||||
from copienator.annotation_data import load_annotation_data
|
||||
from copienator.annotation_layout import layout_for
|
||||
from copienator.filesystem import staged_files
|
||||
from copienator.review_snapshot import stage
|
||||
loaded = load_annotation_data(workspace)
|
||||
if loaded.warnings:
|
||||
raise ValueError("Relancez la génération Anot : " + "; ".join(loaded.warnings))
|
||||
for directory in missing:
|
||||
cid = directory.name[5:]
|
||||
if cid not in loaded.data:
|
||||
raise ValueError(f"Données Anot absentes pour {directory.name}.")
|
||||
data = loaded.data[cid]
|
||||
notes = {label: {'img': None, 'old_header_h': 0, 'layout': layout_for(content['pdf_path'])}
|
||||
for label, content in data.items()}
|
||||
with staged_files(directory) as staging:
|
||||
stage(directory, staging, data, notes, engine='grouped')
|
||||
from copienator.reviewed_cache import ReviewedReadCache
|
||||
cache = ReviewedReadCache(workspace, mode, directories) if incremental else None
|
||||
if cache:
|
||||
@@ -47,6 +67,6 @@ def run(workspace: EvaluationWorkspace, mode: str, *, incremental: bool = False)
|
||||
|
||||
def main(argv=None):
|
||||
parser = evaluation_parser('Regenerate from saved reviewed inputs without rescanning handwriting')
|
||||
parser.add_argument('--annotation-dir', choices=('Bnot', 'BGnot'), required=True)
|
||||
parser.add_argument('--annotation-dir', choices=('Bnot', 'BGnot', 'Anot'), required=True)
|
||||
parser.add_argument("--incremental", action="store_true", help="Skip unchanged copies")
|
||||
return execute(parser, argv, lambda args: run(workspace_from_args(args), args.annotation_dir, incremental=args.incremental))
|
||||
Reference in new issue
Block a user