Skip to content

Commit 5943e3b

Browse files
committed
fixes #80
1 parent 7dabebd commit 5943e3b

File tree

7 files changed

+66
-70
lines changed

7 files changed

+66
-70
lines changed

execnb/nbio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def _read_json(self, encoding=None, errors=None):
2020

2121
# %% ../nbs/01_nbio.ipynb
2222
class NbCell(AttrDict):
23-
def __init__(self, idx, cell, id=None):
23+
def __init__(self, idx, cell):
2424
super().__init__(cell)
2525
self.idx_ = idx
26-
self.id = id or rtoken_hex(4)
26+
if 'id' not in self: self.id = rtoken_hex(4)
2727
if 'source' in self: self.set_source(self.source)
2828

2929
def set_source(self, source):

nbs/01_nbio.ipynb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@
106106
{
107107
"data": {
108108
"text/plain": [
109-
"{'kernelspec': {'display_name': 'Python 3 (ipykernel)',\n",
110-
" 'language': 'python',\n",
111-
" 'name': 'python3'}}"
109+
"{'solveit_dialog_mode': 'learning', 'solveit_ver': 2}"
112110
]
113111
},
114112
"execution_count": null,
@@ -138,13 +136,15 @@
138136
"data": {
139137
"text/plain": [
140138
"[{'cell_type': 'markdown',\n",
139+
" 'id': '801558df',\n",
141140
" 'metadata': {},\n",
142141
" 'source': ['## A minimal notebook']},\n",
143142
" {'cell_type': 'code',\n",
144143
" 'execution_count': None,\n",
145-
" 'metadata': {},\n",
144+
" 'id': 'e2147a69',\n",
145+
" 'metadata': {'time_run': '2026-01-04T20:52:49.901559+00:00'},\n",
146146
" 'outputs': [{'data': {'text/plain': ['2']},\n",
147-
" 'execution_count': None,\n",
147+
" 'execution_count': 0,\n",
148148
" 'metadata': {},\n",
149149
" 'output_type': 'execute_result'}],\n",
150150
" 'source': ['# Do some arithmetic\\n', '1+1']}]"
@@ -176,10 +176,10 @@
176176
"source": [
177177
"#| export\n",
178178
"class NbCell(AttrDict):\n",
179-
" def __init__(self, idx, cell, id=None):\n",
179+
" def __init__(self, idx, cell):\n",
180180
" super().__init__(cell)\n",
181181
" self.idx_ = idx\n",
182-
" self.id = id or rtoken_hex(4)\n",
182+
" if 'id' not in self: self.id = rtoken_hex(4)\n",
183183
" if 'source' in self: self.set_source(self.source)\n",
184184
"\n",
185185
" def set_source(self, source):\n",
@@ -248,11 +248,11 @@
248248
"```python\n",
249249
"{ 'cell_type': 'code',\n",
250250
" 'execution_count': None,\n",
251-
" 'id': 'e525badc',\n",
251+
" 'id': 'e2147a69',\n",
252252
" 'idx_': 1,\n",
253-
" 'metadata': {},\n",
253+
" 'metadata': {'time_run': '2026-01-04T20:52:49.901559+00:00'},\n",
254254
" 'outputs': [ { 'data': {'text/plain': ['2']},\n",
255-
" 'execution_count': None,\n",
255+
" 'execution_count': 0,\n",
256256
" 'metadata': {},\n",
257257
" 'output_type': 'execute_result'}],\n",
258258
" 'source': '# Do some arithmetic\\n1+1'}\n",
@@ -261,14 +261,14 @@
261261
"text/plain": [
262262
"{'cell_type': 'code',\n",
263263
" 'execution_count': None,\n",
264-
" 'metadata': {},\n",
264+
" 'id': 'e2147a69',\n",
265+
" 'metadata': {'time_run': '2026-01-04T20:52:49.901559+00:00'},\n",
265266
" 'outputs': [{'data': {'text/plain': ['2']},\n",
266-
" 'execution_count': None,\n",
267+
" 'execution_count': 0,\n",
267268
" 'metadata': {},\n",
268269
" 'output_type': 'execute_result'}],\n",
269270
" 'source': '# Do some arithmetic\\n1+1',\n",
270-
" 'idx_': 1,\n",
271-
" 'id': 'e525badc'}"
271+
" 'idx_': 1}"
272272
]
273273
},
274274
"execution_count": null,
@@ -343,7 +343,7 @@
343343
{
344344
"data": {
345345
"text/plain": [
346-
"\"{'cell_type': 'markdown', 'metadata': {}, 'source': '## A minimal notebook', 'idx_': 0, 'id': '3b935699'}\""
346+
"\"{'cell_type': 'markdown', 'id': '801558df', 'metadata': {}, 'source': '## A minimal notebook', 'idx_': 0}\""
347347
]
348348
},
349349
"execution_count": null,
@@ -426,7 +426,7 @@
426426
"{ 'cell_type': 'code',\n",
427427
" 'directives_': {},\n",
428428
" 'execution_count': 0,\n",
429-
" 'id': 'ec06b0ff',\n",
429+
" 'id': 'f6ddf5a3',\n",
430430
" 'idx_': 0,\n",
431431
" 'metadata': {},\n",
432432
" 'outputs': [],\n",
@@ -441,7 +441,7 @@
441441
" 'metadata': {},\n",
442442
" 'outputs': [],\n",
443443
" 'idx_': 0,\n",
444-
" 'id': 'ec06b0ff'}"
444+
" 'id': 'f6ddf5a3'}"
445445
]
446446
},
447447
"execution_count": null,
@@ -517,7 +517,7 @@
517517
"minimal_fn = Path('../tests/minimal.ipynb')\n",
518518
"minimal = read_nb(minimal_fn)\n",
519519
"minimal_dict = _read_json(minimal_fn)\n",
520-
"# assert minimal_dict==nb2dict(minimal)"
520+
"assert minimal_dict==nb2dict(minimal)"
521521
]
522522
},
523523
{
@@ -599,7 +599,7 @@
599599
"try:\n",
600600
" minimal_txt = minimal_fn.read_text()\n",
601601
" write_nb(minimal, tmp)\n",
602-
" # test_eq(minimal_txt, tmp.read_text())\n",
602+
" test_eq(minimal_txt, tmp.read_text())\n",
603603
"finally: tmp.unlink()"
604604
]
605605
},
@@ -621,7 +621,7 @@
621621
"name": "stdout",
622622
"output_type": "stream",
623623
"text": [
624-
"[{'cell_type': 'code', 'execution_count': 0, 'id': '8cbb61b0', 'metadata': {}, 'outputs': [], 'source': 'print(1)', 'idx_': 0}]\n"
624+
"[{'cell_type': 'code', 'execution_count': 0, 'id': '5e7ed95f', 'metadata': {}, 'outputs': [], 'source': 'print(1)', 'idx_': 0}]\n"
625625
]
626626
}
627627
],

tests/clean.ipynb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@
4545
]
4646
}
4747
],
48-
"metadata": {
49-
"kernelspec": {
50-
"display_name": "Python 3 (ipykernel)",
51-
"language": "python",
52-
"name": "python3"
53-
}
54-
},
48+
"metadata": {},
5549
"nbformat": 4,
5650
"nbformat_minor": 5
5751
}

tests/error.ipynb

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@
44
"cell_type": "code",
55
"execution_count": null,
66
"id": "c2ce6772-1ff0-4c56-a3b2-3dbf23d96757",
7-
"metadata": {},
8-
"outputs": [],
7+
"metadata": {
8+
"time_run": "2026-01-04T20:53:19.756058+00:00"
9+
},
10+
"outputs": [
11+
{
12+
"ename": "ModuleNotFoundError",
13+
"evalue": "No module named 'err'",
14+
"output_type": "error",
15+
"traceback": [
16+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
17+
"\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)",
18+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 1\u001b[39m",
19+
"\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merr\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m foo",
20+
"",
21+
"\u001b[31mModuleNotFoundError\u001b[39m: No module named 'err'"
22+
]
23+
}
24+
],
925
"source": [
1026
"from err import foo"
1127
]
@@ -24,23 +40,8 @@
2440
}
2541
],
2642
"metadata": {
27-
"kernelspec": {
28-
"display_name": "Python 3 (ipykernel)",
29-
"language": "python",
30-
"name": "python3"
31-
},
32-
"language_info": {
33-
"codemirror_mode": {
34-
"name": "ipython",
35-
"version": 3
36-
},
37-
"file_extension": ".py",
38-
"mimetype": "text/x-python",
39-
"name": "python",
40-
"nbconvert_exporter": "python",
41-
"pygments_lexer": "ipython3",
42-
"version": "3.9.7"
43-
}
43+
"solveit_dialog_mode": "learning",
44+
"solveit_ver": 2
4445
},
4546
"nbformat": 4,
4647
"nbformat_minor": 5

tests/minimal.ipynb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5+
"id": "801558df",
56
"metadata": {},
67
"source": [
78
"## A minimal notebook"
@@ -10,15 +11,18 @@
1011
{
1112
"cell_type": "code",
1213
"execution_count": null,
13-
"metadata": {},
14+
"id": "e2147a69",
15+
"metadata": {
16+
"time_run": "2026-01-04T20:52:49.901559+00:00"
17+
},
1418
"outputs": [
1519
{
1620
"data": {
1721
"text/plain": [
1822
"2"
1923
]
2024
},
21-
"execution_count": null,
25+
"execution_count": 0,
2226
"metadata": {},
2327
"output_type": "execute_result"
2428
}
@@ -30,12 +34,9 @@
3034
}
3135
],
3236
"metadata": {
33-
"kernelspec": {
34-
"display_name": "Python 3 (ipykernel)",
35-
"language": "python",
36-
"name": "python3"
37-
}
37+
"solveit_dialog_mode": "learning",
38+
"solveit_ver": 2
3839
},
3940
"nbformat": 4,
40-
"nbformat_minor": 4
41+
"nbformat_minor": 5
4142
}

tests/params.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"cell_type": "code",
55
"execution_count": null,
66
"id": "a63ce885",
7-
"metadata": {},
7+
"metadata": {
8+
"time_run": "2026-01-04T20:52:46.502210+00:00"
9+
},
810
"outputs": [],
911
"source": [
1012
"a=1"
@@ -14,7 +16,9 @@
1416
"cell_type": "code",
1517
"execution_count": null,
1618
"id": "ea528db5",
17-
"metadata": {},
19+
"metadata": {
20+
"time_run": "2026-01-04T20:52:46.506607+00:00"
21+
},
1822
"outputs": [
1923
{
2024
"name": "stdout",
@@ -30,11 +34,8 @@
3034
}
3135
],
3236
"metadata": {
33-
"kernelspec": {
34-
"display_name": "Python 3 (ipykernel)",
35-
"language": "python",
36-
"name": "python3"
37-
}
37+
"solveit_dialog_mode": "learning",
38+
"solveit_ver": 2
3839
},
3940
"nbformat": 4,
4041
"nbformat_minor": 5

tests/ran.ipynb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"cell_type": "code",
4040
"execution_count": null,
4141
"id": "b123d6d0",
42-
"metadata": {},
42+
"metadata": {
43+
"time_run": "2026-01-04T20:51:54.553810+00:00"
44+
},
4345
"outputs": [
4446
{
4547
"name": "stdout",
@@ -54,7 +56,7 @@
5456
"2"
5557
]
5658
},
57-
"execution_count": null,
59+
"execution_count": 0,
5860
"metadata": {},
5961
"output_type": "execute_result"
6062
}
@@ -113,11 +115,8 @@
113115
}
114116
],
115117
"metadata": {
116-
"kernelspec": {
117-
"display_name": "Python 3 (ipykernel)",
118-
"language": "python",
119-
"name": "python3"
120-
}
118+
"solveit_dialog_mode": "learning",
119+
"solveit_ver": 2
121120
},
122121
"nbformat": 4,
123122
"nbformat_minor": 5

0 commit comments

Comments
 (0)