Miscs changes (Interro22)

This commit is contained in:
2026-03-17 14:19:43 +01:00
parent e703662d9e
commit ebc7a9aadc
10 changed files with 129 additions and 95 deletions
+7 -10
View File
@@ -10,16 +10,16 @@ from reportlab.pdfgen import canvas
import annotating
import annotating_with_checks
from utils import natural_key
# Roughly 10 A4 pages at 100 DPI
# MAX_HEIGHT_PX = 11690
MAX_HEIGHT_PX = 17000 # Can be increased by 10%.
# MAX_HEIGHT_PX = 16000
MAX_HEIGHT_PX = 18500 # Can be increased by 10%.
def render_item(item):
student_id, label, content = item
pdf_path = content['pdf_path']
if not os.path.exists(pdf_path):
print("no pdf path")
print("no pdf path for ", pdf_path)
return None
base_img, _, _ = annotating.make_base_image(pdf_path)
@@ -27,7 +27,6 @@ def render_item(item):
final_img, header_h = annotating.compose_label_image(
base_img, label, content['result'], content['coordinates'][0],
render_fn=annotating_with_checks.safe_render_latex,
draw_callback=cb_renderer.callback,
more_right=True,
with_id=student_id
@@ -137,10 +136,11 @@ def main():
for line in lines:
labels = [l.strip() for l in line.split(',') if l.strip()]
safe_labels = [l.replace(":", "").strip() for l in line.split(',') if l.strip()]
if not labels:
continue
prefix = os.path.commonprefix(labels).strip()
prefix = os.path.commonprefix(safe_labels).strip()
if not prefix:
prefix = "Group"
@@ -151,10 +151,7 @@ def main():
items_to_render.append((sid, lbl, lbls[lbl]))
# Sort structurally: by student id and label
items_to_render.sort(key=lambda x: (
annotating_with_checks.natural_key(x[0]),
annotating_with_checks.natural_key(x[1])
))
items_to_render.sort(key=lambda x: (natural_key(x[0]), natural_key(x[1])))
# Render images in parallel using the pre-existing lock & render function
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
rendered = list(executor.map(render_item, items_to_render))