MUSA Graderv0.1.0

API reference · grader/models.py · 261 lines

grader.models

Structured result types shared by the engine, the store and the UI.

The contract in design.md section 24 is the source of truth for the on-disk shape: every rubric item keeps both automatic_score and final_score so a manual override never destroys the automated result.

Summary

NameKindDescription
ExecutionRecordclassOutcome of running one student notebook (design.md section 19).
RubricItemResultclassOne graded rubric line (design.md section 24).
SubmissionResultclassEverything known about one student's submission.
GradingProgressclassSnapshot pushed to the UI while grading runs (design.md section 7).
status_icon()function
status_color()function

Constants

NameValueNotes
STATUS_PASS'pass'
STATUS_PARTIAL'partial'
STATUS_FAIL'fail'
STATUS_WARNING'warning'
STATUS_MANUAL_REVIEW'manual_review'
STATUS_EXECUTION_ERROR'execution_error'
STATUS_NOT_FOUND'not_found'
ALL_STATUSES(STATUS_PASS, STATUS_PARTIAL, STATUS_FAIL, STATUS_WARNING, STATUS_MANUAL_REVIEW, STATUS_EXECUTION_ERROR, STATUS_NOT_FOUND)
STATUS_DISPLAY{STATUS_PASS: ('✓', 'green'), STATUS_PARTIAL: ('⚠', 'yellow'), STATUS_WARNING: ('⚠', 'yellow'), STATUS_MANUAL_REVIEW: ('⚠', 'yellow'), STAT…Status -> (icon, colour bucket). Colour is never the only signal (section 15).

Classes

class ExecutionRecord #[source]

dataclass

Outcome of running one student notebook (design.md section 19).

Fields

NameTypeDefaultNotes
successboolFalse
execution_time_secondsfloat0.0
timeoutboolFalse
error_cellint | NoneNone
error_messagestr | NoneNone
tracebackstr''
modestr'docker'
attemptedboolFalse
logstr''
executed_notebook_pathstr | NoneNone

Properties

property status: str #[source]

No description.

Methods

to_dict() -> dict[str, Any] #[source]

No description.

classmethod from_dict(data: dict[str, Any]) -> 'ExecutionRecord' #[source]

No description.

class RubricItemResult #[source]

dataclass

One graded rubric line (design.md section 24).

Fields

NameTypeDefaultNotes
rubric_idstrrequired
namestrrequired
points_possiblefloatrequired
automatic_scorefloat0.0
statusstrSTATUS_NOT_FOUND
confidencefloat1.0
feedbackstr''
evidencedict[str, Any]field(default_factory=dict)
typestr'deterministic'
manual_overrideboolFalseHuman intervention (design.md section 11) — never overwrites the automated value.
manual_scorefloat | NoneNone
override_reasonstr''

Properties

property final_score: float #[source]

The manual score when overridden, otherwise the automatic score.

property needs_review: bool #[source]

No description.

Methods

to_dict() -> dict[str, Any] #[source]

No description.

classmethod from_dict(data: dict[str, Any]) -> 'RubricItemResult' #[source]

No description.

class SubmissionResult #[source]

dataclass

Everything known about one student's submission.

Fields

NameTypeDefaultNotes
student_idstrrequired
display_namestr''
notebook_pathstr | NoneNone
submission_dirstr | NoneNone
itemslist[RubricItemResult]field(default_factory=list)
executionExecutionRecordfield(default_factory=ExecutionRecord)
discovery_warningslist[str]field(default_factory=list)
review_reasonslist[str]field(default_factory=list)
reviewedboolFalse
graded_atstr | NoneNone
statusstr'pending'pending | graded | error | skipped
errorstr | NoneNone
artifactsdict[str, Any]field(default_factory=dict)

Properties

property max_score: float #[source]

Sum of the items' possible points.

property automatic_total: float #[source]

No description.

property total_score: float #[source]

Sum of the items' final scores.

property percentage: float | None #[source]

No description.

property confidence: float | None #[source]

Lowest item confidence — the weakest link decides trust in the grade.

property has_manual_override: bool #[source]

No description.

property needs_review: bool #[source]

No description.

Methods

open_review_reasons() -> list[str] #[source]

No description.

item(rubric_id: str) -> RubricItemResult | None #[source]

No description.

to_dict() -> dict[str, Any] #[source]

No description.

classmethod from_dict(data: dict[str, Any]) -> 'SubmissionResult' #[source]

No description.

class GradingProgress #[source]

dataclass

Snapshot pushed to the UI while grading runs (design.md section 7).

Fields

NameTypeDefaultNotes
totalint0
completedint0
successfulint0
flaggedint0
failedint0
current_studentstr | NoneNone
stagestr'idle'
stagesdict[str, str]field(default_factory=dict)
finishedboolFalse
messagestr''

Properties

property remaining: int #[source]

No description.

Methods

to_dict() -> dict[str, Any] #[source]

No description.

Functions

status_icon(status: str) -> str #[source]

No description.

status_color(status: str) -> str #[source]

No description.