Skip to content

Commit c0ddcae

Browse files
committed
Fix loops module cell throwing a traceback.
Remove --allow-errors flag from build.
1 parent d4bac94 commit c0ddcae

File tree

3 files changed

+42
-49
lines changed

3 files changed

+42
-49
lines changed

build.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ INPUT_DIR="workshops/docs/modules/notebooks"
55
OUT_DIR="workshops/docs/modules"
66
TEMPLATE_DIR="workshops/docs/modules/notebooks/nbconvert_templates"
77

8-
# We need to allow errors when executing since there are examples that
9-
# intentionally elicit a traceback.
10-
# TODO: If we move those examples into Markdown cells we can remove
11-
# --allow-errors and better test notebooks at build time
12-
#
8+
# We allow errors (--allow-errors) when executing to catch and broken examples.
9+
# Any example that requires printing a traceback should be moved into a
10+
# Markdown example cell so that code is displayed by not executed.
11+
1312
# ggplot/plotnine cells are sometimes slow, so we increase the default timeout
14-
EXECUTE="--execute --allow-errors --ExecutePreprocessor.timeout=240"
13+
# EXECUTE="--execute --allow-errors --ExecutePreprocessor.timeout=240"
14+
EXECUTE="--execute --ExecutePreprocessor.timeout=240"
1515

1616
generate_html='no'
1717
generate_instructor_notes='no'

workshops/docs/modules/loops.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ While this works, it's a bad approach for two reasons:
111111

112112

113113

114+
Running:
114115

115116
```python
116117
word = 'tin'
@@ -120,29 +121,22 @@ print(word[2])
120121
print(word[3])
121122
```
122123

123-
<pre class="output">
124-
<div class="output_label">output</div>
125-
<code class="text">
126-
t
127-
i
128-
n
129124

130-
</code>
131-
</pre>
132125

133126

134-
---------------------------------------------------------------------------
135127

136-
IndexError Traceback (most recent call last)
137-
138-
<ipython-input-3-e59d5eac5430> in <module>()
139-
3 print(word[1])
140-
4 print(word[2])
141-
----> 5 print(word[3])
142-
143-
144-
IndexError: string index out of range
128+
Gives the error:
145129

130+
```
131+
---------------------------------------------------------------------------
132+
IndexError Traceback (most recent call last)
133+
<ipython-input-4-e59d5eac5430> in <module>()
134+
3 print(word[1])
135+
4 print(word[2])
136+
----> 5 print(word[3])
137+
138+
IndexError: string index out of range
139+
```
146140

147141

148142

workshops/docs/modules/notebooks/loops.ipynb

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,37 +109,36 @@
109109
]
110110
},
111111
{
112-
"cell_type": "code",
113-
"execution_count": 4,
112+
"cell_type": "markdown",
114113
"metadata": {},
115-
"outputs": [
116-
{
117-
"name": "stdout",
118-
"output_type": "stream",
119-
"text": [
120-
"t\n",
121-
"i\n",
122-
"n\n"
123-
]
124-
},
125-
{
126-
"ename": "IndexError",
127-
"evalue": "string index out of range",
128-
"output_type": "error",
129-
"traceback": [
130-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
131-
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
132-
"\u001b[0;32m<ipython-input-4-e59d5eac5430>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
133-
"\u001b[0;31mIndexError\u001b[0m: string index out of range"
134-
]
135-
}
136-
],
137114
"source": [
115+
"Running:\n",
116+
"\n",
117+
"```python\n",
138118
"word = 'tin'\n",
139119
"print(word[0])\n",
140120
"print(word[1])\n",
141121
"print(word[2])\n",
142-
"print(word[3])"
122+
"print(word[3])\n",
123+
"```"
124+
]
125+
},
126+
{
127+
"cell_type": "markdown",
128+
"metadata": {},
129+
"source": [
130+
"Gives the error:\n",
131+
"\n",
132+
"```\n",
133+
"---------------------------------------------------------------------------\n",
134+
"IndexError Traceback (most recent call last)\n",
135+
"<ipython-input-4-e59d5eac5430> in <module>()\n",
136+
" 3 print(word[1])\n",
137+
" 4 print(word[2])\n",
138+
"----> 5 print(word[3])\n",
139+
"\n",
140+
"IndexError: string index out of range\n",
141+
"```"
143142
]
144143
},
145144
{

0 commit comments

Comments
 (0)