diff --git a/Exercises/00-setup/images/cell_jup.png b/Exercises/00-setup/images/cell_jup.png new file mode 100644 index 0000000..b0e2f8f Binary files /dev/null and b/Exercises/00-setup/images/cell_jup.png differ diff --git a/Exercises/00-setup/images/home_jup.png b/Exercises/00-setup/images/home_jup.png new file mode 100644 index 0000000..44f8f1c Binary files /dev/null and b/Exercises/00-setup/images/home_jup.png differ diff --git a/Exercises/00-setup/images/inter_jup.png b/Exercises/00-setup/images/inter_jup.png new file mode 100644 index 0000000..c07d288 Binary files /dev/null and b/Exercises/00-setup/images/inter_jup.png differ diff --git a/Exercises/00-setup/images/kernel_1.png b/Exercises/00-setup/images/kernel_1.png new file mode 100644 index 0000000..41f4092 Binary files /dev/null and b/Exercises/00-setup/images/kernel_1.png differ diff --git a/Exercises/00-setup/images/run_cell.png b/Exercises/00-setup/images/run_cell.png new file mode 100644 index 0000000..91bf4da Binary files /dev/null and b/Exercises/00-setup/images/run_cell.png differ diff --git a/Exercises/00-setup/images/tab_auto.png b/Exercises/00-setup/images/tab_auto.png new file mode 100644 index 0000000..e99e6b2 Binary files /dev/null and b/Exercises/00-setup/images/tab_auto.png differ diff --git a/Exercises/00-setup/jupyter.md b/Exercises/00-setup/jupyter.md new file mode 100644 index 0000000..63571c7 --- /dev/null +++ b/Exercises/00-setup/jupyter.md @@ -0,0 +1,92 @@ +# Using Jupyter Notebooks and Jupyter Lab + + +## What is a Jupyter Notebook? + +From the [Project Jupyter website](https://jupyter.org/): + +> The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more. + +## What is Jupyter Lab? + +Jupyter Lab is a web-based development environment for Jupyter Notebooks, code and data. You can also use it to view Markdown, PDF and text files. + + +## Interacting with Jupyter Lab and launching a Notebook + +When you open EPFL noto, you should see a screen as follows: + + + +You will notice there will be a directory structure on the left-hand side of your window. On the right-hand side, we have a "launcher" interface where we can create a Jupyter Notebook (boxed in red), or several other types of files. To start a new notebook, click on the "Python 3" logo beneath "Notebook". You can also open an existing notebook from the directory. + +Once you open a notebook, you will be brought to the following screen. + + + + +Some of the most important components of the notebook are highlighted in colored boxes. +- To rename your notebook (shown here as Untitled), you can right-click your document and select Rename. +- In purple is the cell formatting assignment. By default, it is set to "Code", but it can also be set to "Markdown". +- In red is a code cell, in which you can write Python code. +- In blue is a markdown cell, which is used to display nicely formatted text, images and mathematical equations. + + + +#### Markdown cells +Here are some useful resources for Markdown cells: +- https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet +- https://www.datacamp.com/community/tutorials/markdown-in-jupyter-notebook + +#### Code cells + +Code cells support Python code (and other languages with different kernels, although we will only use Python in this course). They can be executed in any order. + +- To run a single cell, use **Shift + Enter** or press on the ▶ button. +- To run all the cells starting from the beginning, go to `Run` -> `Run All Cells...`. + + + + +:warning: Code cells can be executed in any order. This means that you can overwrite your current variables by running cells out of order. This also means that variables declared in cells that were executed then deleted will still be present (known as a hidden state) unless the kernel is restarted. Therefore, **when coding in notebooks, be cautious of the order in which you run cells.** One solution to avoid hidden states is to frequently restart your kernel (and run up to your currently selected cell). This is covered more in depth in [this section](#the-kernel). + +#### Autocompletion and documentation +Autocompletion is possible with JupyterLab too! Use **Tab**. + + + +To view the documentation for a function or class, use **Shift + Tab**. + +#### Keyboard shortcuts + +You can gain a lot of time using [keyboard shortcuts](https://cheatography.com/weidadeyue/cheat-sheets/jupyter-notebook/pdf/) to navigate through notebooks. + +## The kernel + +The kernel maintains the state of a notebook's computations (such as current variables, declared functions and loaded data). For notebooks that do not take too long to run, it is desirable to frequently restart the kernel to ensure that there are no hidden states. + +Here is a list of what the different kernel related actions do: + +![](images/kernel_1.png) + +- **Interrupt ( or ■ button):** Causes the kernel to stop performing the current task without actually shutting the kernel down. You can use this option when you want to stop a very long task (eg. stop processing a large dataset). + +- **Restart (or ↻ button):** Stops the kernel and starts it again. This action causes you to lose all the state data. In some cases, this is precisely what you need to do when the environment has become "dirty" with hidden state data. + +- **Restart & Clear Output:** Stops the kernel, starts it again, and clears all the existing cell outputs. + +- **Restart Kernel & Run Up to Selected Cell:** Stops the kernel, starts it again, and then runs every cell starting from the top cell and ending with the currently selected cell. Use this when you are working on a Notebook and want to make sure there are no hidden states. + +- **Restart Kernel & Run All Cells:** Stops the kernel, starts it again, and then runs every cell starting from the top cell and ending with the last cell. Use this when you're done working on a Notebook and want to make sure everything runs properly and doesn't depend on hidden states. + +- **Shutdown:** Shuts the kernel down. You may perform this step in preparation for using a different kernel. + +- **Change Kernel:** Selects a different kernel from the list of kernels you have installed. For example, you may want to test an application using various Python versions to ensure that it runs on all of them. + +## Additional resources + +**Jupyter Notebook tutorial: https://www.dataquest.io/blog/jupyter-notebook-tutorial/** + +**Jupyter Notebook documentation: https://jupyterlab.readthedocs.io/en/stable/user/notebook.html** + +**Jupyter Lab interface documentation: https://jupyterlab.readthedocs.io/en/stable/user/interface.html** diff --git a/Exercises/00-setup/noto.md b/Exercises/00-setup/noto.md new file mode 100644 index 0000000..d7b6ce1 --- /dev/null +++ b/Exercises/00-setup/noto.md @@ -0,0 +1,20 @@ +# EPFL Noto + +we need to provide instructions on git pull to update. + + +EPFL provides a centralized JupyterLab platform for students called [Noto](https://www.epfl.ch/education/educational-initiatives/cede/digitaltools/noto/), allowing you to run all these notebooks without having to install anything on your computer. This is because those notebooks are running in the cloud (i.e. on a remote server, with which you directly interact through the JupyterLab interface). + +To clone this repo on EPFL Noto, click on this link:https://go.epfl.ch/ME-390-2022. + +As in a local Python installation, you will need to frequently `git pull` the most recent changes in order to ensure that your files are up-to-date. + +:warning: You'll need a stable internet connection to run these labs through Noto, as it runs in the cloud. This is not the case when running the notebooks locally, even though we're still using a web browser to access Jupyter Lab. + +## Other cloud-based notebook platforms +There exists other online platforms offering cloud-based Jupyter Notebooks. These platforms could enable faster computation time. Notably: + +- [Google Colab](https://colab.research.google.com/), which offers free GPU runtimes, which is very useful for some machine learning tasks (such as training neural networks). +- [Deepnote](https://deepnote.com/), which offers real-time collaboration (useful for group projects). + +**Note**: We do not provide any support for using these platforms.