Skip to content
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Local database files
*.duckdb

# Python environment
# Python environment (UV creates .venv by default)
.venv/

# Mono auto generated files
Expand Down
46 changes: 29 additions & 17 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,41 +104,52 @@ If you don't have git:



#### 4. The Sandbox (Virtual Environment)
#### 4. UV

In tech policy, you know the value of containment. We don't want to install software libraries globally where they might break other things. We use a **Virtual Environment (venv)**—a self-contained sandbox for this specific project.
In tech policy, you know the value of containment. We don't want to install software libraries globally where they might break other things. We use **UV**—a modern, fast Python package manager that handles everything for us: creating a sandbox, installing the right Python version, and fetching dependencies.

* *Concept:* **UV** is like a smart assistant that sets up your entire Python environment automatically. It reads a "shopping list" called `pyproject.toml` and fetches everything you need in one command.

**Installing UV:**

**On Windows (PowerShell):**

```powershell
python -m venv venv
.\venv\Scripts\activate

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

After installation, **close and reopen PowerShell** for the changes to take effect.

**On Mac/Linux (Terminal):**

```bash
python3 -m venv venv
source venv/bin/activate

curl -LsSf https://astral.sh/uv/install.sh | sh
```

*Check:* You should see `(venv)` appear at the start of your command prompt line. You are now inside the sandbox.
After installation, either restart your terminal or run:
```bash
source $HOME/.local/bin/env
```

#### 5. Install Dependencies (The "Pip" Step)
*Check:* Type `uv --version` and press Enter. You should see a version number like `uv 0.5.x`. If you see "command not found", try restarting your terminal.

We need to equip our sandbox with specific tools like `streamlit` (for the website) and `duckdb` (for the database). To do this, we use **pip**.
#### 5. Install Dependencies (The "UV Sync" Step)

* *Concept:* **Pip** is the App Store installer for Python. Instead of browsing a store, we give it a shopping list called `requirements.txt`, and it fetches everything for us automatically.
Now we use UV to create our sandbox and install all the tools we need (like `streamlit` for the website and `duckdb` for the database).

Run this command:
Run this command from inside the project folder:

```bash
pip install -r requirements.txt

uv sync
```

*What just happened?* UV did several things automatically:
1. Created a `.venv` folder (the sandbox)
2. Installed the correct Python version if needed
3. Downloaded and installed all the required libraries

*Check:* You should see output showing packages being installed. When it's done, you'll see something like "Resolved X packages" and "Installed X packages".

#### 6. Load the Cartridge

Tell Ollama to download the specific brain we need (model `qwen3:4b`).
Expand Down Expand Up @@ -175,10 +186,11 @@ We have set `debug_mode = true` by default.
**Save the file** if you made any changes. Now, run the app from your CLI:

```bash
streamlit run parliament.py

uv run streamlit run parliament.py
```

*Note:* We use `uv run` to execute commands inside our sandbox. This ensures Streamlit uses the correct Python environment with all our installed dependencies.

### 🌐 Part 3: Accessing the Dashboard

*(Time: 2 mins)*
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[project]
name = "parliament-uk"
version = "0.1.0"
description = "A demonstrator for the Regulate Tech podcast series that pulls and analyses UK Parliament data"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"streamlit",
"duckdb",
"requests",
"pandas",
"toml",
]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.