Open faizer1989 opened 2 years ago
@jfthuong Hi Jeff, I am interested in how you impliment this error handling. is there documentation on it?
Nice idea.
I believe it's @raynardj who developed the system that caught the exceptions and proposed some solutions based on some simple database.
The listed modules are interesting.
Hmmm, it changes how ipython kernel run the cell's code, add a layer of exception handling
You can easily design more friendly messages by updating BUGBOOK
It's a dictionary, the key is the name of the error, the value is the message: a string of html
source code
from unpackai.bug import BUGBOOK
BUGBOOK["SyntaxError"] ="""
<h5>There is a <strong>grammatical</strong> error in your python code</h5>
<p>Please check the following</p>
<p>Every '(' or '[' or '{' or '"' or ' was closed with properly</p>
<p>':' should be followed by a new line with 1 extra <strong>indent</strong> (4 spaces)</p>
<p>or other grammatical errors, please check traceback below for clue, usually <strong>near ^ mark</strong></p>
"""
For more advanced error catching, you can define a error filter function
A function will return True
if it's the error you want to replace the message.
The function can be used as the key for BUGBOOK, without "
# functions that we can use as key of the fule
def module_not_found_error_filter(etype, evalue, tb):
if etype.__name__ == "ModuleNotFoundError":
libname = str(evalue).replace("No module named ", "")[1:-1]
if libname in ["fastai", "unpackai", "transformers","test_filter"]:
return True
return False
Of course the original design is to gather errors along with the student's code and send to our own backend so we can analyze their activity and most encountered pitfalls, but that's a long lead to follow
@jamescavanagh
For week 4. "NLP week" we already have a nice error message display thanks to Jeff.
The main issue: students make lots of unintentional errors and don't have an understanding of how to approach the debugging of some simple errors.
The error messaging thus should be beginner-friendly and encouraging to debug.
Some error handling python packages: