anuragredbus commited on
Commit
0e50d91
·
1 Parent(s): b55c1ff

add training/syntax_only.ipynb — kernel + Python syntax only (no project logic)

Browse files
Files changed (1) hide show
  1. training/syntax_only.ipynb +105 -0
training/syntax_only.ipynb ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 4,
4
+ "metadata": {
5
+ "kernelspec": {
6
+ "display_name": "Python 3",
7
+ "language": "python",
8
+ "name": "python3"
9
+ },
10
+ "language_info": {
11
+ "name": "python",
12
+ "version": "3.10.0"
13
+ }
14
+ },
15
+ "cells": [
16
+ {
17
+ "cell_type": "markdown",
18
+ "metadata": {},
19
+ "source": [
20
+ "# `syntax_only.ipynb`\n",
21
+ "\n",
22
+ "**Purpose:** confirm the notebook kernel runs and Python **syntax** is valid.\n",
23
+ "\n",
24
+ "- No app logic, no repo imports, no training.\n",
25
+ "- Run **Run all**; every cell should complete without error."
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "metadata": {},
31
+ "execution_count": null,
32
+ "outputs": [],
33
+ "source": [
34
+ "# Cell 1 — stdlib only\n",
35
+ "import ast\n",
36
+ "import json\n",
37
+ "import sys\n",
38
+ "from pathlib import Path\n",
39
+ "\n",
40
+ "print(\"Python:\", sys.version.split()[0])\n",
41
+ "print(\"OK: stdlib imports\")"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "metadata": {},
47
+ "execution_count": null,
48
+ "outputs": [],
49
+ "source": [
50
+ "# Cell 2 — language syntax (no domain code)\n",
51
+ "x = [n * 2 for n in range(3)]\n",
52
+ "d = {\"a\": 1, **{\"b\": 2}}\n",
53
+ "y = (n := 1) + 1\n",
54
+ "\n",
55
+ "match y:\n",
56
+ " case 2:\n",
57
+ " z = \"two\"\n",
58
+ " case _:\n",
59
+ " z = \"other\"\n",
60
+ "\n",
61
+ "assert x == [0, 2, 4] and d[\"b\"] == 2 and z == \"two\"\n",
62
+ "print(\"OK: comprehensions, dict unpack, walrus, match\")"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "metadata": {},
68
+ "execution_count": null,
69
+ "outputs": [],
70
+ "source": [
71
+ "# Cell 3 — parse a multi-line string (syntax check only)\n",
72
+ "src = \"\"\"\n",
73
+ "def _demo(a: int) -> str:\n",
74
+ " return f\"v={a}\"\n",
75
+ "\"\"\"\n",
76
+ "ast.parse(src)\n",
77
+ "compile(src, \"<syntax_only>\", \"exec\")\n",
78
+ "print(\"OK: ast.parse + compile\")"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "code",
83
+ "metadata": {},
84
+ "execution_count": null,
85
+ "outputs": [],
86
+ "source": [
87
+ "# Cell 4 — optional third-party imports (skip if not installed)\n",
88
+ "_optional = [\"numpy\", \"torch\", \"transformers\", \"pydantic\"]\n",
89
+ "for name in _optional:\n",
90
+ " try:\n",
91
+ " __import__(name)\n",
92
+ " print(\"OK:\", name)\n",
93
+ " except ImportError:\n",
94
+ " print(\"(skip)\", name, \"— not installed\")"
95
+ ]
96
+ },
97
+ {
98
+ "cell_type": "markdown",
99
+ "metadata": {},
100
+ "source": [
101
+ "If every code cell printed `OK`, your kernel and basic syntax path are fine. Use `train_grpo_smoke.ipynb` for repo/env checks."
102
+ ]
103
+ }
104
+ ]
105
+ }