Skip to content

Switch to uv package manager for easy setup #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions requirements.txt → .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# SPDX-License-Identifier: MPL-2.0

power-grid-model[doc] >= 1.9
jupyter
matplotlib
repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v5.0.2
hooks:
- id: reuse
77 changes: 27 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,70 +23,47 @@ It is recommended to read the numpy structured array

Please create the relevant environment before the workshop. If you encounter problems, please raise a question in the [discussion board](https://github.com/orgs/PowerGridModel/discussions)

### Preparation for Windows (beginners guide)

1. [Download](https://github.com/PowerGridModel/power-grid-model-workshop/archive/refs/heads/main.zip) (or
checkout) this workshop/repository and remember the destination location. For example:
`C:\Users\YourUserName\Downloads\power-grid-model-workshop`.

1. Install the latest [Python](https://www.python.org/ftp/python/3.10.7/python-3.10.7-amd64.exe) version.
You probably want the **Windows installer (64-bit)** under **Stable Release**.

1. Now open a terminal (Windows-Key + R, type `cmd`, press **OK**) and use the `cd` (change dir) command to navigate
to the folder where you downloaded the workshop. For example:
```shell
C:\Users\YourUserName> cd Downloads\power-grid-model-workshop
C:\Users\YourUserName\Downloads\power-grid-model-workshop>_
```
1. Optional: Create and activate a virtual environment. You can skip this step, but it helps you to keep your system
clean, as we will be installing about 70 Python packages in the next step.
```shell
> python -m venv venv
> venv\Scripts\activate
```
1. install Power Grid Model and some other packages we'll use for this workshop:
### Preparation with uv (Windows/Mac/Linux)
1. Open a terminal
- Windows: Press `Windows-Key + R`, type `cmd`, press **OK**
- Mac/Linux: Open a terminal
1. Download or clone this workshop/repository
- if you download the repository, remember the destination location. For example:
- Windows:`C:\Users\YourUserName\Downloads\power-grid-model-workshop`
- Mac/Linux: `~/Downloads/power-grid-model-workshop`
1. Install the `uv` package manager [link](https://docs.astral.sh/uv/getting-started/installation)
for your operating system (Windows/Mac/Linux)
1. Navigate to the repository folder
- Windows: `cd Downloads\power-grid-model-workshop`
- Mac/Linux: `cd ~/Downloads/power-grid-model-workshop`
1. Setup python environment and install dependencies using `uv`:
```shell
> pip install power-grid-model jupyter pandas matplotlib
uv sync
```
1. Now run jupyter notebook. It will probably (depending on your system) automatically open a browser at
1. Start jupyter notebook. It will probably (depending on your system) automatically open a browser at
http://localhost:8888. If not, the console output will tell you where to find the jupyter notebook server.
```shell
> jupyter notebook
uv run jupyter notebook
```
1. Try any of the `.ipynb` files, for example
[`Power Flow Example.ipynb`](http://localhost:8888/notebooks/examples/Power%20Flow%20Example.ipynb) and press the `>>`
button to run the entire file. Note that the last section in the Power Flow Example is about error handling, so
don't get scared if you see some error messages there.


### Next time, pick up where you left off

1. Open a terminal (Windows-Key + R, type `cmd`, press **OK**) and use the `cd` (change dir) command to navigate
to the folder where you downloaded the workshop. For example:
```shell
C:\Users\YourUserName> cd Downloads\power-grid-model-workshop
C:\Users\YourUserName\Downloads\power-grid-model-workshop>_
```
2. Optional: Activate the virtual environment (if you created one initially).
```shell
> venv\Scripts\activate
```
3. Run jupyter notebook. It will probably (depending on your system) automatically open a browser at
1. Again, open a terminal
- Windows: Press `Windows-Key + R`, type `cmd`, press **OK**
- Mac/Linux: Open a terminal
1. Navigate to the repository folder
- Example:
- Windows: `cd Downloads\power-grid-model-workshop`
- Mac/Linux: `cd ~/Downloads/power-grid-model-workshop`

1. Start jupyter notebook. It will probably (depending on your system) automatically open a browser at
http://localhost:8888. If not, the console output will tell you where to find the jupyter notebook server.
```shell
> jupyter notebook
```

### Preparation for WSL2 or Linux (for advanced users)

If you know WSL2/Linux you should be able to configure environment yourself.

```shell
> pip install power-grid-model jupyter pandas
> jupyter notebook
```

Open the jupyter notebook [`Power Flow Example.ipynb`](http://localhost:8888/Power%20Flow%20Example.ipynb), try to run it.
uv run jupyter notebook

## License

Expand Down
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2025 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

[project]
name = "power-grid-model-workshop"
version = "0.1.0"
description = "A collection of Jupyter notebooks for Power Grid Model workshops"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"jupyter>=1.1.1",
"matplotlib>=3.10.1",
"pandas>=2.2.3",
"power-grid-model>=1.10.88",
"power-grid-model-ds[visualizer]>=1.2.4",
]

[tool.setuptools]
packages = []
Loading