Rudimentary support for --refaire

This commit is contained in:
2026-04-01 22:20:11 +02:00
parent c1524a99c3
commit 95db769751
6 changed files with 155 additions and 46 deletions
+10 -5
View File
@@ -108,9 +108,9 @@ from utils import natural_key
def process_student(args):
"""Thread worker: Processes one student."""
root_dir, student_id, labels, overwrite = args
root_dir, student_id, labels, overwrite, sub_folder = args
output_dir = os.path.join(root_dir, "Bnot", f"Copie{student_id}")
output_dir = os.path.join(root_dir, sub_folder, f"Copie{student_id}")
if os.path.exists(output_dir):
if not overwrite:
@@ -230,14 +230,16 @@ if __name__ == "__main__":
else:
root_dir = input_path
results = annotating.make_dictionary(root_dir)
if not args.refaire:
results = annotating.make_dictionary(root_dir)
# --- ADD THE REFAIRE BLOCK HERE ---
if args.refaire:
refaire_path = os.path.join(root_dir, "refaire.json")
if os.path.exists(refaire_path):
with open(refaire_path, "r", encoding="utf-8") as f:
refaire_list = json.load(f)
results = annotating.make_dictionary(root_dir,
refaire=True,refaire_list=refaire_list)
filtered_results = {}
for copie_name, labels_to_redo in refaire_list:
@@ -262,7 +264,10 @@ if __name__ == "__main__":
print(f"Student ID {target_id} not found in directory scan.")
results = {}
tasks = sorted([(root_dir, sid, lbls, overwrite) for sid, lbls in results.items()])
sub_folder = "BRnot" if args.refaire else "Bnot"
tasks = sorted([(root_dir, sid, lbls, overwrite, sub_folder)
for sid, lbls in results.items()])
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
results = executor.map(process_student, tasks)