Support evaluation-local configuration and names overrides
This commit is contained in:
1 parent
0bb6f7d97c
commit
d4404e4c27
36 files changed
+409
-184
No files matched your search
@@ -23,7 +23,7 @@ from copienator import (
|
||||
workspace_from_args,
|
||||
)
|
||||
from copienator.annotation_data import load_annotation_data
|
||||
from copienator.annotation_documents import MAX_HEIGHT_PX, MAX_PIXELS, document_fits
|
||||
from copienator.annotation_documents import annotation_limits, document_fits
|
||||
from copienator.commands import annotating, annotating_with_checks
|
||||
from copienator.commands.import_annotations import clear_import_directory
|
||||
from copienator.filesystem import staged_directory
|
||||
@@ -60,15 +60,16 @@ def render_item(item):
|
||||
|
||||
|
||||
def save_batch(batch, prefix, group_id, output_root: Path) -> None:
|
||||
max_height_px, max_pixels = annotation_limits()
|
||||
output_dir = output_root / f"{prefix} G{group_id}"
|
||||
print(f"Generating group PDF: {prefix} G{group_id} ({len(batch)} elements)")
|
||||
max_width = max(item[2].width for item in batch)
|
||||
total_height = sum(item[2].height for item in batch)
|
||||
if not document_fits(max_width, total_height, MAX_HEIGHT_PX, MAX_PIXELS):
|
||||
if not document_fits(max_width, total_height, max_height_px, max_pixels):
|
||||
raise CliError(
|
||||
f"{prefix} G{group_id} would be {max_width} × {total_height} px "
|
||||
f"({max_width * total_height} pixels); document limits are "
|
||||
f"{MAX_HEIGHT_PX} px high and {MAX_PIXELS} pixels."
|
||||
f"{max_height_px} px high and {max_pixels} pixels."
|
||||
)
|
||||
concatenated = Image.new("RGB", (max_width, total_height), "white")
|
||||
draw = ImageDraw.Draw(concatenated)
|
||||
@@ -280,12 +281,13 @@ def _existing_group_state(
|
||||
|
||||
|
||||
def split_batches(rendered):
|
||||
max_height_px, max_pixels = annotation_limits()
|
||||
batches = []
|
||||
heights = []
|
||||
widths = []
|
||||
|
||||
def fits(width, height):
|
||||
return document_fits(width, height, MAX_HEIGHT_PX, MAX_PIXELS)
|
||||
return document_fits(width, height, max_height_px, max_pixels)
|
||||
|
||||
def add_block(items):
|
||||
width = max(item[2].width for item in items)
|
||||
@@ -326,7 +328,7 @@ def split_batches(rendered):
|
||||
f"Copie{student_id} ({item[1]}) is {image.width} × "
|
||||
f"{image.height} px ({image.width * image.height} pixels); "
|
||||
f"a single answer cannot be split. Document limits are "
|
||||
f"{MAX_HEIGHT_PX} px high and {MAX_PIXELS} pixels."
|
||||
f"{max_height_px} px high and {max_pixels} pixels."
|
||||
)
|
||||
if block and not fits(max(width, image.width), height + image.height):
|
||||
add_block(block)
|
||||
|
||||
Reference in new issue
Block a user