perf: skip fact extraction for fully graded projects on batch retries
This commit is contained in:
@@ -358,6 +358,18 @@ def _run_project(batch_id, project_id, session_factory, client_factory, embedder
|
||||
with session_factory() as db:
|
||||
batch = db.get(ScoringBatch, batch_id)
|
||||
project = db.get(Project, project_id)
|
||||
existing = db.scalars(select(CriterionScore).where(CriterionScore.batch_id == batch_id,
|
||||
CriterionScore.project_id == project_id)).all()
|
||||
graded = {score.criterion_id for score in existing
|
||||
if score.status in (STATUS_SCORED, STATUS_REVIEWED)}
|
||||
criteria = batch.rubric_snapshot["criteria"]
|
||||
if all(criterion["criterion_id"] in graded for criterion in criteria):
|
||||
# A retry in a multi-student batch must not spend two more model calls
|
||||
# extracting facts for a student whose scores will all be skipped.
|
||||
db.execute(update(ScoringBatch).where(ScoringBatch.id == batch_id).values(
|
||||
progress_done=ScoringBatch.progress_done + len(criteria)))
|
||||
db.commit()
|
||||
return 0, 0
|
||||
try:
|
||||
client = client_factory(db, batch)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user