If you are a data scientist, or do machine learning, like me, you are probably writing most of the code in Jupyter Notebooks. For everyone else, I’ll explain: Jupyter is a wonderful system that allows you to combine executable code and text fragments based on Markdown in a single document that can be edited and executed directly through the browser. Such a document is called a laptop (now you know how to give a friend a laptop for my birthday, and not much to spend money)
Most data scientists usually install a Python environment on their computer (for example, Anaconda or Miniconda ), and then start the local Jupyter server and create laptops on their local computer. If you suddenly need a very high-performance computer, you can run Jupyter on the server, and work with it over the network through a browser.
The idea itself is to use a cloud service to provide ready-made Jupyter laptops with all the necessary environment. This is what Azure Notebooks is called - the publicly available Jupyter service in the Microsoft Azure cloud, which you can use from anywhere to write your code or documents.
Using Azure Notebooks is often much more convenient than using the Python environment on the local computer, and I’ll try to describe why.
1. You can immediately start programming
Whether you are starting to learn Python, or want to experiment a bit with F #, the first thing you need to do is set up a development environment, such as Visual Studio or Anaconda. This requires at least time and disk space. If you are going to engage in serious development - most likely these efforts will pay off, however if you just want to try a piece of code, or if you came to a party with your friends and want to brag about your latest program - most likely you will not have an extra couple of hours of installation time. In these cases, you can simply log in with your Microsoft Account at http://notebooks.azure.com and immediately start programming in one of the available languages: Python 2/3, R or F # .
2. Your code is available everywhere
Let's go back to the example when you wanted to show off your program at a party with friends. In this case, it would be great to have the code at hand, without having to copy it from a USB flash drive or even from OneDrive. In Azure Notebooks, all your files are stored online, they are organized into projects that resemble GitHub repositories, only without version control. Moreover, each project can be made private or public , in this case you can share the code.
3. Share code easily
Azure Notebooks is a great way to share code with other people. Each project has a unique link that you can send to friends (it is important that the project is publicly available). With this link, your friends will be able to:
- Watch the project code
- clone the project and get their own copy, which they can immediately begin to execute and modify
Unlike Google Colab, you share the whole project at once, which can include several laptops at once, as well as data, the README file, requirements.txt
environment configuration, etc.
If you need to configure the environment, for example, install some packages , this can be done using the configuration files , or by including pip install
commands at the beginning of the laptop (this is also useful if you want to achieve compatibility with Google Colab). Installing packages on F # laptops is done through the Paket
package manager, as described here .
4. Documented Code / Data Journalism
A laptop is a great way to add detailed instructions to the program code, or vice versa, add calculated fragments to the text. This can be useful in many scenarios:
- Writing instructions or a book on a topic related to algorithms or some kind of computing. For example, to explain what an affine transform is, you can first write a long text with a definition (including formulas, since laptops support LaTeX syntax for formulas), and then include executable examples of applying affine transforms to multiple pictures. Readers will not only see how the code works, but they will also be able to fix it, execute it live, and continue to experiment.
- Writing text based on data, such as in digital (computational) journalism . When preparing an article in notebook format, you can embed code that collects data from open sources, builds some graphs on their basis, and even draws some conclusions (or pushes the reader to do so).
5. Presentations
My favorite feature that sets Azure Notebooks apart from all similar solutions is the ability to use them for presentations using the pre-installed RISE extension . you can mark cells as separate slides, or as fragments (a continuation of previous slides) to create an animation. You can “hide” some cells - for example, if they contain some useful executable code that you don’t need to show to your listeners, or a long explanatory text visible in laptop mode but not in slide mode.
Of course, Azure Notebooks are not designed to create beautiful marketing presentations, but for many cases where content is important, not design, this approach is more convenient. Especially great to use Azure Notebooks for academic and scientific presentations, since you can use LaTeX formulas. And don't forget that laptops are easy to share!
6. Executable code for the GitHub repository
If you support your Python project on GitHub, then using Azure Notebooks you can give visitors the opportunity to run your code. One way is to put the code in a Notebooks project in parallel and specify a link where visitors can clone examples and try them. However, it is even more convenient to use direct cloning from any GitHub repository - all you need to do is include the following code in the project description in Readme.md
:
<a href="https://notebooks.azure.com/import/gh/<git_user>/<repo>"> <img src="https://notebooks.azure.com/launch.png" /></a>
7. Code execution on different servers
In deep learning tasks, very often we can begin to develop a training script and run it on a subset of the data on a regular machine, and then transfer the learning process to a computer with a GPU. Azure Notebooks make it very elegant. When you open a project, we launch it by default on a free computing resource (Free Compute), but if we have an Azure subscription tied to our account, we can also select any suitable virtual machine from the list (by the word “suitable” I mean Data Science Virtual Machine running Ubuntu).
Usually in my work I always start developing code on a free resource, and then switch to VM. At the same time, Azure Notebooks will automatically transfer (or rather mount ) the entire project environment (including laptops and data files from the project) to the selected virtual machine.
In fairness, it is worth noting that the virtual machine provided for free is very good, with 4 GB of memory and 1 GB of disk space.
8. Teaching
I speak a lot, and also teach a couple of courses at several universities, and personally find Azure Notebooks an extremely convenient teaching tool . Here's how you can use laptops:
- Lecturing using presentation mode. Azure Notebooks slides are easier to create and maintain, as you can focus on content rather than design. Working with text is much more convenient, and formulas in TeX are much faster to type than Word Equations. Of the unpleasant moments - adding pictures and diagrams is more difficult, therefore laptops are not suitable for marketing presentations.
- Writing a tutorial with examples If you create slides using laptops, you can always add additional text to the slides that will not be shown in presentation mode, but it will further reveal the idea. Thus, the same laptop can be used as a textbook and as slides . In addition, the same laptop contains executable examples that are used in a demonstration, or as a starting point for students to work independently.
- Laboratory work and exams . Put all the materials, including the initial pre-built code, into one Azure Notebooks project, and then give the students a link. They will be able to clone the project and start working on it right in the browser.
.ipynb
individual links from them (if there is no time limit), or ask them to upload a .ipynb
laptop .ipynb
to GitHub or cloud storage if it is important for you to exclude the student’s further work on the task.
I also use other cloud technologies for teaching with, for example, Azure Functions for obtaining laboratory results, but this is a completely different story, which I will probably share someday ...
Some features
Azure Notebooks is a great tool, but there are some things to keep in mind:
- Network access from a laptop is somewhat limited. Since you get a free computing resource with Azure Notebooks, you are tempted to use it for other purposes, for example, to send spam. To avoid this, from Azure Notebook open network access to only a limited number of network resources, including all resources of Azure, OneDrive, as well as GitHub, Kaggle, and possibly something else. To use external data in your code, put it on OneDrive / GitHub, or upload it to the project manually using the web interface.
- Insert images / schemes into text. Since all text is edited in Markdown format, pasting pictures and diagrams through clipboard does not work. To insert pictures, save them in JPEG / PNG and upload them somewhere on the Internet (I usually use the GitHub repository for this), then use the Markdown syntax to add pictures. And remember: use PowerPoint for marketing presentations, and Azure Notebooks for academic / scientific / development ones.
- Access to the GPU is not yet provided for free - only as part of explicitly created virtual machines.
Examples
A good way to quickly get to know the various features of Azure Notebooks, such as graphing, installing packages, accessing external data, etc. - start with examples . Another great collection of examples for Jupyter is here . Remember: you can run any Jupyter Notebook in Azure simply by uploading the .ipynb
file to the project.
Conclusion
Azure Notebooks is a great tool to help you in a variety of life situations, some of which I described in an article. If you use laptops for something else - share your experience in the comments, it's interesting!
Despite the fact that there are other ways to run laptops in the cloud , including Google Colab and Binder , a comparison shows that Azure Notebooks includes the maximum number of extremely useful features.
I hope that Azure Notebooks will make your life better and more productive, and you will, like me, constantly use them!
PS The official documentation for Azure Notebooks is available here: http://aka.ms/aznb