Skip to content
Merged
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
21 changes: 5 additions & 16 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
FROM pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
FROM astral/uv:0.8.22-python3.10-bookworm-slim
WORKDIR /workspaces/pathpyG
RUN apt-get update
RUN apt-get -y install git

# For signed commits: https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials#_sharing-gpg-keys
RUN apt install gnupg2 -y
# Install git (and gpg for signed commits: https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials#_sharing-gpg-keys)
RUN apt-get update && apt-get -y install git gnupg2

# Install dependencies for .svg support in tikz
RUN apt update && apt install -y ghostscript
RUN apt-get update && apt-get -y install ghostscript

# Install dependencies for manim
RUN apt-get install -y build-essential python3-dev libcairo2-dev libpango1.0-dev ffmpeg

# Install torch
RUN pip install torch==2.4.1+cu121 --index-url https://download.pytorch.org/whl/cu121
# pip install torch==2.4.1+cpu --index-url https://download.pytorch.org/whl/cpu # CPU only

# Install torch_geometric and dependencies
RUN pip install torch_geometric>=2.5.0
RUN pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.4.0+cu121.html
# RUN pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.4.0+cpu.html # CPU only
RUN apt-get update && apt-get -y install build-essential python3-dev libcairo2-dev libpango1.0-dev ffmpeg
39 changes: 21 additions & 18 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@
"build": {
"dockerfile": "Dockerfile"
},
"name": "pathpyG-torch2.4.1-cuda12.1",
"name": "pathpyG-torch2.8.0-cuda12.9",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"ms-toolsai.jupyter"
"ms-toolsai.jupyter",
"charliermarsh.ruff",
"ms-python.mypy-type-checker"
],
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.analysis.typeCheckingMode": "basic"
"settings": {
"[python]": {
"analysis.languageServerMode": "light",
"editor.defaultFormatter": "charliermarsh.ruff",
"notebook.defaultFormatter": "charliermarsh.ruff",
"mypy-type-checker.importStrategy": "fromEnvironment"
}
}
},
// Add IDs of extensions you want to be installed when container is created.
"extensions": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"ms-toolsai.jupyter"
"ms-toolsai.jupyter",
"charliermarsh.ruff",
"ms-python.mypy-type-checker"
]
},
// Use GPU for CUDA
Expand All @@ -37,7 +35,12 @@
"all"
],
// Install pathpyG as editable python package
"postCreateCommand": "pip install -e '.[dev,test,doc,vis]' && git config --global --add safe.directory /workspaces/pathpyG",
// Use optional dependencies 'vis' for visualization (manim) and 'cu129' for CUDA 12.9 support
// (change 'cu129' to 'cpu' if you want to use the CPU version of PyTorch and PyTorch Geometric)
"postCreateCommand": "uv sync --frozen --extra vis --extra cu129 && git config --global --add safe.directory /workspaces/pathpyG",
"remoteEnv": {
"PATH": "/workspaces/pathpyG/.venv/bin:${containerEnv:PATH}"
},
"features": {
"ghcr.io/prulloac/devcontainer-features/latex:1": {
"scheme": "minimal",
Expand Down
43 changes: 13 additions & 30 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,40 @@ inputs: # defaults are set to the version used in the dev container
required: false
default: "3.10"
description: "The Python version to use."
torch-version:
required: false
default: "2.4.0"
description: "The PyTorch version to use."
cuda-version:
required: false
default: cpu # For GPU support a self-hosted runner is required.
description: "If CUDA should be used or not."
full_install:
required: false
default: true
description: "If all side packages of PyTorch Geometric should be installed."
description: "If optional dependencies like `manim` and `LaTeX` should be installed."

runs:
using: composite

steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
check-latest: true
cache: pip
cache-dependency-path: |
pyproject.toml

- name: Install manim dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3-dev libcairo2-dev libpango1.0-dev ffmpeg
shell: bash
activate-environment: true

- name: Install PyTorch ${{ inputs.torch-version }}+${{ inputs.cuda-version }}
- name: Install pathpyG
run: |
pip install torch==${{ inputs.torch-version }} --extra-index-url https://download.pytorch.org/whl/${{ inputs.cuda-version }}
python -c "import torch; print('PyTorch:', torch.__version__)"
python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
python -c "import torch; print('CUDA:', torch.version.cuda)"
uv sync --frozen --extra ${{ inputs.cuda-version }}
shell: bash

- name: Install pyg-lib # pyg-lib is currently only available on Linux.
if: ${{runner.os == 'Linux' }}
- name: Check installation
run: |
pip uninstall -y pyg-lib
pip install --no-index pyg-lib -f https://data.pyg.org/whl/torch-${{ inputs.torch-version }}+${{ inputs.cuda-version }}.html
uv run python -c "import torch; print('PyTorch:', torch.__version__)"
uv run python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
uv run python -c "import torch; print('CUDA:', torch.version.cuda)"
shell: bash

- name: Install extension packages
if: ${{ inputs.full_install == 'true' }}
run: | # scipy installation before torch-scatter is required to solve dependency conflicts
pip install torch_geometric
pip install scipy
pip install --no-index --upgrade torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-${{ inputs.torch-version }}+${{ inputs.cuda-version }}.html
run: | # ToDo: Add LaTeX installation
sudo apt-get update && sudo apt-get install -y build-essential python3-dev libcairo2-dev libpango1.0-dev ffmpeg
uv sync --frozen --extra vis --extra ${{ inputs.cuda-version }}
shell: bash
6 changes: 1 addition & 5 deletions .github/workflows/docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup packages
uses: ./.github/actions/setup

- name: Install dependencies
run: |
pip install -e .[doc]

- name: Get variables
run: |
python -c 'import pathpyG; print(f"package_version={pathpyG.__version__}")' >> "$GITHUB_ENV"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/docs-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup packages
uses: ./.github/actions/setup

- name: Install dependencies
run: |
pip install -e .[doc]

- name: Get package version
run: |
python -c 'import pathpyG; print(f"package_version={pathpyG.__version__}")' >> "$GITHUB_ENV"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/full_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup packages
uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
torch-version: ${{ matrix.torch-version }}

- name: Install main package
run: |
pip install -e .[test,vis]

- name: Run tests
run: |
pytest
Expand Down
40 changes: 10 additions & 30 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,46 @@
# Inspired by https://github.com/pyg-team/pytorch_geometric/blob/ee30973ed0957a7f29f345d4eeaf9cfd70805109/.github/workflows/linting.yml
name: Linting

description: Run ruff and mypy to check code quality and type hints.

on:
push:
branches:
- main
pull_request:

jobs:
pylint: # linter: tool that checks for errors in Python code, tries to enforce a coding standard and looks for bad code smells
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup packages
uses: ./.github/actions/setup
with:
full_install: false

- name: Install dependencies
run: pip install pylint

- name: Run linting
continue-on-error: true
run: pylint $(git ls-files '*.py')

flake8: # Another linter: Mostly checks if code is PEP8 conform but has some additional plugins.
ruff:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.10.13" # As in docker image (pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime) used as dev container
python-version: "3.10.18" # As in docker image (pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime) used as dev container

- name: Install dependencies
run: pip install flake8 flake8-pyproject flake8-bugbear
run: pip install ruff

- name: Run linting
continue-on-error: true
run: flake8 $(git ls-files '*.py')
run: ruff check .

mypy: # stricter static type checker
mypy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup packages
uses: ./.github/actions/setup
with:
full_install: false

- name: Install dependencies
run: pip install mypy

- name: Check type hints
continue-on-error: true
run: |
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

# Only run workflow if certain files have been changed.
- name: Get changed files
Expand All @@ -31,11 +31,6 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/actions/setup

- name: Install main package
if: steps.changed-files.outputs.any_changed == 'true'
run: |
pip install -e .[test,vis]

- name: Run tests
if: steps.changed-files.outputs.any_changed == 'true'
run: |
Expand Down
26 changes: 1 addition & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,9 @@
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
},
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"python.formatting.provider": "none", // disable for now. Will be deprecated in the future
"python.defaultInterpreterPath": "/workspaces/pathpyG/.venv/bin/python",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"black-formatter.importStrategy": "fromEnvironment",
"black-formatter.args": [
"--config=pyproject.toml"
],
"pylint.importStrategy": "fromEnvironment",
"pylint.args": [
"--rcfile=pyproject.toml"
],
"flake8.importStrategy": "fromEnvironment",
"flake8.args": [
"--toml-config=pyproject.toml"
],
"isort.importStrategy": "fromEnvironment",
"isort.args": [
"--settings-path=pyproject.toml"
],
"mypy-type-checker.importStrategy": "fromEnvironment",
"mypy-type-checker.args": [
"--config-file=pyproject.toml"
],
"python.testing.pytestArgs": [
"tests"
],
Expand Down
Loading
Loading