Jupyter Notebook 101
An introduction to Jupyter Notebooks
Jupyter Notebook is a document that helps with creating and sharing computational documents. You can imagine a Jupyter Notebook like a Google Doc or a Microsoft word; the difference is it has a different file extension (.ipynb) and the code executed in a REPL (Read-Eval-Print-Loop) fashion.
Jupyter Notebooks are built on the IPython kernel, famous for its REPL (Read-Eval-Print-Loop) capabilities. IPython is a command line terminal through which we can interactively execute python commands.
Jupyter Notebooks contain cells that contain atomic commands, which get executed to get the result from a programming environment, for example, from a server where your app is running or an API from a third-party system.
Like in any other text document, you can add text content (in Markdown format!)
The cloud community and the DevOps/SRE groups increasingly interact with complex systems. Also, DevOps/SRE groups mainly write bash/Perl scripts to automate their workflows, aka Runbooks.
By applying the Jupyter Notebook concept to automate the infrastructure workflows simplifies the task of a DevOps/SRE. It also aids in decoupling and debugging various systems quickly.
I’m using the Anaconda Distribution of Jupyter Notebook. Search for “anaconda download”; the first link you find is probably from Anaconda.com, which distributes the Jupyter Notebooks and several other products like Anaconda Server.
Next up, hit New -> Python 3 (ipykernel)
Each Jupyter notebook contains multiple cells, which contain Python code. Python code in each cell gets executed when you run the cell. Cells can also be configured for text so that you can input instructions and guidance needed for the following code snippet. (markdown!).
Please note each cell carries the programming context from the above cells.
A notebook (containing multiple cells) can be run in one go by using Cell -> Run Cells (as shown in the image above).
Alternatively, if you are a command line fan, you can use the below command to run a specific notebook.
> jupyter notebook notebook.ipynb
As discussed above, unSkript uses opensource Jupyter Notebooks under the hood and provides a seamless way of debugging/triggering complex infrastructure scripts.
Few more resources on getting started to understand Jupyter Notebooks: