Skip to content

Commit 28023d5

Browse files
authored
Merge pull request #256 from geometric-intelligence/uv_env
Add uv installation script and support
2 parents c8cb96e + 086ce97 commit 28023d5

10 files changed

Lines changed: 253 additions & 150 deletions

File tree

.github/workflows/docs.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,51 @@ on:
55
branches: [main, github-actions-test]
66
pull_request:
77
branches: [main]
8+
89
permissions:
910
contents: write
1011

1112
jobs:
1213
build:
13-
runs-on: ${{matrix.os}}
14+
runs-on: ubuntu-latest
1415
strategy:
1516
matrix:
16-
os: [ubuntu-latest]
17-
python-version: [3.11.3]
18-
torch-version: [2.0.1]
19-
include:
20-
- torch-version: 2.0.1
17+
python-version: ["3.11"]
2118

2219
steps:
23-
- uses: actions/checkout@v3
24-
- name: Build using Python ${{matrix.python-version}}
25-
uses: actions/setup-python@v4
20+
- uses: actions/checkout@v4
21+
22+
# 1. Setup uv
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
2625
with:
27-
python-version: ${{matrix.python-version}}
28-
cache: "pip"
29-
cache-dependency-path: "pyproject.toml"
30-
- name: Install dependencies [pip]
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install pytest
34-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
35-
source env_setup.sh
36-
- name: Install Pandoc [apt-get]
26+
python-version: ${{ matrix.python-version }}
27+
enable-cache: true
28+
cache-dependency-glob: "uv.lock"
29+
30+
# 2. Run your centralized installation script
31+
- name: Install dependencies (via script)
3732
run: |
38-
sudo apt-get -y install pandoc
33+
# This installs '.[all]' which includes doc dependencies
34+
source uv_env_setup.sh
35+
36+
# 3. Install System Dependencies
37+
- name: Install Pandoc
38+
run: sudo apt-get -y install pandoc
39+
40+
# 4. Generate Docs
3941
- name: Generate API Documentation
4042
run: |
43+
source .venv/bin/activate
4144
cd docs
4245
bash generate_api_docs.sh
46+
4347
- name: Generate Docs [Sphinx]
4448
run: |
45-
sphinx-build -b html -D version=latest -D release=latest docs docs/_build
49+
source .venv/bin/activate
50+
sphinx-build -b html -D version=latest -D release=latest docs docs/_build
51+
52+
# 5. Deploy
4653
- name: Deploy Docs
4754
uses: JamesIves/github-pages-deploy-action@v4
4855
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'geometric-intelligence/TopoBench' }}

.github/workflows/lint.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
ruff:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v3
14-
- uses: chartboost/ruff-action@v1
16+
- uses: actions/checkout@v4
17+
18+
# We use the official action from Astral (creators of uv & ruff)
19+
- name: Run Ruff
20+
uses: astral-sh/ruff-action@v3
1521
with:
16-
src: './topobench'
22+
src: "./topobench"
23+
# This ensures the ruff version matches what you have in pyproject.toml
24+
version-file: "pyproject.toml"
25+
# Optional: fails the build if the code changes (e.g. formatting)
26+
changed-files: "true"

.github/workflows/test.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
41
name: Testing
52

63
on:
@@ -14,38 +11,38 @@ permissions:
1411

1512
jobs:
1613
build:
17-
runs-on: ${{matrix.os}}
14+
runs-on: ubuntu-latest
1815
strategy:
1916
matrix:
20-
os: [ubuntu-latest]
21-
python-version: [3.11.3]
17+
python-version: ["3.11"]
2218

2319
steps:
2420
- uses: actions/checkout@v4
25-
- name: Set up Python ${{matrix.python-version}}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{matrix.python-version}}
2921

30-
- uses: actions/cache@v4
22+
# 1. Setup uv
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
3125
with:
32-
path: ~/.cache/pip
33-
key: ${{matrix.os}}-${{matrix.python-version}}-${{ hashFiles('pyproject.toml') }}
26+
python-version: ${{ matrix.python-version }}
27+
enable-cache: true
28+
cache-dependency-glob: "uv.lock"
3429

35-
- name: Install dependencies
30+
# 2. Run your centralized installation script
31+
- name: Install dependencies (via script)
3632
run: |
37-
python -m pip install --upgrade pip
38-
pip install pytest
39-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
40-
source env_setup.sh
33+
# This script handles the .venv creation and PyTorch/CUDA logic
34+
source uv_env_setup.sh
4135
36+
# 3. Run Tests
4237
- name: Test with pytest
4338
run: |
39+
# We must activate the venv created by your script
40+
source .venv/bin/activate
4441
pytest --cov --cov-report=xml:coverage.xml test/
4542
4643
- name: Upload coverage reports to Codecov
4744
uses: codecov/codecov-action@v4.0.1
4845
with:
4946
token: ${{ secrets.CODECOV_TOKEN }}
5047
file: coverage.xml
51-
fail_ci_if_error: false
48+
fail_ci_if_error: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,4 @@ wandb/
194194

195195
# test temporary
196196
.test_tmp/
197+
uv.lock

README.md

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -52,44 +52,58 @@ The main pipeline trains and evaluates a wide range of state-of-the-art TNNs and
5252

5353
## :jigsaw: Get Started
5454

55-
### Create Environment
55+
### 🚀 Quick Install (Recommended)
5656

57-
First, ensure `conda` is installed:
58-
```bash
59-
conda --version
60-
```
61-
If not, we recommend intalling Miniconda [following the official command line instructions](https://www.anaconda.com/docs/getting-started/miniconda/install).
57+
TopoBench now uses [**uv**](https://docs.astral.sh/uv/), an extremely fast Python package manager and resolver. This allows for nearly instantaneous environment setup and reproducible builds.
6258

63-
Then, clone and navigate to the `TopoBench` repository
64-
```bash
65-
git clone git@github.com:geometric-intelligence/topobench.git
66-
cd TopoBench
67-
```
59+
1. [**Install uv**](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer)
6860

69-
Next, set up and activate a conda environment `tb` with Python 3.11.3:
70-
```bash
71-
conda create -n tb python=3.11.3
72-
conda activate tb
73-
```
61+
2. **Clone and Navigate**:
62+
```bash
63+
git clone git@github.com:geometric-intelligence/topobench.git
64+
cd TopoBench
65+
```
7466

75-
If working with GPUs, check the CUDA version of your machine:
76-
```bash
77-
which nvcc && nvcc --version
78-
```
79-
and ensure that it matches the CUDA version specified in the `env_setup.sh` file (`CUDA=cpu` by default for a broader compatibility). If it does not match, update `env_setup.sh` accordingly by changing both the `CUDA` and `TORCH` environment variables to compatible values as specified on [this website](https://github.com/pyg-team/pyg-lib).
67+
3. **Initialize Environment**:
68+
Use our centralized setup script to handle Python 3.11 virtualization and specialized hardware (CUDA) mapping.
69+
```bash
70+
# Usage: source uv_env_setup.sh [cpu|cu118|cu121]
71+
source uv_env_setup.sh cpu
72+
```
73+
*This script performs the following:*
74+
* Creates a `.venv` using Python 3.11.
75+
* Dynamically configures `pyproject.toml` to point to the correct **PyTorch** and **PyG** (PyTorch Geometric) wheels for your platform.
76+
* Generates a precise `uv.lock` file and syncs all dependencies.
77+
78+
---
79+
80+
### 🛠️ Manual Environment Setup
81+
82+
If you prefer to manage the environment manually or are integrating into an existing workflow:
8083

81-
Next, set up the environment with the following command.
8284
```bash
83-
source env_setup.sh
85+
# Create a virtual environment with strict versioning
86+
uv venv --python 3.11
87+
source .venv/bin/activate
88+
89+
# Sync dependencies including all extras (dev, test, and doc)
90+
uv sync --all-extras
8491
```
85-
This command installs the `TopoBench` library and its dependencies.
8692

87-
### Run Training Pipeline
93+
🚄 Run Training Pipeline
94+
Once the environment is active, you can launch the TopoBench pipeline:
95+
```bash
96+
# Using the activated virtual environment
97+
python -m topobench
8898
89-
Once the setup is completed, train and evaluate a neural network by running the following command:
99+
# Or execute directly via uv without manual activation
100+
uv run python -m topobench
101+
```
90102

103+
✅ Verify Installation
104+
You can verify that the correct versions of Torch and CUDA are detected by running:
91105
```bash
92-
python -m topobench
106+
python -c "import torch; print(f'Torch: {torch.__version__} | CUDA: {torch.version.cuda}')"
93107
```
94108

95109
---
@@ -390,14 +404,15 @@ Specially useful in pre-processing steps, these are the general data manipulatio
390404
To learn more about `TopoBench`, we invite you to read the paper:
391405

392406
```
393-
@article{telyatnikov2024topobench,
394-
title={TopoBench: A Framework for Benchmarking Topological Deep Learning},
395-
author={Lev Telyatnikov and Guillermo Bernardez and Marco Montagna and Pavlo Vasylenko and Ghada Zamzmi and Mustafa Hajij and Michael T Schaub and Nina Miolane and Simone Scardapane and Theodore Papamarkou},
396-
year={2024},
397-
eprint={2406.06642},
398-
archivePrefix={arXiv},
399-
primaryClass={cs.LG},
400-
url={https://arxiv.org/abs/2406.06642},
407+
@article{
408+
telyatnikov2025topobench,
409+
title={TopoBench: A Framework for Benchmarking Topological Deep Learning},
410+
author={Lev Telyatnikov and Guillermo Bernardez and Marco Montagna and Mustafa Hajij and Martin Carrasco and Pavlo Vasylenko and Mathilde Papillon and Ghada Zamzmi and Michael T Schaub and Jonas Verhellen and Pavel Snopov and Bertran Miquel-Oliver and Manel Gil-Sorribes and Alexis Molina and VICTOR GUALLAR and Theodore Long and Julian Suk and Patryk Rygiel and Alexander V Nikitin and Giordan Escalona and Michael Banf and Dominik Filipiak and Liliya Imasheva and Max Schattauer and Alvaro L. Martinez and Halley Fritze and Marissa Masden and Valentina S{\'a}nchez and Manuel Lecha and Andrea Cavallo and Claudio Battiloro and Matthew Piekenbrock and Mauricio Tec and George Dasoulas and Nina Miolane and Simone Scardapane and Theodore Papamarkou},
411+
journal={Journal of Data-centric Machine Learning Research},
412+
issn={XXXX-XXXX},
413+
year={2025},
414+
url={https://openreview.net/forum?id=07sTzyEVtY},
415+
note={}
401416
}
402417
```
403418
If you find `TopoBench` useful, we would appreciate if you cite us!

env_setup.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)