Skip to main content

olympiad-lab

Checkpoints for AI Olympiad training labs.

A lab notebook calls a few short steps (ck.load, ck.look, ck.split, ...) between the student's own code. Each step describes what was just built and sends that description to the scorer server of the course. The server decides whether the step passes and answers with one line. The library holds no expected value, no rule and no label: the notebook sends evidence, the server decides.

Install

pip install olympiad-lab

The only dependency is requests. NumPy, pandas, torch and the other libraries of a lab are used when the notebook has already imported them, and never imported by this package.

What this library records

Read this before you use it. From the moment ck.start() runs, and only in that notebook:

  • Every cell you run: the first 4000 characters of its source, how long it took, whether it raised, and for an error its type, its message and the last 15 lines of the traceback.
  • What each step describes: types, shapes, row counts, column names, data types, small number summaries (minimum, maximum, mean, count of missing values) and the first 200 characters of how the object prints. For ck.split the row ids (or their hashes for very large sets). For ck.loop up to 200 loss values. For ck.eval the score.
  • What you hand in: the submission file, the answers of ck.reading (including the source of the metric function you pass), and at ck.finish() the notebook itself. When the notebook program does not hand it over, or the saved file is older than the cells that ran, the cells this kernel ran are sent in its place.
  • Where it runs: Colab, Kaggle, Jupyter, VS Code or script; the Python and IPython versions; the operating system name; the GPU model.

It does not record other notebooks, other files, the values of environment variables, or your account. Cells that ran before ck.start() are not recorded.

Three things are taken out on your computer, before anything is stored or sent, from cell source, error messages, tracebacks and the notebook:

  • Your student id becomes <student_id>.
  • Anything that looks like a secret becomes <redacted>: access tokens of well-known shapes (Hugging Face, OpenAI, GitHub, Google, Slack, AWS, Kaggle, a private key); a value given to a name such as api_key, HF_TOKEN or os.environ["KAGGLE_KEY"], also in a line such as %env KAGGLE_KEY=..., when it has the shape of a key (twelve or more letters and digits, mixed through one another); any value given to a name that ends in password; the password inside an address and the token of an Authorization header.
  • Names: your home folder is written as ~, and the account name that Colab writes into a notebook is removed.

Code that holds no secret stays exactly as you wrote it: label_key = "category_name" and stop_token = "<|end_of_text|>" are not keys, although their names end like one.

This is a safety net, not a guarantee. A secret that looks like any other word cannot be told apart from one, so do not paste keys into a notebook: use getpass.getpass() or the secrets panel of Colab or Kaggle.

The records go to the scorer server over HTTPS and are used by the instructors of the course for assessment. A copy is kept next to the notebook in olympiad_<lab>_<student>.jsonl. ck.start() says so every time:

This lab records cell runs, cell source and errors for assessment.

Use

!pip -q install olympiad-lab
from olympiad import ck

ck.start("nlp-01", "S07-K4QX")                  # the lab id and your student id
ck.load(train=train_df, test=test_df)           # LOAD: the data is in memory
ck.look(train_df.head(), size=len(train_df))    # LOOK: shows a sample, prints the size
ck.split(train_ids=tr.id, val_ids=va.id)        # SPLIT: no row in both sets
ck.batch(X_tr[:32], y_tr[:32])                  # BATCH: one batch or feature table
ck.model(model, X_va[:32])                      # MODEL: runs the model on one batch
ck.loop(losses)                                 # LOOP: the training loss fell
ck.eval(val_f1, metric="macro_f1")              # EVAL: prints the validation score
ck.submit("submission.csv")                     # SUBMIT: a file, a DataFrame or the text of a file
ck.finish()                                     # sends what waits, prints a summary

Every step prints a tick or a cross, one sentence, and a strip of the lab's parts:

✓ BATCH: Batch shape and data type are right.
Parts 4 of 7: LOAD ✓ | LOOK ✓ | SPLIT ✓ | BATCH ✓ | MODEL - | EVAL - | SUBMIT -

In a notebook the same block is shown as a small box that reads the same in a light and in a dark theme. A part that the lab does not use answers ! LOOP is not part of this lab. A step that runs before ck.start() does nothing and says:

! olympiad: run the first cell (ck.start) before this one.

Other steps:

Step What it does
ck.reading(metric_fn=..., trivial={...}, rewards="b", format={...}, facts="...") Sends the task reading. It is scored after the lab; no score is shown.
ck.model(...), ck.loop(...), ck.eval(...), ck.submit(...) with stage="frozen" Names the stage in labs that compare a frozen and a fine-tuned model.
ck.drill_start("id"), ck.drill_check("id", result) A timed drill: the server stamps the start and answers the check.
ck.status() The minute, the parts passed, the submissions used and left.
ck.export() One file with everything recorded locally. Returns its path.
ck.last The last answer as a dictionary.

Running a cell again is always safe. ck.start() never resets a session or its clock, a check may be repeated as often as you like (the first pass counts), and the same submission file sent twice uses one attempt. ck.start() with another lab id or another student id in the same notebook says so in one line (! START: switched from lab nlp-01 to lab cv-02.) and goes on with the new session; what the old one still had to send is sent in the background.

No line the library prints spells your student id: the id is your key to the scorer, and what a cell prints stays in the notebook. Where a file is named after you (the export), the line shows <student_id> in its place.

The steps take what a notebook naturally holds:

  • A batch may be (inputs, targets) as a loader yields it, or a dict such as {"image": ..., "label": ...}.
  • ck.load takes an (X, y) pair, a data loader, or a dict of splits such as {"train": ..., "test": ...}.
  • A loss history may be a list, an array, one record per epoch (a dict, or a pair such as (train_loss, val_loss): the training loss is read, the two are never mixed), a table, or the history object of Keras or of a Hugging Face trainer.
  • A model may return (logits, hidden); a fitted scikit-learn classifier also reports how many classes it knows.
  • The metric function of ck.reading is called as metric_fn(y_true, y_pred) with NumPy arrays when the notebook has loaded NumPy, and with plain lists when that raises or when NumPy is not loaded. A function written for lists that joins the two with + is recognised and gets lists.
  • ck.submit sends a file or the text of a file as it is. A DataFrame or a list of records is written as CSV, or as JSON lines (one object per row) in a lab that asks for them.

An answer of ck.reading that cannot be read is named in one line while the reading is still open.

The cases for the metric function come with the answer to ck.start(). A reading that is made before that answer is here (no connection yet, or a notebook opened before the lab opens) is kept with your function. The next step that finds the session open runs the function on the cases and sends the reading again, complete (Task reading received (minute 8).). If the function gives no number then, one line asks you to run the reading cell again.

ck.finish() hands in the notebook. In Colab that is the notebook as it is on the page. In Jupyter and VS Code it is the saved file, and a file that was saved before the last cells ran is not the notebook you ran. The step notices that, sends the cells the kernel ran instead and says:

✓ FINISH: received at minute 171. Cell history saved.
! Your notebook file was saved before the last cells ran. Save the notebook, then run this cell again.

Save the notebook and run the cell again; it then answers Notebook saved.

What it never does

  • It never raises into your code. Whatever you pass and whatever happens to the network, a step prints at most one line such as ! olympiad: the LOAD step could not finish (TypeError); your code is not affected. Only KeyboardInterrupt and SystemExit pass through.
  • It never blocks for long. Each step has a time budget: 15 seconds for start, 6 for a check, a reading, a drill or the status, 40 for submit and finish. Cell records travel in a background thread. In Colab, ck.finish() first asks the notebook page for the notebook and says so (Reading the notebook; this can take a few seconds.); without an answer it goes on after 20 seconds with the cells the kernel ran.
  • It never changes your objects. The model is run on the batch you give, without training it.
  • It never imports a heavy library. NumPy, pandas, torch and the others are only looked at when your notebook has already imported them.
  • It stays quiet in worker processes. A worker of multiprocessing or of a DataLoader, forked or spawned, that reaches a step (even ck.start at the top of a script) sends nothing and prints nothing.

When the server cannot be reached

The library writes everything to the local file first and sends it second. So when the server does not answer:

! START: no answer from the server. Working offline: everything is saved locally and sent when the connection is back.
! LOAD: no answer from the server yet. Saved locally; it will be sent again.

Keep working. Checks and readings that got no answer are sent again in the background (a check that arrives this way is marked as late, and the server counts every check once however often it is sent). A submission and ck.finish() are not sent again by themselves: run the cell again when the connection is back. After a connection that failed, the steps of the next ten seconds do not wait for the server again; they are saved and queued at once.

A drill is timed, so its start is never sent later: the clock would start when the network comes back and not when you began. A ck.drill_start without an answer says so, and the check of a drill whose clock is not running says the same:

! DRILL mem-loop: no answer from the server yet, so the clock has not started. Run this cell again when the connection is back.

ck.export() is for the case that the connection never comes back. Run it at the end and send the file to your instructor:

ck.export()

It writes olympiad_export_<lab>_<student>_<utc>.json.gz into the working folder (in Colab it also offers the download) and returns the path. The line it prints, and the value the cell shows for the call, write <student_id> where the name of the file holds your id. The file holds every record of the session, including the submission files, so the lab can be scored later. The times in it are your computer's, not the server's.

Supported environments

  • Python 3.9, 3.10, 3.11, 3.12 and 3.13.
  • Google Colab, Kaggle notebooks (internet on), Jupyter (Notebook and Lab), VS Code notebooks and plain Python scripts. In a script there are no cells, so only the steps are recorded.
  • IPython 7.34 and newer with ipykernel 6.17 and newer (the versions of Colab), up to the current releases.
  • Evidence is built for plain Python objects, NumPy, pandas, torch, scikit-learn, Keras and Hugging Face objects, whichever of them the notebook uses.

Settings

Setting Meaning
ck.start(lab, student_id, server="https://...") Use another scorer server.
OLYMPIAD_SERVER_URL The same, as an environment variable. The argument wins.
OLYMPIAD_STUDENT_ID The student id for ck.start(lab) without one (automated runs).
OLYMPIAD_AUDIT_DIR Audit mode, see below.

Without a setting the library talks to the server it was written for, https://us-central1-ka-ai-olympiad.cloudfunctions.net/api.

Audit mode

With OLYMPIAD_AUDIT_DIR set to a folder, nothing touches the network. Every call is appended to audit.jsonl in that folder as {"route", "body", "ts"}, the body exactly as it would have been sent; submitted files are copied there as submission_<n>_<stage>__<filename> and the submit body names the copy under file instead of carrying the content. Every step prints ! LOAD recorded (audit mode). Instructors use it to run a handed-in notebook again and compare.

No start answer arrives in this mode. A tool that knows the lab can leave its public info in the folder as lab.json (the lab object of a start answer); a table handed to ck.submit is then written in the lab's file format and stages are spelled as the lab spells them. Without the file a table is written as CSV.

The local file, for tool authors

olympiad_<lab>_<student>.jsonl is append-only, one JSON object per line:

{"k": "event", "ts": "...Z", "sent": false, "session_id": "...", "boot": "a3f9c2d1", "event": {"seq": 12, "type": "cell_run", ...}}
{"k": "call",  "ts": "...Z", "sent": false, "session_id": "...", "id": "a3f9c2d1-c4", "route": "/v1/check", "body": {...}, "response": null}
{"k": "ack",   "ts": "...Z", "boot": "a3f9c2d1", "seq": [10, 12]}
{"k": "ack",   "ts": "...Z", "id": "a3f9c2d1-c4", "sent": true, "response": {...}}

The body of a check carries its call_id, the same on every retry. An ack line records what happened later to earlier lines: a range of events the server accepted, or how a call ended. ck.export() folds them in: the exported file is gzip-compressed JSON lines with event and call lines only, where sent is true for what the server accepted and response holds its answer (or its error). A kernel that was restarted appends to the same file under a new boot id. A finish call is kept without the notebook while it is under way; only one that got no answer is kept in full, as a second line.

The file may be renamed, moved or deleted while the notebook runs: the running kernel still finds every line for ck.export(). A line that was cut off (a kernel that was killed while it wrote) is skipped by every reader and never swallows the next one. Above 200 MB new cell records are kept without their source (the notebook says so once), and a submission is kept in full only while it has no answer.

Development

python -m pip install -e . pytest numpy pandas ipython ipykernel nbclient
python -m pytest

The tests run against a small fake scorer on localhost (tests/fake_server.py) and cannot reach the real one: the built-in address is replaced and sockets are confined to the local machine.

Licence

MIT. See LICENSE.

Metadata

Release files for olympiad-lab 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for olympiad-lab 0.1.1
File Size Uploaded Provenance Actions
olympiad_lab-0.1.1.tar.gz 375.9 kB With provenance Details for olympiad_lab-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for olympiad-lab 0.1.1
File Interpreter ABI Platform Actions
olympiad_lab-0.1.1-py3-none-any.whl Python 3 none any Details for olympiad_lab-0.1.1-py3-none-any.whl

Total release size: 520.1 kB

Release files / olympiad_lab-0.1.1.tar.gz

Download URL olympiad_lab-0.1.1.tar.gz
Size 375.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0379e5cc3d25db5b6c7ee6b1d213da535e1349634feef82dfb8c28bb4e25e98c
BLAKE2b-256 checksum
How to use checksums
65c31bf7e3e78f0ed0524c8202c4939a48a3023737e064d1eff4445f9dda1497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / olympiad_lab-0.1.1-py3-none-any.whl

Download URL olympiad_lab-0.1.1-py3-none-any.whl
Size 144.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afa06e210ede428ff2f48af260d84cddc4cbea8d4851486deedd374322cde917
BLAKE2b-256 checksum
How to use checksums
2ff9b85ab37a3117dc1bc9878660b6eee1953c95103912ceac3c45e77cf0fa24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for olympiad-lab 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for olympiad_lab-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page