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
@@ -20,8 +20,8 @@ class Finalisation:
|
||||
def __init__(self, root: Path, mode: str, token: str, lock_fd: int | None = None, *, repository: Path | None = None):
|
||||
self.root = root.resolve()
|
||||
self.repository = (repository or Path.cwd()).resolve()
|
||||
if mode not in ('Bnot', 'BGnot'):
|
||||
raise ValueError('Choisissez Bnot ou BGnot.')
|
||||
if mode not in ('Bnot', 'BGnot', 'Anot'):
|
||||
raise ValueError('Choisissez Anot, Bnot ou BGnot.')
|
||||
self.mode, self.token = mode, token
|
||||
self.lock_fd = lock_fd
|
||||
self.labels = utils.read_all_labels(self.root)
|
||||
@@ -66,6 +66,8 @@ class Finalisation:
|
||||
def state(self):
|
||||
with self.mutex:
|
||||
folders = return_folders(self.root)
|
||||
from copienator.final_scores import exported_scores
|
||||
final_scores = exported_scores(self.root, self.repository)
|
||||
copies = []
|
||||
for directory in self.copies():
|
||||
cid = directory.name[5:]
|
||||
@@ -75,7 +77,7 @@ class Finalisation:
|
||||
scores = read_json(directory / 'score.json')
|
||||
info = read_json(directory / 'info.json', default={})
|
||||
base = read_json(directory / BASELINE, default={})
|
||||
copies.append({'id': cid, 'name': name, 'general': general_remarks.remarks_for_copy(self.root, cid),
|
||||
copies.append({'id': cid, 'name': name, 'finalScore': final_scores.get(str(int(cid))), 'general': general_remarks.remarks_for_copy(self.root, cid),
|
||||
'answers': [{'label': label, 'score': str(scores.get(label, '')),
|
||||
'remark': custom_remarks.remarks_for_copy(self.root, cid).get(label, ''),
|
||||
'image': (directory / f'{label}.jpg').is_file(),
|
||||
@@ -98,6 +100,8 @@ class Finalisation:
|
||||
raise ValueError('Les données ont changé. Rechargez la page avant de réessayer.')
|
||||
kind, value = data['kind'], data['value']
|
||||
if kind == 'draft':
|
||||
if self.mode == 'Anot':
|
||||
raise ValueError('Les coupes et transferts nécessitent Bnot ou BGnot.')
|
||||
instructions = read_instructions(value, self.mode)
|
||||
validate_instructions(self.root, self.mode, instructions)
|
||||
# Same filesystem and atomic replacement; retain the GUI-readable format.
|
||||
@@ -137,6 +141,8 @@ class Finalisation:
|
||||
with self.mutex:
|
||||
if self.job['running'] or self.closing or revision != self.revision():
|
||||
raise ValueError('Traitement déjà en cours ou données modifiées. Rechargez la page.')
|
||||
if apply_draft and self.mode == 'Anot':
|
||||
raise ValueError('Les coupes et transferts nécessitent Bnot ou BGnot.')
|
||||
if apply_draft:
|
||||
validate_instructions(self.root, self.mode, read_instructions(self.draft(), self.mode))
|
||||
if not (self.root / DRAFT).exists():
|
||||
@@ -166,7 +172,7 @@ class Finalisation:
|
||||
outputs = []
|
||||
for directory in directories:
|
||||
info = read_json(directory / 'info.json', default={})
|
||||
paths = [directory / 'info.json', directory / BASELINE]
|
||||
paths = [directory / 'info.json', directory / (FILENAME if self.mode == 'Anot' else BASELINE)]
|
||||
paths += [directory / f'{label}.jpg' for label, entry in info.items() if entry['present']]
|
||||
paths += list(directory.glob('Concat*.*'))
|
||||
if any(not path.is_file() for path in paths):
|
||||
@@ -194,7 +200,7 @@ class Finalisation:
|
||||
commands = [['giving-names', str(self.root), self.mode]]
|
||||
with self.mutex:
|
||||
self.job['log'] += 'Noms seuls modifiés : conservation des images et PDF de correction.\n'
|
||||
elif all((directory / FILENAME).is_file() for directory in self.copies()):
|
||||
elif self.mode == 'Anot' or all((directory / FILENAME).is_file() for directory in self.copies()):
|
||||
commands[0] = ['regenerate-reviewed', str(self.root), '--annotation-dir', self.mode]
|
||||
elif (self.root / 'BRnot').is_dir():
|
||||
with self.mutex:
|
||||
|
||||
Reference in new issue
Block a user