Skip to content

Commit d3a91fb

Browse files
authored
refactor: migrate poetry to uv (#131)
* chore: migrate from poetry to uv - Replace poetry with uv for package management - Use PDM build backend with dynamic versioning - Replace multiple linters with ruff - Update pre-commit hooks to use ruff - Add uv-specific entries to .gitignore - Improve project metadata and keywords * refactor: using uv * test: add unit tests for handling None parameters in various functions * feat: add configuration and pytest setup to suppress pydantic warnings * chore: update CI workflows to use uv for dependency management and caching * docs: enhance CLI reference and update project metadata in pyproject.toml and uv.lock * fix: update excludes in PDM build configuration and refine isort settings * refactor: code format and test * test: improve coverage to 100
1 parent f120368 commit d3a91fb

File tree

83 files changed

+3684
-5040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3684
-5040
lines changed

.flake8

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

.github/workflows/ci_pr.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
branches: [ main ]
66

7+
permissions: read-all
8+
79
jobs:
810
build-and-test:
911
runs-on: ${{ matrix.os }}
@@ -13,37 +15,43 @@ jobs:
1315
python-version: ["3.9", "3.10", "3.11", "3.12"]
1416

1517
steps:
16-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1719
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
1921
with:
2022
python-version: ${{ matrix.python-version }}
2123

22-
- name: Install dependencies
23-
run: |
24-
pip install "poetry~=1.6.1"
25-
poetry config installer.max-workers 1 # fix ChefBuildError
26-
poetry config virtualenvs.in-project true
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
2726

28-
- name: Cache the virtualenv
29-
uses: actions/cache@v2
27+
- name: Cache UV dependencies
28+
uses: actions/cache@v4
3029
with:
31-
path: ./.venv
32-
key: ${{ runner.os }}-${{ matrix.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
30+
path: ~/.cache/uv
31+
key: ${{ runner.os }}-${{ matrix.python-version }}-uv-${{ hashFiles('**/pyproject.toml') }}
32+
restore-keys: |
33+
${{ runner.os }}-${{ matrix.python-version }}-uv-
3334
3435
- name: Install dependencies
3536
run: |
36-
poetry install
37+
uv venv
38+
uv sync --all-extras
3739
3840
- name: Code quality
3941
run: |
40-
poetry run poe lint
42+
uv run poe lint
4143
4244
- name: Run tests
4345
run: |
44-
poetry run poe test-cov
46+
uv run poe test-cov
47+
48+
- name: Generate coverage report
49+
run: |
50+
uv run coverage xml -o coverage.xml
4551
4652
- name: Upload coverage to Codecov
47-
uses: codecov/codecov-action@v2
53+
uses: codecov/codecov-action@v4
4854
with:
4955
token: ${{ secrets.CODECOV_TOKEN }}
56+
file: ./coverage.xml
57+
fail_ci_if_error: true

.github/workflows/codecov.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [published]
66
workflow_dispatch:
77

8+
permissions: read-all
9+
810
jobs:
911
build-and-test:
1012
runs-on: ${{ matrix.os }}
@@ -14,26 +16,37 @@ jobs:
1416
python-version: ["3.9"]
1517

1618
steps:
17-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1820
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2022
with:
2123
python-version: ${{ matrix.python-version }}
2224

23-
- name: Install dependencies
24-
run: |
25-
pip install poetry
26-
poetry config virtualenvs.in-project true
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
2727

2828
- name: Install dependencies
2929
run: |
30-
poetry install
30+
uv pip install -e .
31+
uv pip install --dev
32+
33+
- name: Cache the dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cache/uv
37+
key: ${{ runner.os }}-${{ matrix.python-version }}-uv-${{ hashFiles('**/pyproject.toml') }}
3138

3239
- name: Run tests
3340
run: |
34-
poetry run poe test-cov
41+
uv run poe test-cov
42+
43+
- name: Generate coverage report
44+
run: |
45+
uv run coverage xml -o coverage.xml
3546
3647
- name: Upload coverage to Codecov
37-
uses: codecov/codecov-action@v2
48+
uses: codecov/codecov-action@v4
3849
with:
3950
token: ${{ secrets.CODECOV_TOKEN }}
51+
file: ./coverage.xml
52+
fail_ci_if_error: true

.github/workflows/publish-docs-beta.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ on:
1515
- true
1616
- false
1717

18+
permissions:
19+
contents: write
20+
1821
jobs:
1922
build:
2023
runs-on: ubuntu-latest
2124

2225
steps:
23-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2427
with:
2528
fetch-depth: 0
2629
submodules: recursive
@@ -30,15 +33,26 @@ jobs:
3033
key: ${{ github.ref }}
3134
path: .cache
3235

33-
- uses: abatilo/actions-poetry@v2
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.9'
40+
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@v3
43+
44+
- name: Cache UV dependencies
45+
uses: actions/cache@v4
3446
with:
35-
poetry-version: 1.6.1
47+
path: ~/.cache/uv
48+
key: ubuntu-3.9-uv-${{ hashFiles('**/pyproject.toml') }}
49+
restore-keys: |
50+
ubuntu-3.9-uv-
3651
3752
- name: Install dependencies
3853
run: |
39-
poetry config installer.max-workers 1
40-
poetry config virtualenvs.in-project true
41-
poetry install
54+
uv venv
55+
uv sync --all-extras
4256
4357
- name: Configure Git user
4458
run: |
@@ -48,9 +62,9 @@ jobs:
4862
- name: Publish site version (non-stable)
4963
if: ${{ inputs.delete == 'false' }}
5064
run: |
51-
poetry run mike deploy --push --update-aliases ${{ inputs.version }}
65+
uv run mike deploy --push --update-aliases ${{ inputs.version }}
5266
5367
- name: Delete site version
5468
if: ${{ inputs.delete == 'true' }}
5569
run: |
56-
poetry run mike delete --push ${{ inputs.version }}
70+
uv run mike delete --push ${{ inputs.version }}

.github/workflows/publish-docs.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ on:
77
description: Document version e.g. 1.1, 1.2
88
required: true
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
build:
1215
runs-on: ubuntu-latest
1316

1417
steps:
15-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1619
with:
1720
fetch-depth: 0
1821
submodules: recursive
@@ -22,15 +25,26 @@ jobs:
2225
key: ${{ github.ref }}
2326
path: .cache
2427

25-
- uses: abatilo/actions-poetry@v4
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.9'
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v3
35+
36+
- name: Cache UV dependencies
37+
uses: actions/cache@v4
2638
with:
27-
poetry-version: 1.7.1
39+
path: ~/.cache/uv
40+
key: ubuntu-3.9-uv-${{ hashFiles('**/pyproject.toml') }}
41+
restore-keys: |
42+
ubuntu-3.9-uv-
2843
2944
- name: Install dependencies
3045
run: |
31-
poetry config installer.max-workers 1
32-
poetry config virtualenvs.in-project true
33-
poetry install
46+
uv venv
47+
uv sync --all-extras
3448
3549
- name: Configure Git user
3650
run: |
@@ -39,4 +53,4 @@ jobs:
3953
4054
- name: Publish site
4155
run: |
42-
poetry run mike deploy --push --update-aliases ${{ inputs.version }} latest
56+
uv run mike deploy --push --update-aliases ${{ inputs.version }} latest

.github/workflows/pypi-publish.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,53 @@
11
name: Publish PYPI
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
deploy-to:
7+
type: choice
8+
description: Choose where to publish (test/prod)
9+
options:
10+
- PypiProd
11+
- PypiTest
12+
default: PypiTest
413
release:
514
types: [created]
615

16+
permissions: read-all
17+
718
jobs:
819
deploy:
9-
20+
name: PyPI - ${{ inputs.deploy-to || 'PypiProd' }}
1021
runs-on: ubuntu-latest
22+
permissions:
23+
id-token: write
1124

1225
steps:
13-
- uses: actions/checkout@v2
14-
- name: Set up Python
15-
uses: actions/setup-python@v2
16-
with:
17-
python-version: '3.x'
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install poetry
22-
- name: Build and publish
23-
run: |
24-
poetry version $(git describe --tags --abbrev=0)
25-
poetry build
26-
poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
26+
- name: Check out repository
27+
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
30+
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v3
33+
34+
- name: Cache UV dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.cache/uv
38+
key: ubuntu-publish-uv-${{ hashFiles('**/pyproject.toml') }}
39+
restore-keys: |
40+
ubuntu-publish-uv-
41+
42+
- name: Build artifacts
43+
run: uv build
44+
45+
- name: Publish artifacts to PyPI Test
46+
if: inputs.deploy-to == 'PypiTest'
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
with:
49+
repository-url: https://test.pypi.org/legacy/
50+
51+
- name: Publish artifacts to PyPI Prod
52+
if: inputs.deploy-to == 'PypiProd' || github.event_name == 'push'
53+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/samples/local
44
CHANGELOG.md
55
/dbt_packages
6+
/.claude
67

78
# Byte-compiled / optimized / DLL files
89
__pycache__/
@@ -133,3 +134,17 @@ dmypy.json
133134

134135
# Pyre type checker
135136
.pyre/
137+
138+
# uv specific
139+
.uv/
140+
.pdm-build/
141+
__pypackages__/
142+
.pdm-python
143+
.ruff_cache/
144+
requirements.txt
145+
146+
# Editor specific
147+
.vscode/
148+
.idea/
149+
*.swp
150+
*.swo

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ repos:
1111
hooks:
1212
- id: trailing-whitespace
1313
- id: end-of-file-fixer
14-
- repo: https://github.com/pycqa/flake8
15-
rev: 5.0.4
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.2.0
1616
hooks:
17-
- id: flake8
18-
args: ['--config=.flake8']
17+
- id: ruff
18+
args: [--fix]
19+
- id: ruff-format

dbterd/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""dbterd package initialization."""
2+
3+
import warnings
4+
5+
6+
# Suppress the pydantic warning from the dbt-artifacts-parser dependency
7+
warnings.filterwarnings(
8+
"ignore",
9+
message=r"Field \"model_unique_id\" in (ParsedMetric|Metric) has conflict with protected namespace \"model_\"",
10+
module="pydantic",
11+
)

dbterd/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from dbterd import main
22

3+
34
main.main()

0 commit comments

Comments
 (0)