Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ and a Gradescope autograder zip. Alpha: the API changes without deprecation.
maturin builds it into platform wheels together with
`src/mogs/`. The version is `[workspace.package] version` in `Cargo.toml`.
`src/mogs/_binary.py` finds and runs the installed executable.
- `crates/mogs-schema/`: the JSON messages between the `mogs` executable and
Python (job, events, bundle, inspect, `results.json`) as Rust types. Every
message but `results.json` has `"schema": 1`: bump `SCHEMA` there and in
`src/mogs/grader/wire.py` together. `schemas/` holds the JSON Schemas
generated from the types. `MOGS_BLESS=1 cargo test` rewrites them, and
`tests/test_schemas.py` checks what Python writes against them.
- `tests/`: pytest suite. `cargo test` runs the Rust tests.
- `tests/e2e/`: end-to-end tests. The `docker` ones build the demo autograder
into Gradescope's base image (`tests/e2e/Dockerfile`) and grade submissions
Expand Down
201 changes: 201 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/mogs"]
members = ["crates/mogs", "crates/mogs-schema"]
resolver = "3"

[workspace.package]
Expand Down
14 changes: 14 additions & 0 deletions crates/mogs-schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "mogs-schema"
description = "The JSON messages between the mogs executable and its Python processes."
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
publish = false

[dependencies]
indexmap = { version = "2", features = ["serde"] }
schemars = { version = "1", features = ["indexmap2", "preserve_order"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
94 changes: 94 additions & 0 deletions crates/mogs-schema/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//! The tests the grader runs, as `mogs.grader.bundle.GradingBundle` writes them.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Everything a grading child needs besides the submission.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Bundle {
/// Format version, `SCHEMA`.
#[serde(deserialize_with = "crate::version")]
#[schemars(extend("const" = crate::SCHEMA))]
pub schema: u32,
/// The assignment config the grader needs.
pub config: BundleConfig,
/// Body of the notebook's setup cell, run before the test cells.
pub setup_code: String,
/// Test cells in file order.
pub cells: Vec<TestCell>,
/// Hidden cells without tests, in file order.
pub helpers: Vec<HiddenHelper>,
}

/// The assignment config, without the host path of `requirements`.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct BundleConfig {
/// Assignment name.
pub name: String,
/// File name of the source notebook.
pub notebook: String,
/// Questions in notebook order.
pub questions: Vec<BundleQuestion>,
/// Data files and folders shipped with the notebook, relative to it.
pub files: Vec<String>,
/// Seconds per test.
pub timeout: f64,
/// Seconds for the whole grading run.
pub budget: f64,
/// MB per grading process.
pub memory_mb: u32,
/// Python version on Gradescope.
pub python: String,
}

/// One question of the config.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct BundleQuestion {
/// Question id, e.g. `q1`.
pub id: String,
/// Question title.
pub title: String,
/// Points for the question.
pub points: f64,
/// Whether the question is graded by hand.
pub manual: bool,
}

/// One test cell of the source notebook.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct TestCell {
/// Question id of the cell's tests.
pub qid: String,
/// The file name the runner compiles the cell under, which tracebacks and syntax errors
/// show: `<qid>-tests` for a cell of the notebook, the path relative to the notebook for
/// a public test file (as `selfcheck` runs it).
pub label: String,
/// Whether the cell is marked `# HIDDEN`.
pub hidden: bool,
/// Cell body, run as a module.
pub source: String,
/// Test function names, in file order.
pub tests: Vec<String>,
/// Student names the cell refers to, bound from the submission.
pub uses: Vec<String>,
/// Names the cell reads from hidden helpers. Empty for public cells.
pub needs: Vec<String>,
}

/// A `# HIDDEN` cell without tests, such as data or helpers for hidden tests.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct HiddenHelper {
/// Cell body, run as a module.
pub source: String,
/// Names the cell binds at top level.
pub defines: Vec<String>,
/// Student names the cell refers to, bound from the submission.
pub uses: Vec<String>,
/// Names the cell reads from other hidden helpers.
pub needs: Vec<String>,
}
Loading
Loading