Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5085b61
temp
sebastianMindee Jun 9, 2026
3e1f7bc
add all code safeguards
sebastianMindee Jun 10, 2026
d202821
add the ones I obviously forgot
sebastianMindee Jun 10, 2026
91cb6e1
fix test logic
sebastianMindee Jun 10, 2026
a4c138f
apply some markers + delete regression testing
sebastianMindee Jun 10, 2026
2c78566
add dependency test and tweak pre-commit config
sebastianMindee Jun 10, 2026
7e24520
fix wf?
sebastianMindee Jun 10, 2026
fe6e426
fix workflow lint
sebastianMindee Jun 10, 2026
80c6d93
fix python install pattern or whatever
sebastianMindee Jun 10, 2026
1884e84
fix unit test
sebastianMindee Jun 10, 2026
f397846
restore regression tests
sebastianMindee Jun 10, 2026
fa934d8
fix wf file
sebastianMindee Jun 10, 2026
43fcbcb
fix tests
sebastianMindee Jun 10, 2026
c352a7f
tweak mindee-lite testing
sebastianMindee Jun 10, 2026
8cd4e4c
fix tests
sebastianMindee Jun 10, 2026
80eddc7
add mindee-lite integration tests
sebastianMindee Jun 10, 2026
fd3ad41
fix again
sebastianMindee Jun 10, 2026
7b3ea83
fix... again
sebastianMindee Jun 10, 2026
5848eff
fix tests, again
sebastianMindee Jun 10, 2026
64ea866
fix mv file not overwriting
sebastianMindee Jun 10, 2026
be6abfe
force bash
sebastianMindee Jun 10, 2026
cc70723
fix lite integration tests
sebastianMindee Jun 10, 2026
b654417
fix crop threshold
sebastianMindee Jun 10, 2026
6111f93
add proper publish action
sebastianMindee Jun 10, 2026
63c0cfb
fix perms
sebastianMindee Jun 11, 2026
42b83d2
fix invalid logic
sebastianMindee Jun 11, 2026
3706c1e
restore safeguard
sebastianMindee Jun 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/_publish-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
- "3.14"
runs-on: "ubuntu-22.04"
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- "3.14"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
pytest --cov mindee -m integration

- name: Notify Slack Action on Failure
uses: ravsamhq/notify-slack-action@2.3.0
uses: ravsamhq/notify-slack-action@2.5.0
if: ${{ always() && github.ref_name == 'main' }}
with:
status: ${{ job.status }}
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/_test-regressions.yml

This file was deleted.

50 changes: 46 additions & 4 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
- "3.14"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -46,7 +46,49 @@ jobs:
pip install -e .[test]

- name: Unit testing with pytest
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
pytest --cov mindee --cov-fail-under 87

pytest-lite:
name: Run Unit Tests (Lite)
timeout-minutes: 30
strategy:
matrix:
os:
- "ubuntu-22.04"
- "windows-2022"
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-test-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-test-

- name: Install dependencies
run: |
python -m pip install pip
pip install -e .[test]
pip uninstall -y pypdfium2 pillow

- name: Unit testing with pytest
run: |
pytest -m lite

18 changes: 18 additions & 0 deletions .github/workflows/_workflow_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint workflows

on:
pull_request:
paths:
- '.github/workflows/**'
push:
branches: [main]

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run actionlint
uses: docker://rhysd/actionlint:latest
with:
args: -color

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
3 changes: 0 additions & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
- cron: '32 0 * * *'

jobs:
test-regressions:
uses: mindee/mindee-api-python/.github/workflows/_test-regressions.yml@main
secrets: inherit
test-code-samples:
uses: mindee/mindee-api-python/.github/workflows/_smoke-test.yml@main
secrets: inherit
7 changes: 3 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ permissions:
pull-requests: read

jobs:
workflow-lint:
uses: ./.github/workflows/_workflow_lint.yml
static-analysis:
uses: ./.github/workflows/_static-analysis.yml
needs: workflow-lint
test-units:
uses: ./.github/workflows/_test-units.yml
needs: static-analysis
secrets: inherit
test-regressions:
uses: ./.github/workflows/_test-regressions.yml
needs: test-units
secrets: inherit
test-integrations:
uses: ./.github/workflows/_test-integrations.yml
needs: test-units
Expand Down
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.14.9
rev: v0.15.16
hooks:
- id: ruff-check
args: [ --fix, --exit-non-zero-on-fix]
Expand All @@ -27,9 +27,10 @@ repos:
hooks:
- id: pip-audit
args: ["."]
stages: [pre-push]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
rev: v2.1.0
hooks:
- id: mypy
args: []
Expand All @@ -39,6 +40,7 @@ repos:
- types-setuptools
- importlib-metadata
- types-Pillow
- types-toml
- repo: local
hooks:
- id: sphinx-html
Expand All @@ -47,10 +49,12 @@ repos:
language: system
pass_filenames: false
files: ^docs/.*$|^mindee/.*\.py$
stages: [pre-push]

- id: sphinx-linkcheck
name: Sphinx Linkcheck
entry: make -C docs linkcheck
language: system
pass_filenames: false
files: ^docs/.*$|^mindee/.*\.py$
stages: [pre-push]
9 changes: 9 additions & 0 deletions mindee/dependencies/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from mindee.dependencies.checkers import PILLOW_AVAILABLE, PYPDFIUM2_AVAILABLE
from mindee.dependencies.decorators import requires_pillow, requires_pypdfium2

__all__ = [
"PILLOW_AVAILABLE",
"PYPDFIUM2_AVAILABLE",
"requires_pillow",
"requires_pypdfium2",
]
33 changes: 33 additions & 0 deletions mindee/dependencies/checkers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from mindee.error.mindee_dependency_error import MindeeDependencyError

try:
import PIL # noqa: F401 #pylint: disable=unused-import

PILLOW_AVAILABLE = True
except ImportError:
PILLOW_AVAILABLE = False

try:
import pypdfium2 # noqa: F401 #pylint: disable=unused-import

PYPDFIUM2_AVAILABLE = True
except ImportError:
PYPDFIUM2_AVAILABLE = False


def require_pillow() -> None:
"""Raises a clear error if Pillow is not installed."""
if not PILLOW_AVAILABLE:
raise MindeeDependencyError(
"This feature requires the 'Pillow' library. "
"Install it directly or run `pip install mindee` instead of `mindee-lite`."
)


def require_pypdfium2() -> None:
"""Raises a clear error if PyPDFium2 is not installed."""
if not PYPDFIUM2_AVAILABLE:
raise MindeeDependencyError(
"This feature requires the 'PyPDFium2' library. "
"Install it directly or run `pip install mindee` instead of `mindee-lite`."
)
30 changes: 30 additions & 0 deletions mindee/dependencies/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import functools
from collections.abc import Callable
from typing import ParamSpec, TypeVar

from mindee.dependencies.checkers import require_pillow, require_pypdfium2

P = ParamSpec("P")
R = TypeVar("R")


def requires_pillow(func: Callable[P, R]) -> Callable[P, R]:
"""Decorator to enforce Pillow availability on a function/method."""

@functools.wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
require_pillow()
return func(*args, **kwargs)

return wrapper


def requires_pypdfium2(func: Callable[P, R]) -> Callable[P, R]:
"""Decorator to enforce PyPDFium2 availability on a function/method."""

@functools.wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
require_pypdfium2()
return func(*args, **kwargs)

return wrapper
5 changes: 5 additions & 0 deletions mindee/error/mindee_dependency_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from mindee.error import MindeeError


class MindeeDependencyError(MindeeError, ImportError):
"""An exception relating to missing dependencies."""
Loading
Loading