Skip to content

Commit

Permalink
Merge pull request #7 from PowerCyberTraining/cui
Browse files Browse the repository at this point in the history
Merge updates
  • Loading branch information
cuihantao authored Sep 26, 2024
2 parents 88ef5f9 + ab1d184 commit a7cf0eb
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 13 deletions.
1 change: 1 addition & 0 deletions pct/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ chapters:
- file: modules/01/filesystem.md
- file: modules/01/pkgman.md
- file: modules/01/env.md
- file: modules/01/jupyter.ipynb
- file: notebooks
- file: markdown-notebooks
11 changes: 11 additions & 0 deletions pct/modules/01/env.ipynb → pct/modules/01/_env.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion pct/modules/01/intro.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fundamentals in Tooling
# Tools You Need

## Motivation

Expand Down
117 changes: 117 additions & 0 deletions pct/modules/01/jupyter.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jupyter Notebook\n",
"\n",
"## Why use Jupyter?\n",
"\n",
"Jupyter is an open-source, web-based interface for interactive computing.\n",
"Jupyter Notebook is Jupyter's document format that can store live code,\n",
"equations, visualizations, and text. These documents can be shared for\n",
"reproducible research and published online. This book you are reading is written\n",
"in Jupyter Notebook.\n",
"\n",
"Jupyter supports many programming languages, including Python, Julia\n",
"and R. Since the primary language of this training is Python, we will use\n",
"Jupyter for it.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install Jupyter\n",
"\n",
"### Jupyter Notebook\n",
"If you have followed through the previous section, you should have already\n",
"installed Jupyter Notebook. If not, you can install it by\n",
"\n",
"```bash\n",
"# activate your conda environment\n",
"\n",
"# install jupyter notebook\n",
"mamba install jupyter notebook\n",
"```\n",
"\n",
"\n",
"You can launch Jupyter Notebook by\n",
"\n",
"```bash\n",
"jupyter notebook\n",
"```\n",
"\n",
"The command line will print a URL that you can open in your web browser to\n",
"access. If the web browser does not open automatically, you can hold down Ctrl\n",
"and click on the URL, or copy and paste the URL into your web browser.\n",
"\n",
"This is the classical Jupyter Notebook interface.\n",
"\n",
"\n",
"### JupyterLab\n",
"\n",
"Jupyterlab is the modern web interface for Jupyter. It is more powerful by\n",
"allowing multiple notebooks to be edited in the same browser window. You will\n",
"find it much more convenient to use. \n",
"\n",
"You can install JupyterLab by\n",
"\n",
"```bash\n",
"mamba install jupyterlab\n",
"```\n",
"\n",
"You can launch JupyterLab by\n",
"\n",
"```bash\n",
"jupyter lab\n",
"```\n",
"\n",
"## Tour of Jupyter Notebook and JupyterLab\n",
"\n",
"The official Jupyter website contains two brief tours:\n",
"\n",
"- [Jupyter Notebook Tour](https://jupyter.org/try-jupyter/notebooks/?path=notebooks/Intro.ipynb)\n",
"- [JupyterLab Tour](https://jupyter.org/try-jupyter/lab/index.html)\n",
"\n",
"Please visit each of them. After the page loads, you will see a message at the\n",
"lower right corner, saying \"Try the Notebook Tour\" or \"Try the Welcome Tour.\".\n",
"Click \"Start Now\" to begin the tour. \n",
"\n",
"## Shortcuts\n",
"\n",
"Learning to use shortcuts can significantly increase your productivity! Here are\n",
"some shortcuts to start with:\n",
"\n",
"1. When you are editing a cell, press `esc` to exit edit mode.\n",
"2. When you are NOT editing a cell, you can use arrow keys to move around.\n",
" Alternatively, you can use `j` and `k` to move between cells. `j` and `k`\n",
" reduces the travel distance of the hand compared to arrow keys.\n",
"3. To edit a cell, move the focus there and press `Enter`.\n",
"3. You can insert a cell using `b` (below) or `a` (above).\n",
"4. You can delete a cell using `dd`.\n",
"5. You can run a cell using `Shift+Enter`. This will run the cell and move the\n",
" focus to the next cell. If this is the last cell, a new one will be inserted.\n",
"6. Merge a cell with the cell below it using `Shift+M`.\n",
"7. To split a cell into two, move the focus to the line where you want to split,\n",
" then press `Ctrl+Shift+Minus(-)`. Think of that `-` as a separator.\n",
"8. To change a cell from code to markdown, press `m`. To change it back to code,\n",
" press `y`.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
67 changes: 55 additions & 12 deletions pct/modules/01/wsl.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
# Windows Subsystem for Linux

## Introduction
## Why Linux?

Windows Subsystem for Linux (WSL) is a feature of Windows that allows one to
create a Linux environment within Windows. WSL eliminates the need for a
virtual machine or dual-boot to use Linux. WSL was originally created to meet the
demand from users who want to use Linux BASH productivity tools in Windows
{cite}`why-was-wsl-created`.
You may have heard of Linux from news articles. You may know that Linux powers
many devices, from an Android smart phone to supercomputers to Steam Deck and
Tesla. Linux is free and open source software, and it is the foundation of many
operating systems.

You may not have used Linux before, and that is okay! Most of the work a power
engineering researcher does is in Windows. Many of the power domain software are
exclusively available on Windows.

But why do we want to use Linux? Many of the data analytics and machine learning
libraries are developed with Linux in mind. That means they are easier to set up
[TODO: ref]
and faster to run [TODO: ref] on Linux.

You probably have heard that Linux is difficult to use. In the early days,
command line was the only usable interface. Well, that is still true for many
use cases, but you only need a small set of skills to productive with Linux.

So let's dive in.


## Windows Subsystem for Linux (WSL)

Apparently, we do not want to buy a new computer just for Linux if you have one
that runs Windows. Maybe you have heard of Virtual Machines (VM). VMs are
programs that emulate a computer inside your operating system, so that you can
run another operating system there. The issue of VMs is that they are slow; it
takes too much resources to emulate everything of a computer. We will resort to
a newer technology called Windows Subsystem for Linux (WSL).

WSL is a feature of Windows that allows one to create a Linux environment within
Windows. WSL eliminates the need for a virtual machine or dual-boot to use
Linux. WSL was originally created to meet the demand from users who want to use
Linux BASH productivity tools in Windows {cite}`why-was-wsl-created`.


`````{admonition} How is WSL different from a virtual machine?
:class: tip
You may have used a virtual machine to run Linux on Windows, such as VirtualBox
or VMware. These virtual machines software emulates a physical computer from the
ground up on the host operating system. WSL is different by using a
compatibility layer that is transparent to the user to run Linux applications.
VM software, such as VirtualBox or VMware, emulates a physical computer from the
ground up on the host operating system. WSL is different by using a compatibility
layer that is transparent to the user to run Linux applications. WSL is thus
more lightweight and faster than a VM.
`````

## Installing WSL

You can install WSL on Windows 10 or later. On Windows 11 or later, WSL can support
graphical applications that are native to Linux.

If you don't have a preference on the Linux distribution, you may go with Ubuntu.
If you don't have a preference on the Linux distribution, you may go with
Ubuntu.

Follow the video below to install WSL and Ubuntu.

<iframe width="560" height="315" src="https://www.youtube.com/embed/eId6K8d0v6o?si=gnCRURtNuQKkwXrq" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

Expand Down Expand Up @@ -59,4 +92,14 @@ your WSL files from Windows.

```{bibliography}
:filter: docname in docnames
```
```


:::{admonition} Quizzes

1. Why do we want to use Linux?
2. What does WSL stand for?
3. How is WSL different from a virtual machine?
4. How do you launch WSL?
5. How do you distinguish between Windows and Linux files?
:::

0 comments on commit a7cf0eb

Please sign in to comment.