-
Notifications
You must be signed in to change notification settings - Fork 7
✨ ⬆️ add support for mindee-lite and bump dependencies
#419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5085b61
temp
sebastianMindee 3e1f7bc
add all code safeguards
sebastianMindee d202821
add the ones I obviously forgot
sebastianMindee 91cb6e1
fix test logic
sebastianMindee a4c138f
apply some markers + delete regression testing
sebastianMindee 2c78566
add dependency test and tweak pre-commit config
sebastianMindee 7e24520
fix wf?
sebastianMindee fe6e426
fix workflow lint
sebastianMindee 80c6d93
fix python install pattern or whatever
sebastianMindee 1884e84
fix unit test
sebastianMindee f397846
restore regression tests
sebastianMindee fa934d8
fix wf file
sebastianMindee 43fcbcb
fix tests
sebastianMindee c352a7f
tweak mindee-lite testing
sebastianMindee 8cd4e4c
fix tests
sebastianMindee 80eddc7
add mindee-lite integration tests
sebastianMindee fd3ad41
fix again
sebastianMindee 7b3ea83
fix... again
sebastianMindee 5848eff
fix tests, again
sebastianMindee 64ea866
fix mv file not overwriting
sebastianMindee be6abfe
force bash
sebastianMindee cc70723
fix lite integration tests
sebastianMindee b654417
fix crop threshold
sebastianMindee 6111f93
add proper publish action
sebastianMindee 63c0cfb
fix perms
sebastianMindee 42b83d2
fix invalid logic
sebastianMindee 3706c1e
restore safeguard
sebastianMindee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 warningCode 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}
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`." | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.""" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.