Import Jupyter Notebook from GitHub
To import a Jupyter Notebook from GitHub (or any other place on the Internet), you need to:
- Download the file.
- Run it in Jupyter.
I created an example Jupyter Notebook that can be imported and pushed it to a git repository: https://raw.githubusercontent.com/mikulskibartosz/to_be_imported/master/to_be_imported.ipynb
The file contains one function. The function prints “Hello, World!” when called. The second cell of the notebook calls the function, so after importing it, we should see “Hello, World!” printed in Jupyter.
In another file, I wrote the following code:
1 2 !curl -O https://raw.githubusercontent.com/mikulskibartosz/to_be_imported/master/to_be_imported.ipynb %run to_be_imported.ipynb
The first line downloads the file and stores it in the file indicated by the URL. The second line imports the file to Jupyter Notebook.
If you import a file while running Jupyter Notebook on your machine (not in a Kaggle kernel or some other dockerized environment), the imported code will be executed on your machine!
The imported notebook has access to your files (can delete, modify or upload them somewhere). It may also contain code which downloads an executable file and runs it on your machine. Be careful ;)
Did you enjoy reading this article?
Would you like to learn more about leveraging AI to drive growth and innovation, software craft in data engineering, and MLOps?
Subscribe to the newsletter or add this blog to your RSS reader (does anyone still use them?) to get a notification when I publish a new essay!
You may also like
- MLOps engineer by day
- AI and data engineering consultant by night
- Python and data engineering trainer
- Conference speaker
- Contributed a chapter to the book "97 Things Every Data Engineer Should Know"
- Twitter: @mikulskibartosz
- Mastodon: @firstname.lastname@example.org