{ "nbformat": 4, "nbformat_minor": 4, "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.10.0" } }, "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `syntax_only.ipynb`\n", "\n", "**Purpose:** confirm the notebook kernel runs and Python **syntax** is valid.\n", "\n", "- No app logic, no repo imports, no training.\n", "- Run **Run all**; every cell should complete without error." ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Cell 1 — stdlib only\n", "import ast\n", "import json\n", "import sys\n", "from pathlib import Path\n", "\n", "print(\"Python:\", sys.version.split()[0])\n", "print(\"OK: stdlib imports\")" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Cell 2 — language syntax (no domain code)\n", "x = [n * 2 for n in range(3)]\n", "d = {\"a\": 1, **{\"b\": 2}}\n", "y = (n := 1) + 1\n", "\n", "match y:\n", " case 2:\n", " z = \"two\"\n", " case _:\n", " z = \"other\"\n", "\n", "assert x == [0, 2, 4] and d[\"b\"] == 2 and z == \"two\"\n", "print(\"OK: comprehensions, dict unpack, walrus, match\")" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Cell 3 — parse a multi-line string (syntax check only)\n", "src = \"\"\"\n", "def _demo(a: int) -> str:\n", " return f\"v={a}\"\n", "\"\"\"\n", "ast.parse(src)\n", "compile(src, \"\", \"exec\")\n", "print(\"OK: ast.parse + compile\")" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Cell 4 — optional third-party imports (skip if not installed)\n", "_optional = [\"numpy\", \"torch\", \"transformers\", \"pydantic\"]\n", "for name in _optional:\n", " try:\n", " __import__(name)\n", " print(\"OK:\", name)\n", " except ImportError:\n", " print(\"(skip)\", name, \"— not installed\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If every code cell printed `OK`, your kernel and basic syntax path are fine. Use `train_grpo_smoke.ipynb` for repo/env checks." ] } ] }