Convert ipynb files to py in the current folder with tempfile (which is more straightforward than converting py to ipynb and I can catch exceptions with exec(), like what I did for the clean command).
Use exec(open(filename).read()) execute py files
Use try-except block to catch exceptions
Create a dict error_suggestion_dict to store exception handling suggestions.
Cases:
Notebooks that can run: Finished executing {filename}, no error encountered
Notebooks with ModuleNotFoundError, AttributeError, SyntaxError: provide suggestions: {error_type} encountered while executing the notebook: {err}. It is recommended to + [suggestion]
"ModuleNotFoundError": "create a virtualenv, and adding a requirements.txt with the package",
"AttributeError": "downgrade some libraries",
"SyntaxError": "check syntax",
Notebooks with other errors: provide a link to the guide of debugging notebooks:
{error_type} encountered while executing the notebook: {err}
Checkout how to debug notebooks:
https://docs.ploomber.io/en/latest/user-guide/debugging.html
Issue ticket number and link
Closes #6
Checklist before requesting a review
[x] I have performed a self-review of my code
[x] I have added thorough tests (when necessary).
[x] I have added the right documentation (when needed). Product update? If yes, write one line about this update.
Describe your changes
Add test command to ensure the notebook runs:
tempfile
(which is more straightforward than converting py to ipynb and I can catch exceptions withexec()
, like what I did for theclean
command).exec(open(filename).read())
execute py fileserror_suggestion_dict
to store exception handling suggestions.Cases:
{error_type} encountered while executing the notebook: {err}. It is recommended to + [suggestion]
Issue ticket number and link
Closes #6
Checklist before requesting a review