Skip to content

Commit

Permalink
DX: define developer environment with uv (#39)
Browse files Browse the repository at this point in the history
* DX: run notebooks with local kernel

---------

Co-authored-by: GitHub <[email protected]>
  • Loading branch information
redeboer and web-flow authored Oct 23, 2024
1 parent e12473a commit b27581e
Show file tree
Hide file tree
Showing 40 changed files with 5,096 additions and 501 deletions.
File renamed without changes.
10 changes: 10 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv export \
> requirements.txt
uv pip install \
--requirement requirements.txt \
--system
uv cache clean
1 change: 1 addition & 0 deletions .binder/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.12
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"ignorePaths": [
"**/.cspell.json",
".envrc",
".github/workflows",
".gitignore",
".pre-commit-config.yaml",
Expand Down Expand Up @@ -97,6 +98,7 @@
"preorder",
"pygments",
"pyplot",
"pyproject",
"pytest",
"redeboer",
"rtfd",
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ indent_size = 4
[LICENSE]
indent_size = unset

[setup.cfg]
[uv.lock]
indent_size = 4
3 changes: 2 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
layout anaconda
uv sync --all-extras --quiet
source .venv/bin/activate
2 changes: 1 addition & 1 deletion .github/workflows/clean-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
cleanup:
name: Remove caches
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: ComPWA/actions/clean-caches@v1
with:
Expand Down
103 changes: 0 additions & 103 deletions .github/workflows/constraints.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: |-
${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
on:
pull_request:
branches:
- main
- epic/*
paths:
- .pre-commit-config.yaml
- uv.lock
workflow_dispatch:

jobs:
lock:
uses: ComPWA/actions/.github/workflows/lock.yml@v2
secrets:
token: ${{ secrets.PAT }}
20 changes: 8 additions & 12 deletions .github/workflows/notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ on:
jobs:
pytest:
name: Run all notebooks
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- uses: hynek/setup-cached-uv@v2
- name: Install dependencies
run: |
sudo apt-get -y install graphviz
pip install uv
- run: |
for notebook in $(git ls-files | grep ipynb); do
uv pip sync requirements.txt --quiet --system
pytest $notebook --no-header
done
python-version: "3.12"
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install graphviz
run: sudo apt-get -y install graphviz
- run: uv run --extra dev pytest
4 changes: 2 additions & 2 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
check-labels:
name: Check labels
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest # cspell:ignore agilepathway
with:
Expand All @@ -28,7 +28,7 @@ jobs:

check-title:
name: Check title
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: npm install @compwa/commitlint-config
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
.ipynb_checkpoints/
.tox/
.virtual_documents/
condaenv.*.requirements.txt
node_modules/
60 changes: 31 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
ci:
autoupdate_commit_msg: "MAINT: autoupdate pre-commit hooks"
autoupdate_commit_msg: "MAINT: update lock files"
autoupdate_schedule: quarterly
skip:
- prettier
- taplo

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.1
hooks:
- id: check-dev-files
args:
- --doc-apt-packages=graphviz
- --no-cd
- --no-cspell-update
- --no-github-actions
- --no-pypi
- --repo-name=ComPWA-demo
- --repo-title="ComPWA demos"
- id: colab-toc-visible
- id: remove-empty-tags

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
args:
- --drop-empty-cells
- --extra-keys
- |
cell.attachments
Expand All @@ -38,24 +51,8 @@ repos:
metadata.varInspector
metadata.vscode
- repo: https://github.com/ComPWA/policy
rev: 0.3.18
hooks:
- id: check-dev-files
args:
- --no-cspell-update
- --no-github-actions
- --no-gitpod
- --no-prettierrc
- --no-pypi
- --no-version-branches
- --repo-name=ComPWA-demo
- --repo-title="ComPWA demos"
- id: colab-toc-visible
- id: remove-empty-tags

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.7.0
hooks:
- id: ruff
args: [--fix]
Expand All @@ -64,7 +61,7 @@ repos:
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -80,15 +77,15 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/ComPWA/prettier-pre-commit
rev: v3.3.3
hooks:
- id: prettier

- repo: https://github.com/ComPWA/mirrors-taplo
rev: v0.8.1
- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo
- id: taplo-format

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
Expand All @@ -98,13 +95,18 @@ repos:
- --in-place

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.2
rev: v8.15.2
hooks:
- id: cspell

- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.3
rev: 3.0.3
hooks:
- id: editorconfig-checker
name: editorconfig
alias: ec

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.25
hooks:
- id: uv-lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"mhutchie.git-graph",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.organizeImports": true,
"search.exclude": {
"**/uv.lock": true
},
"telemetry.telemetryLevel": "off"
}
1 change: 1 addition & 0 deletions 2021.11.29/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
Loading

0 comments on commit b27581e

Please sign in to comment.