Spaces:
Paused
Paused
File size: 2,896 Bytes
0e50d91 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | {
"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, \"<syntax_only>\", \"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."
]
}
]
}
|