Skip to content

Commit 16eb837

Browse files
authored
chore: run tests with uv (#106)
switches to using uv lockfile to run tests to make ci environment more reproducible.
1 parent a631919 commit 16eb837

File tree

5 files changed

+211
-204
lines changed

5 files changed

+211
-204
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ jobs:
2222
uses: actions/checkout@v5
2323
with:
2424
submodules: recursive
25-
- name: Set up Python
26-
uses: actions/setup-python@v6
25+
- name: Install uv with python
26+
uses: astral-sh/setup-uv@v7
2727
with:
2828
python-version: ${{ matrix.python }}
2929
- name: Install package and test dependencies
3030
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install ".[test]"
31+
uv sync --frozen --extra test
3332
- name: Run tests
3433
run: |
35-
python -m pytest tests
34+
uv run pytest

CONTRIBUTING.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ git clone --recursive https://github.com/<your-fork>/substrait-python.git
66
cd substrait-python
77
```
88

9-
## Conda env
10-
Create a conda environment with developer dependencies.
9+
## Development environment
10+
Activate environment with uv.
1111
```
12-
conda env create -f environment.yml
13-
conda activate substrait-python-env
12+
uv sync --extra test
1413
```
1514

1615
## Update the substrait submodule locally
@@ -21,43 +20,45 @@ git submodule update --init --recursive
2120
```
2221

2322

24-
# Upgrade the substrait protocol definition
23+
# Code generation
2524

26-
## a) Use the upgrade script
25+
## Protobuf stubs
2726

2827
Run the upgrade script to upgrade the submodule and regenerate the protobuf stubs.
2928

3029
```
31-
./update_proto.sh <version>
30+
uv sync --extra gen_proto
31+
uv run ./update_proto.sh <version>
3232
```
3333

34-
## b) Manual upgrade
34+
## Antlr grammar
3535

36-
### Upgrade the Substrait submodule
36+
Substrait uses antlr grammar to derive output types of extension functions. Make sure java is installed and ANTLR_JAR environment variable is set. Take a look at .devcontainer/Dockerfile for example setup.
3737

3838
```
39-
cd third_party/substrait
40-
git checkout <version>
41-
cd -
42-
git commit . -m "Use submodule <version>"
39+
make antlr
4340
```
4441

45-
### Generate protocol buffers
46-
Generate the protobuf files manually. Requires protobuf `v3.20.1`.
42+
## Extensions stubs
43+
44+
Substrait uses jsonschema to describe the data model for extension files.
45+
4746
```
48-
./gen_proto.sh
47+
make codegen-extensions
4948
```
5049

50+
# Lint & Format
51+
52+
Run the following make commands to lint and format with ruff.
5153

52-
# Build
53-
## Python package
54-
Editable installation.
5554
```
56-
pip install -e .
55+
make lint
56+
make format
5757
```
5858

5959
# Test
6060
Run tests in the project's root dir.
6161
```
62-
pytest
62+
uv sync --extra test
63+
uv run pytest
6364
```

environment.yml

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

tests/builders/plan/test_read.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from substrait.builders.plan import read_named_table
66
import pytest
77
from substrait.gen.proto.extensions.extensions_pb2 import AdvancedExtension
8-
from google.protobuf import any
8+
from google.protobuf import any_pb2
99
from google.protobuf.wrappers_pb2 import StringValue
1010

1111
struct = stt.Type.Struct(
@@ -80,7 +80,10 @@ def test_read_rel_schema_nullable():
8080

8181

8282
def test_read_rel_ae():
83-
extension = AdvancedExtension(optimization=[any.pack(StringValue(value="Opt1"))])
83+
any = any_pb2.Any()
84+
any.Pack(StringValue(value="Opt1"))
85+
86+
extension = AdvancedExtension(optimization=[any])
8487

8588
actual = read_named_table(["example_db", "example_table"], named_struct, extension)(
8689
None

0 commit comments

Comments
 (0)