Skip to content

Commit 2f16751

Browse files
authored
Merge pull request #6 from cvxgrp/migration-to-uv
Migration to uv along with workflow updates. No significant changes to the package code.
2 parents b37fbe7 + 3a26d78 commit 2f16751

File tree

14 files changed

+2217
-322
lines changed

14 files changed

+2217
-322
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on: pull_request
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- name: Install uv
10+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
11+
env:
12+
UV_COMPILE_BYTECODE: 1
13+
- name: Add uv to PATH
14+
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
15+
- name: Cache uv dependencies
16+
uses: actions/cache@v4
17+
with:
18+
path: .venv
19+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
20+
restore-keys: |
21+
${{ runner.os }}-uv-
22+
- name: Install dependencies
23+
run: uv sync
24+
- name: Test
25+
run: uv run pytest

.github/workflows/poetry-cd.yml

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

.github/workflows/poetry-ci.yml

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

.github/workflows/pre-commit.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v4
12+
- name: Install uv
13+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
14+
env:
15+
UV_COMPILE_BYTECODE: 1
16+
- name: Add uv to PATH
17+
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
18+
- name: Cache uv dependencies
19+
uses: actions/cache@v4
20+
with:
21+
path: .venv
22+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
23+
restore-keys: |
24+
${{ runner.os }}-uv-
25+
- name: Install dependencies
26+
run: uv sync
1227
- uses: pre-commit/[email protected]
1328
with:
1429
extra_args: '--verbose --all-files'

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
pypi_release:
8+
name: Build and Publish to PyPI
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Install uv
13+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
14+
env:
15+
UV_COMPILE_BYTECODE: 1
16+
- name: Add uv to PATH
17+
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
18+
- name: Cache uv dependencies
19+
uses: actions/cache@v4
20+
with:
21+
path: .venv
22+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
23+
restore-keys: |
24+
${{ runner.os }}-uv-
25+
- name: Install dependencies
26+
run: uv sync
27+
- name: Run tests
28+
run: uv run pytest
29+
- name: Build and publish package
30+
run: uv build && uv publish
31+
env:
32+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_KEY }}

.gitignore

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
### Python template
2+
3+
.idea
4+
.task
5+
.vscode
6+
.DS_Store
7+
.ruff_cache
8+
19
# Byte-compiled / optimized / DLL files
210
__pycache__/
11+
__marimo__/
312
*.py[cod]
413
*$py.class
514

@@ -25,6 +34,7 @@ share/python-wheels/
2534
.installed.cfg
2635
*.egg
2736
MANIFEST
37+
*/_version.py
2838

2939
# PyInstaller
3040
# Usually these files are written by a python script from a template
@@ -77,7 +87,6 @@ target/
7787

7888
# Jupyter Notebook
7989
.ipynb_checkpoints
80-
*/.ipynb_checkpoints
8190

8291
# IPython
8392
profile_default/
@@ -100,15 +109,17 @@ ipython_config.py
100109
# This is especially recommended for binary packages to ensure reproducibility, and is more
101110
# commonly ignored for libraries.
102111
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103-
poetry.lock
112+
#poetry.lock
104113

105114
# pdm
106115
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107116
#pdm.lock
108117
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109118
# in version control.
110-
# https://pdm.fming.dev/#use-with-ide
119+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111120
.pdm.toml
121+
.pdm-python
122+
.pdm-build/
112123

113124
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114125
__pypackages__/
@@ -158,8 +169,18 @@ cython_debug/
158169
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159170
# and can be added to the global gitignore or merged into this file. For a more nuclear
160171
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
161-
#.idea/
162-
163-
# Notebook results
164-
notebooks/data/
165-
notebooks/plots/
172+
.idea/
173+
174+
# LaTeX intermediate files
175+
.aux
176+
.bbl
177+
.blg
178+
.fdb_latexmk
179+
.fls
180+
.log
181+
.out
182+
.toc
183+
.synctex.gz
184+
.xdv
185+
186+
data/

.pre-commit-config.yaml

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,51 @@
1+
default_language_version:
2+
python: "3.11"
3+
14
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
5+
- repo: local
46
hooks:
5-
- id: check-toml
6-
- id: end-of-file-fixer
7-
- id: trailing-whitespace
7+
# Formatting
8+
- id: ruff-format
9+
name: ruff-format
10+
entry: uv run ruff format
11+
language: system
12+
types: [python]
13+
require_serial: true
814

9-
- repo: https://github.com/psf/black
10-
rev: 23.7.0
11-
hooks:
12-
- id: black
15+
# Security
16+
- id: check-added-large-files
17+
name: check-added-large-files
18+
entry: uv run check-added-large-files
19+
language: system
20+
- id: detect-private-key
21+
name: detect-private-key
22+
entry: uv run detect-private-key
23+
language: system
24+
types: [text]
1325

14-
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
rev: 'v0.0.286'
16-
hooks:
26+
# Linting
27+
- id: check-jsonschema
28+
name: check-jsonschema
29+
entry: uv run check-jsonschema
30+
language: system
31+
types: [json, yaml]
32+
- id: end-of-file-fixer
33+
name: end-of-file-fixer
34+
entry: uv run python -m pre_commit_hooks.end_of_file_fixer
35+
language: system
36+
- id: trailing-whitespace
37+
name: trailing-whitespace
38+
entry: uv run python -m pre_commit_hooks.trailing_whitespace_fixer
39+
language: system
1740
- id: ruff
18-
args: [ --fix, --exit-non-zero-on-fix ]
41+
name: ruff (critical subset)
42+
entry: uv run ruff check
43+
language: system
44+
types: [python]
45+
args:
46+
- --select=F,E,B,S,PERF,TRY,I,T100
47+
- --extend-ignore=TRY003
48+
- --exit-non-zero-on-fix
49+
- --force-exclude
1950

20-
- repo: https://github.com/asottile/pyupgrade
21-
rev: v3.10.1
22-
hooks:
23-
- id: pyupgrade
24-
25-
- repo: https://github.com/python-jsonschema/check-jsonschema
26-
rev: 0.26.3
27-
hooks:
28-
- id: check-dependabot
29-
args: ["--verbose"]
30-
- id: check-github-workflows
31-
args: ["--verbose"]
32-
exclude: 'notebooks/.*'
51+
exclude: 'notebooks/.*|data/.*'

ls_spa/__init__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
from .ls_spa import *
1+
"""This module efficiently computes Shapley values for least-squares problems."""
2+
3+
from .ls_spa import (
4+
ShapleyResults,
5+
SizeIncompatible,
6+
SizeIncompatibleError,
7+
error_estimates,
8+
ls_spa,
9+
merge_sample_cov,
10+
merge_sample_mean,
11+
reduce_data,
12+
square_shapley,
13+
)
14+
15+
__all__ = [
16+
"ShapleyResults",
17+
"SizeIncompatible",
18+
"SizeIncompatibleError",
19+
"error_estimates",
20+
"ls_spa",
21+
"merge_sample_cov",
22+
"merge_sample_mean",
23+
"reduce_data",
24+
"square_shapley",
25+
]

0 commit comments

Comments
 (0)