Skip to content

Commit cf5caf3

Browse files
authored
Merge pull request #18 from Schulich-Ignite/radu/bugs
Radu/bugs
2 parents 14e44e9 + b147f63 commit cf5caf3

4 files changed

Lines changed: 203 additions & 29 deletions

File tree

documentation.ipynb

Lines changed: 189 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14+
"## Updating the library\n",
15+
"Currently, the Ignite Aranite platform is not using the latest version of the library. To update it, we can write the following command in a cell\n",
16+
"```shell\n",
17+
"!pip install --upgrade schulich-ignite\n",
18+
"```\n",
19+
"The cell can then be deleted, and we can continue writing code as normal.\n",
20+
"\n",
1421
"## Ignite magic and boilerplate code\n",
1522
"In order be able to run our custom ignite code, you must first import our libray and the extension by doing the following:\n",
1623
"```python\n",
@@ -34,7 +41,7 @@
3441
},
3542
{
3643
"cell_type": "code",
37-
"execution_count": 4,
44+
"execution_count": 2,
3845
"metadata": {},
3946
"outputs": [
4047
{
@@ -108,43 +115,122 @@
108115
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
109116
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
110117
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
111-
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span>\n",
118+
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Stopped</span>\n",
112119
"</pre></div>\n"
113120
],
114121
"text/latex": [
115122
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
116-
"\n",
123+
"\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\n",
117124
"\\end{Verbatim}\n"
118125
],
119-
"text/plain": []
126+
"text/plain": [
127+
"Stopped"
128+
]
120129
},
121130
"metadata": {},
122131
"output_type": "display_data"
123132
},
133+
{
134+
"name": "stdout",
135+
"output_type": "stream",
136+
"text": [
137+
"Error: 'Core' object has no attribute 'output_text'\n"
138+
]
139+
},
124140
{
125141
"data": {
126142
"application/vnd.jupyter.widget-view+json": {
127-
"model_id": "fd2dc249b9924e8d85c4adf53235a7ef",
143+
"model_id": "3da3b244cdea44c8ac71ea8570ae43d7",
128144
"version_major": 2,
129145
"version_minor": 0
130146
},
131147
"text/plain": [
132-
"Button(description='Stop', style=ButtonStyle())"
148+
"Canvas(height=100, width=100)"
133149
]
134150
},
135151
"metadata": {},
136152
"output_type": "display_data"
137153
},
138154
{
139155
"data": {
140-
"application/vnd.jupyter.widget-view+json": {
141-
"model_id": "f08a64daa28b4da19fc808268997e30a",
142-
"version_major": 2,
143-
"version_minor": 0
144-
},
145-
"text/plain": [
146-
"Canvas(height=100, width=100)"
147-
]
156+
"text/html": [
157+
"<style>.output_html .hll { background-color: #ffffcc }\n",
158+
".output_html { background: #f8f8f8; }\n",
159+
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
160+
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
161+
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
162+
".output_html .o { color: #666666 } /* Operator */\n",
163+
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
164+
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
165+
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
166+
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
167+
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
168+
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
169+
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
170+
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
171+
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
172+
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
173+
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
174+
".output_html .go { color: #888888 } /* Generic.Output */\n",
175+
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
176+
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
177+
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
178+
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
179+
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
180+
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
181+
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
182+
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
183+
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
184+
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
185+
".output_html .m { color: #666666 } /* Literal.Number */\n",
186+
".output_html .s { color: #BA2121 } /* Literal.String */\n",
187+
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
188+
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
189+
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
190+
".output_html .no { color: #880000 } /* Name.Constant */\n",
191+
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
192+
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
193+
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
194+
".output_html .nf { color: #0000FF } /* Name.Function */\n",
195+
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
196+
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
197+
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
198+
".output_html .nv { color: #19177C } /* Name.Variable */\n",
199+
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
200+
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
201+
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
202+
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
203+
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
204+
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
205+
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
206+
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
207+
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
208+
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
209+
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
210+
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
211+
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
212+
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
213+
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
214+
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
215+
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
216+
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
217+
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
218+
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
219+
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
220+
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
221+
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
222+
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
223+
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
224+
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
225+
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span>\n",
226+
"</pre></div>\n"
227+
],
228+
"text/latex": [
229+
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
230+
"\n",
231+
"\\end{Verbatim}\n"
232+
],
233+
"text/plain": []
148234
},
149235
"metadata": {},
150236
"output_type": "display_data"
@@ -270,16 +356,16 @@
270356
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
271357
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
272358
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
273-
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Stopped due to inactivity</span>\n",
359+
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span><span class=\"err\">Running...</span>\n",
274360
"</pre></div>\n"
275361
],
276362
"text/latex": [
277363
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
278-
"\\PY{err}{S}\\PY{err}{t}\\PY{err}{o}\\PY{err}{p}\\PY{err}{p}\\PY{err}{e}\\PY{err}{d}\\PY{err}{ }\\PY{err}{d}\\PY{err}{u}\\PY{err}{e}\\PY{err}{ }\\PY{err}{t}\\PY{err}{o}\\PY{err}{ }\\PY{err}{i}\\PY{err}{n}\\PY{err}{a}\\PY{err}{c}\\PY{err}{t}\\PY{err}{i}\\PY{err}{v}\\PY{err}{i}\\PY{err}{t}\\PY{err}{y}\n",
364+
"\\PY{err}{R}\\PY{err}{u}\\PY{err}{n}\\PY{err}{n}\\PY{err}{i}\\PY{err}{n}\\PY{err}{g}\\PY{err}{.}\\PY{err}{.}\\PY{err}{.}\n",
279365
"\\end{Verbatim}\n"
280366
],
281367
"text/plain": [
282-
"Stopped due to inactivity"
368+
"Running..."
283369
]
284370
},
285371
"metadata": {},
@@ -288,7 +374,7 @@
288374
{
289375
"data": {
290376
"application/vnd.jupyter.widget-view+json": {
291-
"model_id": "ce4a952879fe4b6d957501419927a1e4",
377+
"model_id": "e681b29da4a54ba5bc220216d6fd859d",
292378
"version_major": 2,
293379
"version_minor": 0
294380
},
@@ -302,7 +388,7 @@
302388
{
303389
"data": {
304390
"application/vnd.jupyter.widget-view+json": {
305-
"model_id": "c95577b1419743d38d33b568a626a66a",
391+
"model_id": "e0bd96e84639405082a83ee80bf959b2",
306392
"version_major": 2,
307393
"version_minor": 0
308394
},
@@ -312,6 +398,90 @@
312398
},
313399
"metadata": {},
314400
"output_type": "display_data"
401+
},
402+
{
403+
"data": {
404+
"text/html": [
405+
"<style>.output_html .hll { background-color: #ffffcc }\n",
406+
".output_html { background: #f8f8f8; }\n",
407+
".output_html .c { color: #408080; font-style: italic } /* Comment */\n",
408+
".output_html .err { border: 1px solid #FF0000 } /* Error */\n",
409+
".output_html .k { color: #008000; font-weight: bold } /* Keyword */\n",
410+
".output_html .o { color: #666666 } /* Operator */\n",
411+
".output_html .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
412+
".output_html .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
413+
".output_html .cp { color: #BC7A00 } /* Comment.Preproc */\n",
414+
".output_html .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
415+
".output_html .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
416+
".output_html .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
417+
".output_html .gd { color: #A00000 } /* Generic.Deleted */\n",
418+
".output_html .ge { font-style: italic } /* Generic.Emph */\n",
419+
".output_html .gr { color: #FF0000 } /* Generic.Error */\n",
420+
".output_html .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
421+
".output_html .gi { color: #00A000 } /* Generic.Inserted */\n",
422+
".output_html .go { color: #888888 } /* Generic.Output */\n",
423+
".output_html .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
424+
".output_html .gs { font-weight: bold } /* Generic.Strong */\n",
425+
".output_html .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
426+
".output_html .gt { color: #0044DD } /* Generic.Traceback */\n",
427+
".output_html .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
428+
".output_html .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
429+
".output_html .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
430+
".output_html .kp { color: #008000 } /* Keyword.Pseudo */\n",
431+
".output_html .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
432+
".output_html .kt { color: #B00040 } /* Keyword.Type */\n",
433+
".output_html .m { color: #666666 } /* Literal.Number */\n",
434+
".output_html .s { color: #BA2121 } /* Literal.String */\n",
435+
".output_html .na { color: #7D9029 } /* Name.Attribute */\n",
436+
".output_html .nb { color: #008000 } /* Name.Builtin */\n",
437+
".output_html .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
438+
".output_html .no { color: #880000 } /* Name.Constant */\n",
439+
".output_html .nd { color: #AA22FF } /* Name.Decorator */\n",
440+
".output_html .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
441+
".output_html .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
442+
".output_html .nf { color: #0000FF } /* Name.Function */\n",
443+
".output_html .nl { color: #A0A000 } /* Name.Label */\n",
444+
".output_html .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
445+
".output_html .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
446+
".output_html .nv { color: #19177C } /* Name.Variable */\n",
447+
".output_html .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
448+
".output_html .w { color: #bbbbbb } /* Text.Whitespace */\n",
449+
".output_html .mb { color: #666666 } /* Literal.Number.Bin */\n",
450+
".output_html .mf { color: #666666 } /* Literal.Number.Float */\n",
451+
".output_html .mh { color: #666666 } /* Literal.Number.Hex */\n",
452+
".output_html .mi { color: #666666 } /* Literal.Number.Integer */\n",
453+
".output_html .mo { color: #666666 } /* Literal.Number.Oct */\n",
454+
".output_html .sa { color: #BA2121 } /* Literal.String.Affix */\n",
455+
".output_html .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
456+
".output_html .sc { color: #BA2121 } /* Literal.String.Char */\n",
457+
".output_html .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
458+
".output_html .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
459+
".output_html .s2 { color: #BA2121 } /* Literal.String.Double */\n",
460+
".output_html .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
461+
".output_html .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
462+
".output_html .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
463+
".output_html .sx { color: #008000 } /* Literal.String.Other */\n",
464+
".output_html .sr { color: #BB6688 } /* Literal.String.Regex */\n",
465+
".output_html .s1 { color: #BA2121 } /* Literal.String.Single */\n",
466+
".output_html .ss { color: #19177C } /* Literal.String.Symbol */\n",
467+
".output_html .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
468+
".output_html .fm { color: #0000FF } /* Name.Function.Magic */\n",
469+
".output_html .vc { color: #19177C } /* Name.Variable.Class */\n",
470+
".output_html .vg { color: #19177C } /* Name.Variable.Global */\n",
471+
".output_html .vi { color: #19177C } /* Name.Variable.Instance */\n",
472+
".output_html .vm { color: #19177C } /* Name.Variable.Magic */\n",
473+
".output_html .il { color: #666666 } /* Literal.Number.Integer.Long */</style><div class=\"highlight\"><pre><span></span>\n",
474+
"</pre></div>\n"
475+
],
476+
"text/latex": [
477+
"\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n",
478+
"\n",
479+
"\\end{Verbatim}\n"
480+
],
481+
"text/plain": []
482+
},
483+
"metadata": {},
484+
"output_type": "display_data"
315485
}
316486
],
317487
"source": [

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="schulich-ignite",
8-
version="0.0.8",
8+
version="0.0.9",
99
author="Schulich Ignite",
1010
author_email="info@shulichignite.com",
1111
description="Spark library for Shulich Ignite sessions",

spark/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ def load_ipython_extension(ipython):
1111
# Defines the "magic" that will be used inside the cells
1212
@magics_class
1313
class IgniteMagic(Magics):
14-
1514
@cell_magic
1615
def ignite(self, line, cell_code):
16+
if hasattr(self, "core_obj"):
17+
self.core_obj.stop()
18+
1719
globals_dict = {}
1820
locals_dict = {}
1921

20-
core_obj = core.Core(globals_dict)
22+
self.core_obj = core.Core(globals_dict)
2123

2224
# Copy global constants from Core object
2325
for key, val in core.Core.global_constants.items():
2426
globals_dict[key] = val
2527

2628
# Copy global methods from Core object
2729
for field in core.Core.global_fields:
28-
globals_dict[field] = getattr(core_obj, field)
30+
globals_dict[field] = getattr(self.core_obj, field)
2931

3032
# Execute the code inside the cell and inject the globals we defined.
3133
try:
@@ -42,5 +44,5 @@ def ignite(self, line, cell_code):
4244
globals_dict[key] = val # Copy locals to global to keep them available.
4345

4446
# Run bootstrap code
45-
core_obj.start(methods)
47+
self.core_obj.start(methods)
4648

spark/core.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ def clear(self, *args):
332332

333333
# Draws background on canvas
334334
def background(self, *args):
335+
old_fill = self.canvas.fill_style
335336
argc = len(args)
336-
if (argc == 3):
337+
338+
if argc == 3:
337339
if ((not type(args[0]) is int) or (not type(args[1]) is int) or (not type(args[2]) is int)):
338340
raise TypeError("Enter Values between 0 and 255(integers only) for all 3 values")
339341
elif (not (args[0] >= 0 and args[0] <= 255) or not (args[1] >= 0 and args[1] <= 255) or not (
@@ -342,15 +344,13 @@ def background(self, *args):
342344
self.clear()
343345
self.fill_style(args[0], args[1], args[2])
344346
self.fill_rect(0, 0, self.width, self.height)
345-
346-
elif (argc == 1):
347+
elif argc == 1:
347348
if (not type(args[0]) is str):
348349
raise TypeError("Enter colour value in Hex i.e #000000 for black and so on")
349350
self.clear()
350351
self.fill_style(args[0])
351352
self.fill_rect(0, 0, self.width, self.height)
352-
353-
elif (argc == 4):
353+
elif argc == 4:
354354
if ((not type(args[0]) is int) or (not type(args[1]) is int) or (not type(args[2]) is int) or (
355355
not type(args[3]) is float)):
356356
raise TypeError("Enter Values between 0 and 255(integers only) for all 3 values")
@@ -361,6 +361,8 @@ def background(self, *args):
361361
self.clear()
362362
self.fill_style(args[0], args[1], args[2], args[3])
363363
self.fill_rect(0, 0, self.width, self.height)
364+
365+
self.canvas.fill_style = old_fill
364366

365367
### Helper Functions ###
366368

0 commit comments

Comments
 (0)