Skip to content

Commit 903e3f9

Browse files
committed
Switch quivr to pdm dependency management
1 parent 912b9a4 commit 903e3f9

File tree

7 files changed

+83
-105
lines changed

7 files changed

+83
-105
lines changed
Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Lint Test
1+
name: Build Lint Test and Coverage
22

33
on:
44
push:
@@ -8,10 +8,9 @@ on:
88

99
jobs:
1010
build-lint-test-coverage:
11-
runs-on: ${{ matrix.os }}
11+
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest]
1514
python-version: ["3.10", "3.11"]
1615
defaults:
1716
run:
@@ -22,15 +21,41 @@ jobs:
2221
uses: actions/checkout@v3
2322
- name: Get git tags
2423
run: git fetch --prune --unshallow --tags
25-
- uses: actions/setup-python@v4
24+
- name: Setup PDM
25+
uses: pdm-project/setup-pdm@v4
2626
with:
2727
python-version: ${{ matrix.python-version }}
28-
cache: 'pip' # caching pip dependencies
29-
- name: Install hatch, the build tool
30-
run: pip install hatch
31-
- name: Build
32-
run: hatch build
28+
cache: true
29+
cache-dependency-path: ./pyproject.toml
30+
- name: Install Testing Dependencies
31+
run: |
32+
pdm install -G test
3333
- name: Lint
34-
run: hatch run dev:lint
35-
- name: Test
36-
run: hatch run test:all
34+
run: pdm run lint
35+
- name: Test with coverage
36+
run: pdm run test
37+
- name: Run benchmarks
38+
run: |
39+
pdm run benchmark --benchmark-json bench.json
40+
- name: Store main benchmark result
41+
if: github.ref == 'refs/heads/main'
42+
uses: benchmark-action/github-action-benchmark@v1
43+
with:
44+
name: Python Benchmark
45+
tool: 'pytest'
46+
output-file-path: bench.json
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
auto-push: true
49+
gh-pages-branch: gh-pages
50+
- name: Compare benchmarks
51+
if: github.event_name == 'pull_request'
52+
uses: benchmark-action/github-action-benchmark@v1
53+
with:
54+
name: Python Benchmark
55+
tool: 'pytest'
56+
output-file-path: bench.json
57+
github-token: ${{ secrets.GITHUB_TOKEN }}
58+
comment-always: true
59+
fail-threshold: '200%'
60+
alert-threshold: '150%'
61+
auto-push: false

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
dist/
22
*~
33
.mypy_cache
4-
.dir-locals.el
4+
.dir-locals.el
5+
pdm.lock
6+
.pdm-python

pyproject.toml

Lines changed: 33 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
2+
requires = ["pdm-backend"]
3+
build-backend = "pdm.backend"
44

55
[project]
66
name = "quivr"
@@ -17,7 +17,10 @@ dependencies = [
1717
"mmh3",
1818
"typing_extensions>=4.0.0"
1919
]
20-
dynamic = [ "version" ]
20+
dynamic = ["version"]
21+
22+
[project.urls]
23+
Source = "https://github.com/B612-Asteroid-Institute/quivr"
2124

2225
[project.optional-dependencies]
2326
docs = [
@@ -28,19 +31,16 @@ docs = [
2831
"furo==2023.08.17",
2932
]
3033

31-
[project.urls]
32-
Source = "https://github.com/spenczar/quivr"
33-
34-
[tool.hatch.build.targets.sdist]
35-
include = [
36-
"/quivr",
37-
]
34+
[tool.pdm.build]
35+
includes = ["quivr"]
3836

39-
[tool.hatch.version]
40-
path = "quivr/__version__.py"
37+
[tool.pdm.version]
38+
source = "scm"
39+
write_to = "quivr/__version__.py"
40+
write_template = "__version__ = '{}'"
4141

42-
[tool.hatch.envs.dev]
43-
dependencies = [
42+
[dependency-groups]
43+
dev = [
4444
"black",
4545
"isort",
4646
"mypy",
@@ -51,39 +51,7 @@ dependencies = [
5151
"ipython"
5252
]
5353

54-
[tool.hatch.envs.dev.scripts]
55-
check = [
56-
"lint",
57-
"typecheck",
58-
"test",
59-
]
60-
fix = [
61-
"ruff ./quivr ./test --fix"
62-
]
63-
lint = [
64-
"ruff check ./quivr ./test",
65-
"black --check ./quivr ./test",
66-
"isort --check-only ./quivr ./test"
67-
]
68-
format = [
69-
"black ./quivr ./test",
70-
"isort ./quivr ./test"
71-
]
72-
typecheck = [
73-
"mypy --strict ./quivr ./examples ./test/typing_tests",
74-
]
7554
test = [
76-
"pytest --benchmark-disable ./test {args}",
77-
]
78-
doctest = [
79-
"pytest --doctest-modules ./quivr {args}"
80-
]
81-
benchmark = [
82-
"pytest --benchmark-only ./test {args}"
83-
]
84-
85-
[tool.hatch.envs.test]
86-
dependencies = [
8755
"black",
8856
"isort",
8957
"mypy",
@@ -93,49 +61,27 @@ dependencies = [
9361
"ruff",
9462
]
9563

96-
[[tool.hatch.envs.test.matrix]]
97-
python = ["3.10", "3.11"]
98-
99-
[tool.hatch.envs.test.scripts]
100-
all = [
64+
[tool.pdm.scripts]
65+
check = { composite = ["lint", "typecheck", "test"] }
66+
fix = "ruff check ./quivr ./test --fix"
67+
lint = { composite = [
10168
"ruff check ./quivr ./test",
10269
"black --check ./quivr ./test",
103-
"isort --check-only ./quivr ./test",
104-
"mypy --strict ./quivr ./examples ./test/typing_tests",
105-
"pytest --benchmark-disable ./test {args}",
106-
"pytest --doctest-modules ./quivr",
107-
]
108-
109-
benchmark = [
110-
"pytest --benchmark-only ./test"
111-
]
112-
113-
[tool.hatch.envs.docs]
114-
dependencies = [
115-
"sphinx==7.2.2",
116-
"sphinx-autodoc-typehints",
117-
"sphinx-copybutton",
118-
"sphinx-toolbox",
119-
"furo==2023.08.17",
120-
]
121-
122-
[tool.hatch.envs.docs.scripts]
123-
make-html = [
124-
"make -C docs html"
125-
]
126-
127-
open-html = [
128-
"open docs/build/html/index.html"
129-
]
130-
131-
clean = [
132-
"make -C docs clean"
133-
]
134-
135-
rebuild = [
136-
"make -C docs clean",
137-
"make -C docs html"
138-
]
70+
"isort --check-only ./quivr ./test"
71+
] }
72+
format = { composite = [
73+
"black ./quivr ./test",
74+
"isort ./quivr ./test"
75+
] }
76+
typecheck = "mypy --strict ./quivr ./examples ./test/typing_tests"
77+
test = "pytest --benchmark-disable ./test {args}"
78+
doctest = "pytest --doctest-modules ./quivr {args}"
79+
benchmark = "pytest --benchmark-only ./test {args}"
80+
81+
docs-html = "make -C docs html"
82+
docs-open = "open docs/build/html/index.html"
83+
docs-clean = "make -C docs clean"
84+
docs-rebuild = { composite = ["docs-clean", "docs-html"] }
13985

14086
[tool.black]
14187
line-length = 110

quivr/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from .__version__ import __version__
1+
try:
2+
from .__version__ import __version__
3+
except ImportError:
4+
__version__ = "unknown"
5+
26
from .attributes import FloatAttribute, IntAttribute, StringAttribute
37
from .columns import (
48
BinaryColumn,

quivr/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.7.5"
1+
__version__ = "unknown"

quivr/linkage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def _concatenate_linkage_components(
448448

449449

450450
def combine_multilinkages(
451-
links: Iterable[MultiKeyLinkage[LeftTable, RightTable]]
451+
links: Iterable[MultiKeyLinkage[LeftTable, RightTable]],
452452
) -> MultiKeyLinkage[LeftTable, RightTable]:
453453
"""Combine a list of MultiKeyLinkages into a single MultiKeyLinkage.
454454

quivr/tables.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,14 @@ def from_kwargs(
274274
arrays.append(None)
275275
continue
276276

277+
assert hasattr(array, "__len__"), f"Cannot determine length of {type(array).__name__}"
277278
if size is None:
278279
size = len(array)
279280
size_col = column_name
280281
elif len(array) != size:
281282
raise errors.InvalidColumnDataError(
282283
column,
283-
f"wrong length {len(value)} (expected {size} based on column {size_col})",
284+
f"wrong length {len(array)} (expected {size} based on column {size_col})",
284285
)
285286

286287
arrays.append(array)
@@ -1036,7 +1037,7 @@ def nulls(cls, size: int, **kwargs: AttributeValueType) -> Self:
10361037
for all columns, while also setting the Table's attributes.
10371038
"""
10381039
null_array = pa.repeat(None, size)
1039-
data = [null_array for _ in range(len(cls.schema))] # type: ignore
1040+
data = [null_array for _ in range(len(cls.schema))]
10401041
null_table = pa.table(data, schema=cls.schema)
10411042
return cls.from_pyarrow(table=null_table, validate=False, permit_nulls=True, **kwargs)
10421043

0 commit comments

Comments
 (0)