This repository contains the notebooks and data used in the SMART CITIES 4500 lessons. Each lesson’s notebook is designed to be reproducible in two ways:
- in the browser using Google Colab (easier, no installation) - requires Google account.,
- on your own machine using Python and a local clone of the
student-notebooksbranch (more technical, but more flexible).
- At the top each reproducible notebook in this repo, there is an “Open in Colab” badge
.
- Open each lesson notebook by clicking the badge, which will launch it in Google Colab in your browser. (You need a Google account for this.)
- If the notebook requires local data files:
- In Colab, use the folder icon on the left → “Upload” to upload the files from the Datasets section in this repo.
- Alternatively, you can mount Google Drive (as described in the notebook) and put the files there.
⚠️ Note: Colab gives you a fresh environment every time, so you may need to re‑upload data files or re‑run setup cells at the start of each new session.
This option assumes you want to clone the student-notebooks branch and run notebooks locally in an IDE such as VS Code. We reccomend uv to manage the virtual environment and dependencies.
⚠️ Note: Thestudent-notebooksbranch contains the latest version of the student notebooks and correspondingdata/folders for each lesson.
Once you've cloned the student-notebooks branch, the folder structure should look like this:
.
├── src/
│ ├── week1.ipynb
│ ├── week2.ipynb
│ └── ...
├── data/
│ ├── demography/
│ ├── traffic/
│ └── ...
├── requirements.txt
├── pyproject.toml
└── README.md
A virtual environment is an isolated Python installation that keeps the packages for one project separate from everything else on your system.
This avoids version conflicts and makes it easier to reproduce results: everyone installs the same package versions listed in requirements.txt / pyproject.toml using uv.
Mac OS
Homebrew:
brew install uvWindows
PowerShell:
```
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```
After installation, verify:
uv --versionChoose a folder on your machine and clone only the student branch:
git clone --single-branch --branch student-notebooks https://github.com/gregmaya/oslomet-smua4500When new lessons are published, you can pull updates with:
git pullfrom inside the cloned folder.
From the project root:
# Create / update the virtual environment and install packages
uv sync-
uv syncreads the project configuration (e.g.pyproject.toml/requirements.txt), creates a.venv/directory, and installs the specified package versions. -
To upgrade packages (if the instructor announces an update):
uv sync --upgrade
Commonly, VSCode will auto-detect and use the .venv environment once it exists. If not, you can select it manually via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) → “Python: Select Interpreter” → choose the one in .venv.
If that doesn’t work, or if you want to run from the command line, you can activate the environment manually.
-
macOS / Linux (bash/zsh):
source .venv/bin/activate -
Windows (PowerShell):
.venv\Scripts\Activate.ps1
Your shell prompt should change, indicating the environment is active. To deactivate later, run:
deactivateIn VS Code:
- Open the cloned folder in VS Code.
- Install the Python and Jupyter extensions if prompted.
- In any
.ipynbnotebook, use the “Select Kernel” dropdown and point it to the Python interpreter in.venv(VS Code usually auto‑detects it).
Now you can open src/weekXX/notebook.ipynb and run the cells locally.
The instructor will periodically push new or updated notebooks and data to the student-notebooks branch. To update:
git pull
uv syncgit pullfetches any new lesson folders and notebook changes.uv syncensures your virtual environment matches any updated dependencies.