Skip to content

Commit 63b94ac

Browse files
authored
feat: enable Python 3.13, update deps, switch to uv, add codecov (#14)
* feat: enable Python 3.13, update deps, switch to uv, add codecov Signed-off-by: Panos Vagenas <[email protected]> * update repo links to new org Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Panos Vagenas <[email protected]>
1 parent aa50365 commit 63b94ac

File tree

21 files changed

+5154
-5270
lines changed

21 files changed

+5154
-5270
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/data/** linguist-vendored

.github/actions/setup-poetry/action.yml

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

.github/codecov.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
codecov:
2+
# https://docs.codecov.io/docs/comparing-commits
3+
allow_coverage_offsets: true
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
informational: true
9+
target: auto # auto compares coverage to the previous base commit
10+
flags:
11+
- docling
12+
comment:
13+
layout: "reach, diff, flags, files"
14+
behavior: default
15+
require_changes: false # if true: only post the comment if coverage changes
16+
branches: # branch names that can post comment
17+
- "main"

.github/scripts/release.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ fi
1010
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
1111

1212
# update package version
13-
poetry version "${TARGET_VERSION}"
13+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "${TARGET_VERSION}"
14+
uv lock --upgrade-package docling-core
1415

1516
# collect release notes
1617
REL_NOTES=$(mktemp)
17-
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"
18+
uv run --no-sync semantic-release changelog --unreleased >> "${REL_NOTES}"
1819

1920
# update changelog
2021
TMP_CHGLOG=$(mktemp)
@@ -30,7 +31,7 @@ mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
3031
# push changes
3132
git config --global user.name 'github-actions[bot]'
3233
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33-
git add pyproject.toml "${CHGLOG_FILE}"
34+
git add pyproject.toml uv.lock "${CHGLOG_FILE}"
3435
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
3536
git commit -m "${COMMIT_MSG}"
3637
git push origin main

.github/workflows/cd.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@ env:
88
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
99

1010
jobs:
11-
# To be enabled when we add docs
12-
# docs:
13-
# permissions:
14-
# contents: write
15-
# runs-on: ubuntu-latest
16-
# steps:
17-
# - uses: actions/checkout@v4
18-
# - uses: ./.github/actions/setup-poetry
19-
# - name: Build and push docs
20-
# run: poetry run mkdocs gh-deploy --force
21-
2211
code-checks:
2312
uses: ./.github/workflows/checks.yml
13+
with:
14+
push_coverage: false
2415
pre-release-check:
2516
runs-on: ubuntu-latest
2617
outputs:
@@ -29,15 +20,20 @@ jobs:
2920
- uses: actions/checkout@v4
3021
with:
3122
fetch-depth: 0 # for fetching tags, required for semantic-release
32-
- uses: ./.github/actions/setup-poetry
23+
- name: Install uv and set the python version
24+
uses: astral-sh/setup-uv@v5
25+
with:
26+
enable-cache: true
27+
- name: Install dependencies
28+
run: uv sync --only-dev
3329
- name: Check version of potential release
3430
id: version_check
3531
run: |
36-
TRGT_VERSION=$(poetry run semantic-release print-version)
37-
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
38-
echo "${TRGT_VERSION}"
32+
TRGT_VERSION=$(uv run --no-sync semantic-release print-version)
33+
echo "TRGT_VERSION=${TRGT_VERSION}" >> "$GITHUB_OUTPUT"
34+
echo "${TRGT_VERSION}"
3935
- name: Check notes of potential release
40-
run: poetry run semantic-release changelog --unreleased
36+
run: uv run --no-sync semantic-release changelog --unreleased
4137
release:
4238
needs: [code-checks, pre-release-check]
4339
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
@@ -54,7 +50,12 @@ jobs:
5450
with:
5551
token: ${{ steps.app-token.outputs.token }}
5652
fetch-depth: 0 # for fetching tags, required for semantic-release
57-
- uses: ./.github/actions/setup-poetry
53+
- name: Install uv and set the python version
54+
uses: astral-sh/setup-uv@v5
55+
with:
56+
enable-cache: true
57+
- name: Install dependencies
58+
run: uv sync --only-dev
5859
- name: Run release script
5960
env:
6061
GH_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/checks.yml

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
on:
22
workflow_call:
3+
inputs:
4+
push_coverage:
5+
type: boolean
6+
description: "If true, the coverage results are pushed to codecov.io."
7+
default: true
8+
secrets:
9+
CODECOV_TOKEN:
10+
required: false
311

412
jobs:
513
run-checks:
@@ -9,8 +17,71 @@ jobs:
917
python-version: ['3.9', '3.10', '3.11', '3.12']
1018
steps:
1119
- uses: actions/checkout@v4
12-
- uses: ./.github/actions/setup-poetry
20+
- name: Install uv and set the python version
21+
uses: astral-sh/setup-uv@v5
1322
with:
1423
python-version: ${{ matrix.python-version }}
15-
- name: Run styling check
16-
run: poetry run pre-commit run --all-files
24+
enable-cache: true
25+
- name: pre-commit cache key
26+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
27+
- uses: actions/cache@v4
28+
with:
29+
path: ~/.cache/pre-commit
30+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
31+
- name: Install dependencies
32+
run: uv sync --frozen --all-extras
33+
- name: Check style and run tests
34+
run: pre-commit run --all-files
35+
- name: Upload coverage to Codecov
36+
if: inputs.push_coverage
37+
uses: codecov/codecov-action@v5
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
files: ./coverage.xml
41+
42+
build-package:
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
python-version: ['3.12']
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Install uv and set the python version
50+
uses: astral-sh/setup-uv@v5
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
enable-cache: true
54+
- name: Install dependencies
55+
run: uv sync --all-extras
56+
- name: Build package
57+
run: uv build
58+
- name: Check content of wheel
59+
run: unzip -l dist/*.whl
60+
- name: Store the distribution packages
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: python-package-distributions
64+
path: dist/
65+
66+
test-package:
67+
needs:
68+
- build-package
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
python-version: ['3.12']
73+
steps:
74+
- name: Download all the dists
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: python-package-distributions
78+
path: dist/
79+
- name: Install uv and set the python version
80+
uses: astral-sh/setup-uv@v5
81+
with:
82+
python-version: ${{ matrix.python-version }}
83+
enable-cache: true
84+
- name: Install package
85+
run: uv pip install dist/*.whl
86+
- name: Check accessing the DoclingLoader class
87+
run: python -c 'from langchain_docling import DoclingLoader'

.github/workflows/ci.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,9 @@ on:
88
- "**"
99
- "!gh-pages"
1010

11-
env:
12-
# disable keyring (https://github.com/actions/runner-images/issues/6185):
13-
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
14-
1511
jobs:
1612
code-checks:
17-
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name != 'DS4SD/docling-langchain' && github.event.pull_request.head.repo.full_name != 'ds4sd/docling-langchain') }}
13+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'docling-project/docling-langchain' }}
1814
uses: ./.github/workflows/checks.yml
19-
20-
# To enable when we add the ./docs
21-
# build-docs:
22-
# runs-on: ubuntu-latest
23-
# steps:
24-
# - uses: actions/checkout@v4
25-
# - uses: ./.github/actions/setup-poetry
26-
# - name: Build docs
27-
# run: poetry run mkdocs build --verbose --clean
15+
secrets:
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pypi.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,29 @@ on:
77
permissions:
88
contents: read
99

10-
env:
11-
# disable keyring (https://github.com/actions/runner-images/issues/6185):
12-
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
13-
1410
jobs:
1511
build-and-publish:
1612
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.12']
16+
environment:
17+
name: pypi
18+
url: https://pypi.org/p/langchain-docling
19+
permissions:
20+
id-token: write # IMPORTANT: mandatory for trusted publishing
1721
steps:
1822
- uses: actions/checkout@v4
19-
- uses: ./.github/actions/setup-poetry
20-
- name: Build and publish
21-
run: poetry publish --build --no-interaction --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
23+
- name: Install uv and set the python version
24+
uses: astral-sh/setup-uv@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
enable-cache: true
28+
- name: Install dependencies
29+
run: uv sync --all-extras
30+
- name: Build package
31+
run: uv build
32+
- name: Publish distribution 📦 to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
attestations: true

.pre-commit-config.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,53 @@ repos:
44
hooks:
55
- id: black
66
name: Black
7-
entry: poetry run black langchain_docling test
7+
entry: uv run --no-sync black langchain_docling test
88
pass_filenames: false
99
language: system
1010
files: '\.py$'
1111
- id: isort
1212
name: isort
13-
entry: poetry run isort langchain_docling test
13+
entry: uv run --no-sync isort langchain_docling test
1414
pass_filenames: false
1515
language: system
1616
files: '\.py$'
1717
- id: autoflake
1818
name: autoflake
19-
entry: poetry run autoflake langchain_docling test
19+
entry: uv run --no-sync autoflake langchain_docling test
2020
pass_filenames: false
2121
language: system
2222
files: '\.py$'
2323
- id: mypy
2424
name: MyPy
25-
entry: poetry run mypy langchain_docling test
25+
entry: uv run --no-sync mypy langchain_docling test
2626
pass_filenames: false
2727
language: system
2828
files: '\.py$'
2929
- id: flake8
3030
name: Flake8
31-
entry: poetry run flake8 langchain_docling
31+
entry: uv run --no-sync flake8 langchain_docling
3232
pass_filenames: false
3333
language: system
3434
files: '\.py$'
3535
- id: pytest
3636
name: Pytest
37-
entry: poetry run pytest test/
37+
entry: uv run --no-sync pytest --cov=langchain_docling --cov-report=xml test
3838
pass_filenames: false
3939
language: system
4040
files: '\.py$'
4141
- id: nbqa_black
4242
name: nbQA Black
43-
entry: poetry run nbqa black examples/
43+
entry: uv run --no-sync nbqa black examples/
4444
pass_filenames: false
4545
language: system
4646
files: '\.ipynb$'
4747
- id: nbqa_isort
4848
name: nbQA isort
49-
entry: poetry run nbqa isort examples/
49+
entry: uv run --no-sync nbqa isort examples/
5050
pass_filenames: false
5151
language: system
5252
files: '\.ipynb$'
53-
- id: poetry
54-
name: Poetry
55-
entry: poetry check --lock
56-
pass_filenames: false
57-
language: system
53+
- repo: https://github.com/astral-sh/uv-pre-commit
54+
rev: 0.7.8
55+
hooks:
56+
- id: uv-lock

0 commit comments

Comments
 (0)