Skip to content

Commit 43a6160

Browse files
committed
fix shell to self
1 parent fd8cb8a commit 43a6160

File tree

6 files changed

+40
-62
lines changed

6 files changed

+40
-62
lines changed

00_xml.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"\n",
4040
"from fastcore.utils import *\n",
4141
"from fastcore.meta import delegates\n",
42-
"from IPython import display"
42+
"try: from IPython import display\n",
43+
"except: display=None"
4344
]
4445
},
4546
{
@@ -771,7 +772,7 @@
771772
],
772773
"metadata": {
773774
"kernelspec": {
774-
"display_name": "Python 3 (ipykernel)",
775+
"display_name": "python3",
775776
"language": "python",
776777
"name": "python3"
777778
}

01_lmcode.ipynb

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "efe78920",
77
"metadata": {},
88
"outputs": [],
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 2,
31+
"execution_count": null,
3232
"id": "873000d7",
3333
"metadata": {},
3434
"outputs": [],
@@ -48,7 +48,7 @@
4848
},
4949
{
5050
"cell_type": "code",
51-
"execution_count": 3,
51+
"execution_count": null,
5252
"id": "4703296a",
5353
"metadata": {},
5454
"outputs": [],
@@ -73,7 +73,7 @@
7373
},
7474
{
7575
"cell_type": "code",
76-
"execution_count": 4,
76+
"execution_count": null,
7777
"id": "84cadbec-0b34-4669-bfc9-6bf790816035",
7878
"metadata": {},
7979
"outputs": [],
@@ -112,7 +112,7 @@
112112
},
113113
{
114114
"cell_type": "code",
115-
"execution_count": 5,
115+
"execution_count": null,
116116
"id": "15b72cb2",
117117
"metadata": {},
118118
"outputs": [
@@ -122,7 +122,7 @@
122122
"479001600"
123123
]
124124
},
125-
"execution_count": 5,
125+
"execution_count": null,
126126
"metadata": {},
127127
"output_type": "execute_result"
128128
}
@@ -133,7 +133,7 @@
133133
},
134134
{
135135
"cell_type": "code",
136-
"execution_count": 6,
136+
"execution_count": null,
137137
"id": "632a7ac1",
138138
"metadata": {},
139139
"outputs": [
@@ -143,7 +143,7 @@
143143
"'2'"
144144
]
145145
},
146-
"execution_count": 6,
146+
"execution_count": null,
147147
"metadata": {},
148148
"output_type": "execute_result"
149149
}
@@ -162,7 +162,7 @@
162162
},
163163
{
164164
"cell_type": "code",
165-
"execution_count": 7,
165+
"execution_count": null,
166166
"id": "81857615",
167167
"metadata": {},
168168
"outputs": [],
@@ -191,7 +191,7 @@
191191
},
192192
{
193193
"cell_type": "code",
194-
"execution_count": 8,
194+
"execution_count": null,
195195
"id": "69d74f4d",
196196
"metadata": {},
197197
"outputs": [
@@ -201,7 +201,7 @@
201201
"120"
202202
]
203203
},
204-
"execution_count": 8,
204+
"execution_count": null,
205205
"metadata": {},
206206
"output_type": "execute_result"
207207
}
@@ -223,7 +223,7 @@
223223
},
224224
{
225225
"cell_type": "code",
226-
"execution_count": 9,
226+
"execution_count": null,
227227
"id": "fcb472b3",
228228
"metadata": {},
229229
"outputs": [],
@@ -242,7 +242,7 @@
242242
},
243243
{
244244
"cell_type": "code",
245-
"execution_count": 10,
245+
"execution_count": null,
246246
"id": "1e9ee5c1",
247247
"metadata": {},
248248
"outputs": [],
@@ -264,21 +264,9 @@
264264
],
265265
"metadata": {
266266
"kernelspec": {
267-
"display_name": "Python 3 (ipykernel)",
267+
"display_name": "python3",
268268
"language": "python",
269269
"name": "python3"
270-
},
271-
"language_info": {
272-
"codemirror_mode": {
273-
"name": "ipython",
274-
"version": 3
275-
},
276-
"file_extension": ".py",
277-
"mimetype": "text/x-python",
278-
"name": "python",
279-
"nbconvert_exporter": "python",
280-
"pygments_lexer": "ipython3",
281-
"version": "3.12.1"
282270
}
283271
},
284272
"nbformat": 4,

02_shell.ipynb

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": null,
66
"id": "efe78920",
77
"metadata": {},
88
"outputs": [],
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 3,
23+
"execution_count": null,
2424
"id": "1328ef69",
2525
"metadata": {},
2626
"outputs": [],
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 14,
43+
"execution_count": null,
4444
"id": "6bbf062d",
4545
"metadata": {},
4646
"outputs": [],
@@ -52,7 +52,7 @@
5252
},
5353
{
5454
"cell_type": "code",
55-
"execution_count": 5,
55+
"execution_count": null,
5656
"id": "d3d04ec5",
5757
"metadata": {},
5858
"outputs": [],
@@ -64,7 +64,7 @@
6464
},
6565
{
6666
"cell_type": "code",
67-
"execution_count": 6,
67+
"execution_count": null,
6868
"id": "d6ba32b4",
6969
"metadata": {},
7070
"outputs": [
@@ -88,7 +88,7 @@
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 7,
91+
"execution_count": null,
9292
"id": "34099c2f",
9393
"metadata": {},
9494
"outputs": [],
@@ -99,7 +99,7 @@
9999
},
100100
{
101101
"cell_type": "code",
102-
"execution_count": 8,
102+
"execution_count": null,
103103
"id": "d6aa8e7b",
104104
"metadata": {},
105105
"outputs": [],
@@ -113,18 +113,18 @@
113113
" signal.signal(signal.SIGALRM, handler)\n",
114114
" signal.alarm(timeout)\n",
115115
" try:\n",
116-
" with capture_output() as io: result = shell.orig_run(cell)\n",
116+
" with capture_output() as io: result = self.orig_run(cell)\n",
117117
" result.stdout = io.stdout\n",
118118
" return result\n",
119119
" except TimeoutException as e:\n",
120-
" result = shell.ExecutionResult(error_before_exec=None, error_in_exec=e)\n",
120+
" result = self.ExecutionResult(error_before_exec=None, error_in_exec=e)\n",
121121
" finally:\n",
122122
" if timeout: signal.alarm(0)"
123123
]
124124
},
125125
{
126126
"cell_type": "code",
127-
"execution_count": 9,
127+
"execution_count": null,
128128
"id": "cdadbb12",
129129
"metadata": {},
130130
"outputs": [],
@@ -145,7 +145,7 @@
145145
},
146146
{
147147
"cell_type": "code",
148-
"execution_count": 10,
148+
"execution_count": null,
149149
"id": "5ffbe57e",
150150
"metadata": {},
151151
"outputs": [],
@@ -155,7 +155,7 @@
155155
},
156156
{
157157
"cell_type": "code",
158-
"execution_count": 11,
158+
"execution_count": null,
159159
"id": "b03b78b3",
160160
"metadata": {},
161161
"outputs": [
@@ -165,7 +165,7 @@
165165
"(2, '3\\n')"
166166
]
167167
},
168-
"execution_count": 11,
168+
"execution_count": null,
169169
"metadata": {},
170170
"output_type": "execute_result"
171171
}
@@ -177,7 +177,7 @@
177177
},
178178
{
179179
"cell_type": "code",
180-
"execution_count": 12,
180+
"execution_count": null,
181181
"id": "48849fc3",
182182
"metadata": {},
183183
"outputs": [
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"cell_type": "code",
205-
"execution_count": 13,
205+
"execution_count": null,
206206
"id": "ddabea6d",
207207
"metadata": {},
208208
"outputs": [
@@ -212,7 +212,7 @@
212212
"TimeoutError()"
213213
]
214214
},
215-
"execution_count": 13,
215+
"execution_count": null,
216216
"metadata": {},
217217
"output_type": "execute_result"
218218
}
@@ -232,7 +232,7 @@
232232
},
233233
{
234234
"cell_type": "code",
235-
"execution_count": 15,
235+
"execution_count": null,
236236
"id": "1e9ee5c1",
237237
"metadata": {},
238238
"outputs": [],
@@ -254,21 +254,9 @@
254254
],
255255
"metadata": {
256256
"kernelspec": {
257-
"display_name": "Python 3 (ipykernel)",
257+
"display_name": "python3",
258258
"language": "python",
259259
"name": "python3"
260-
},
261-
"language_info": {
262-
"codemirror_mode": {
263-
"name": "ipython",
264-
"version": 3
265-
},
266-
"file_extension": ".py",
267-
"mimetype": "text/x-python",
268-
"name": "python",
269-
"nbconvert_exporter": "python",
270-
"pygments_lexer": "ipython3",
271-
"version": "3.12.1"
272260
}
273261
},
274262
"nbformat": 4,

index.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
],
295295
"metadata": {
296296
"kernelspec": {
297-
"display_name": "Python 3 (ipykernel)",
297+
"display_name": "python3",
298298
"language": "python",
299299
"name": "python3"
300300
}

lmtools/shell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ def handler(*args): raise TimeoutError()
2323
signal.signal(signal.SIGALRM, handler)
2424
signal.alarm(timeout)
2525
try:
26-
with capture_output() as io: result = shell.orig_run(cell)
26+
with capture_output() as io: result = self.orig_run(cell)
2727
result.stdout = io.stdout
2828
return result
2929
except TimeoutException as e:
30-
result = shell.ExecutionResult(error_before_exec=None, error_in_exec=e)
30+
result = self.ExecutionResult(error_before_exec=None, error_in_exec=e)
3131
finally:
3232
if timeout: signal.alarm(0)
3333

lmtools/xml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
from fastcore.utils import *
1212
from fastcore.meta import delegates
13-
from IPython import display
13+
try: from IPython import display
14+
except: display=None
1415

1516
# %% ../00_xml.ipynb 6
1617
def xt(tag:str, # XML tag name

0 commit comments

Comments
 (0)