Skip to content
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

[build] Upgrade py 3.10 #1770

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:

requirements:
host:
- python>=3.9, <3.12
- python>=3.10, <3.12
- setuptools

run:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: ["3.9", "3.10"]
python: ["3.10", "3.11"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand All @@ -24,7 +24,7 @@ jobs:
uses: actions/setup-python@v5
with:
# MacOS issue ref.: https://github.com/actions/setup-python/issues/855 & https://github.com/actions/setup-python/issues/865
python-version: ${{ matrix.os == 'macos-latest' && '3.11' || matrix.python }}
python-version: ${{ matrix.os == 'macos-latest' && matrix.python == '3.10' && '3.11' || matrix.python }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there 3.11 written in this condition ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still the action bug with macOS for the python matrix == 3.10 uses python 3.11 to avoid the bug do you remember ? :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but why matrix.python == '3.10' && '3.11' || matrix.python ? Shouldn't matrix.os == 'macos-latest' && matrix.python == '3.10' be enough ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odulcy-mindee syntax is a bit confusing the last && defines which value to use so

matrix.os == 'macos-latest' && matrix.python == '3.10' -> if both True use 3.11 (&& '3.11') else use the matrix.python version

We could also used the version before so if macos-latest use always python 3.11 the change is a bit more explicit (but can be fully removed later on if we change to py 3.11 & py 3.12)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end with the current defined matrix.python array both commands does the same the change makes it only a bit more "fine grained" ^^

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, thanks for the clarification

architecture: x64
- if: matrix.framework == 'tensorflow'
name: Cache python modules (TF)
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.9
python-version: "3.10"
channels: pypdfium2-team,bblanchon,defaults,conda-forge
channel-priority: strict
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"
architecture: x64
- name: check status
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: docker build -t doctr-tf-py3.9-slim --build-arg SYSTEM=cpu .
run: docker build -t doctr-tf-py3.10-slim --build-arg SYSTEM=cpu .
- name: Run docker container
run: docker run doctr-tf-py3.9-slim python3 -c 'import doctr'
run: docker run doctr-tf-py3.10-slim python3 -c 'import doctr'

pytest-api:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/public_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
# Must match version at https://www.python.org/ftp/python/
python: ["3.9.18", "3.10.13", "3.11.8"]
python: ["3.10.13", "3.11.8", "3.12.7"]
framework: ["tf", "torch", "tf,viz,html,contrib", "torch,viz,html,contrib"]
system: ["cpu", "gpu"]

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -73,7 +73,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.9
python-version: "3.10"
channels: pypdfium2-team,bblanchon,defaults,conda-forge
channel-priority: strict
- name: Install dependencies
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.9
python-version: "3.10"
- name: Install package
shell: bash -el {0}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"
architecture: x64
- name: Cache python modules
uses: actions/cache@v4
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -329,7 +329,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -375,7 +375,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9", "3.10"]
python: ["3.10", "3.11"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9", "3.10"]
python: ["3.10", "3.11"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9", "3.10"]
python: ["3.10", "3.11"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -150,14 +150,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.10"]
python: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
# MacOS issue ref.: https://github.com/actions/setup-python/issues/855 & https://github.com/actions/setup-python/issues/865
python-version: ${{ matrix.os == 'macos-latest' && '3.11' || matrix.python }}
python-version: ${{ matrix.os == 'macos-latest' && matrix.python == '3.10' && '3.11' || matrix.python }}
architecture: x64
- name: Run environment collection script
run: python scripts/collect_env.py
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.9"]
python: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ The KIE predictor results per page are in a dictionary format with each key repr

### Prerequisites

Python 3.9 (or higher) and [pip](https://pip.pypa.io/en/stable/) are required to install docTR.
Python 3.10 (or higher) and [pip](https://pip.pypa.io/en/stable/) are required to install docTR.

### Latest release

Expand Down
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["Mindee <[email protected]>"]
license = "Apache-2.0"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
python = ">=3.10,<3.13"
python-doctr = {git = "https://github.com/mindee/doctr.git", extras = ['tf'], branch = "main" }
# Fastapi: minimum version required to avoid pydantic error
# cf. https://github.com/tiangolo/fastapi/issues/4168
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
************

This library requires `Python <https://www.python.org/downloads/>`_ 3.9 or higher.
This library requires `Python <https://www.python.org/downloads/>`_ 3.10 or higher.


Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions doctr/models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def estimate_orientation(
gray_img = cv2.medianBlur(gray_img, 5)
thresh = cv2.threshold(gray_img, thresh=0, maxval=255, type=cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
else:
thresh = img.astype(np.uint8) # type: ignore[assignment]
thresh = img.astype(np.uint8)

page_orientation, orientation_confidence = general_page_orientation or (None, 0.0)
if page_orientation and orientation_confidence >= min_confidence:
# We rotate the image to the general orientation which improves the detection
# No expand needed bitmap is already padded
thresh = rotate_image(thresh, -page_orientation) # type: ignore
thresh = rotate_image(thresh, -page_orientation)
else: # That's only required if we do not work on the detection models bin map
# try to merge words in lines
(h, w) = img.shape[:2]
Expand Down
2 changes: 1 addition & 1 deletion doctr/models/detection/differentiable_binarization/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def bitmap_to_boxes(
contours, _ = cv2.findContours(bitmap.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
# Check whether smallest enclosing bounding box is not too small
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < min_size_box): # type: ignore[index]
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < min_size_box):
continue
# Compute objectness
if self.assume_straight_pages:
Expand Down
2 changes: 1 addition & 1 deletion doctr/models/detection/fast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def bitmap_to_boxes(
contours, _ = cv2.findContours(bitmap.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
# Check whether smallest enclosing bounding box is not too small
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < 2): # type: ignore[index]
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < 2):
continue
# Compute objectness
if self.assume_straight_pages:
Expand Down
2 changes: 1 addition & 1 deletion doctr/models/detection/linknet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def bitmap_to_boxes(
contours, _ = cv2.findContours(bitmap.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
# Check whether smallest enclosing bounding box is not too small
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < 2): # type: ignore[index]
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < 2):
continue
# Compute objectness
if self.assume_straight_pages:
Expand Down
Loading
Loading