diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..e68b284 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,36 @@ +# Dev Container Configuration + +This directory contains the development container configuration for the diffusion model workshop. + +## What gets installed + +When a user opens this repository in GitHub Codespaces, the following will be automatically set up: + +### Base Environment +- Python 3.11 (Debian Bullseye) +- Git and GitHub CLI + +### Python Dependencies +- **Workshop dependencies**: Installed from `pyproject.toml` + - Diffusers, transformers, scikit-learn and other ML libraries + - PyTorch CPU version (for lighter resource usage in Codespaces) +- **Documentation dependencies**: Also installed from `pyproject.toml` + - MkDocs and related tools for building documentation + +### VS Code Extensions +- Python development: Python, Pylance, Black formatter, Ruff linter +- Jupyter notebooks: Full Jupyter support with renderers and keybindings +- General development: JSON, YAML, and Markdown support + +### Port Forwarding +- **Port 8888**: Jupyter notebook server + +## Usage + +Users simply need to: +1. Fork this repository +2. Open in GitHub Codespaces +3. Wait for the automatic setup to complete +4. Start working with the workshop materials + +The environment will be ready to use with all dependencies installed and VS Code properly configured for Python and Jupyter development. \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..61037d3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,50 @@ +{ + "name": "Diffusion Models Workshop", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + + "features": { + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-toolsai.jupyter", + "ms-toolsai.jupyter-keymap", + "ms-toolsai.jupyter-renderers", + "ms-python.black-formatter", + "charliermarsh.ruff", + "ms-vscode.vscode-json", + "redhat.vscode-yaml", + "ms-vscode.vscode-markdown" + ], + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": false, + "python.formatting.provider": "black", + "jupyter.askForKernelRestart": false, + "files.associations": { + "*.ipynb": "jupyter-notebook" + } + } + } + }, + + "postCreateCommand": "./.devcontainer/uv_setup.sh && ./.devcontainer/torch_setup.sh", + + "remoteUser": "vscode", + + "forwardPorts": [8888], + + "portsAttributes": { + "8888": { + "label": "Jupyter", + "onAutoForward": "notify" + } + } +} \ No newline at end of file diff --git a/.devcontainer/torch_setup.sh b/.devcontainer/torch_setup.sh new file mode 100755 index 0000000..6b0facf --- /dev/null +++ b/.devcontainer/torch_setup.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euxo pipefail + +# Install torch into venv (CPU build for codespaces) +uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu \ No newline at end of file diff --git a/.devcontainer/uv_setup.sh b/.devcontainer/uv_setup.sh new file mode 100755 index 0000000..151b0f6 --- /dev/null +++ b/.devcontainer/uv_setup.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euxo pipefail + +# Install uv +curl -LsSf https://astral.sh/uv/install.sh | sh + +# Install runtime deps into .venv +uv sync + +# Activate venv +echo 'source .venv/bin/activate' >> ~/.bashrc \ No newline at end of file diff --git a/docs/setting-up/codespaces.md b/docs/setting-up/codespaces.md new file mode 100644 index 0000000..45beee6 --- /dev/null +++ b/docs/setting-up/codespaces.md @@ -0,0 +1,13 @@ +# Codespaces + +For this workshop, you can work entirely within Github Codespaces. + +!!! warning + + GitHub Codespaces only provides CPU resources, which means training and inference of the models will run much slower. If you have access to a GPU on your local machine, we recommend running the workshop locally instead and installing PyTorch manually by following the instructions in [Running Locally](./running-locally.md). + +First create a new repository on Github, and then create a codespace from that repository. + +Navigate to the LLM workshop repo (click the GitHub symbol in the top right of this page). Switch to the `Handson` branch, and download the content as a zip file. Upload this to your new repo. Open the repo as a Codespace. There is no need to create a virtual environment, since you're already in a containerized environment anyway with a version of Python 3.12. + +You don’t need to create or manage a virtual environment yourself. The devcontainer will automatically install `uv`, create and activate a `.venv`, and install all required dependencies when your Codespace is built. \ No newline at end of file diff --git a/docs/Introduction/running-locally.md b/docs/setting-up/running-locally.md similarity index 100% rename from docs/Introduction/running-locally.md rename to docs/setting-up/running-locally.md diff --git a/mkdocs.yml b/mkdocs.yml index 6bb47e7..ba08c48 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,9 +7,11 @@ nav: - The Workshop: Home/workshop.md - License: Home/LICENSE.md - About us: Home/about.md + - Setting up: + - Codespaces: setting-up/codespaces.md + - Running Locally: setting-up/running-locally.md - Introduction: - Introduction: Introduction/Introduction.md - - Running Locally: Introduction/running-locally.md - Physics: Physics/Physics.md - Building Blocks: - BuildingBlocks/index.md