Skip to content

Conversation

@MehmedGIT
Copy link
Contributor

@MehmedGIT MehmedGIT commented Dec 22, 2025

Version update for beanie to work with pydantic v2 for local installations. I forgot to add that to #1348. Not sure how the ocrd_network pipeline tests have passed with beanie<=2.0 and pydantic >=2.0. Should fail with:

(venv_operandi) mm@mm-Precision-5560:~/Repos/operandi$ ocrd --version
Traceback (most recent call last):
  File "/home/mm/venv_operandi/bin/ocrd", line 3, in <module>
    from ocrd.cli import cli
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd/cli/__init__.py", line 31, in <module>
    from ..decorators import ocrd_loglevel
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd/decorators/__init__.py", line 22, in <module>
    from .ocrd_cli_options import ocrd_cli_options
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd/decorators/ocrd_cli_options.py", line 6, in <module>
    from ocrd_network import (
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd_network/__init__.py", line 3, in <module>
    from .processing_server import ProcessingServer
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd_network/processing_server.py", line 14, in <module>
    from .database import (
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/ocrd_network/database.py", line 15, in <module>
    from beanie import init_beanie
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/beanie/__init__.py", line 1, in <module>
    from beanie.migrations.controllers.free_fall import free_fall_migration
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/beanie/migrations/controllers/free_fall.py", line 4, in <module>
    from beanie.odm.documents import Document
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/beanie/odm/documents.py", line 50, in <module>
    from beanie.odm.fields import (
  File "/home/mm/venv_operandi/lib/python3.12/site-packages/beanie/odm/fields.py", line 8, in <module>
    from pydantic.fields import ModelField
ImportError: cannot import name 'ModelField' from 'pydantic.fields' (/home/mm/venv_operandi/lib/python3.12/site-packages/pydantic/fields.py)

This PR is also important to fix dependency issues in Operandi caused by version mismatches of Beanie between core 3.9.1 and operandi_utils.

@MehmedGIT
Copy link
Contributor Author

MehmedGIT commented Dec 22, 2025

Beanie 1.29.0 is the latest version available for Python 3.8, hence, the failing tests...

@MehmedGIT MehmedGIT requested a review from kba December 22, 2025 14:57
@MehmedGIT
Copy link
Contributor Author

MehmedGIT commented Dec 22, 2025

Another note on Beanie, currently the dependencies are as follows:
Beanie (async ODM) -> Motor -> PyMongo -> MongoDB

Motor, the async MongoDB driver, is slated for deprecation around May 2026. Beanie v2+ already has native PyMongo async support and the motor dependency could be dropped.

Beanie -> Async PyMongo -> MongoDB

@MehmedGIT MehmedGIT changed the title update: beanie version update: beanie version, drop motor dependency Dec 22, 2025
Copy link
Member

@kba kba left a comment

Choose a reason for hiding this comment

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

LGTM.

Let's track that upcoming removal in a separate issue.

I don't understand why the tests fail, beanie v2.0.1 should be available for >= 3.9 but

` ERROR: Could not find a version that satisfies the requirement beanie>=2.0.1 (from ocrd) (from versions: 0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.4.0b1, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 1.0.0b1, 1.0.0b2, 1.0.0b3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.2.8, 1.3.0, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.12, 1.8.13, 1.9.0, 1.9.1, 1.9.2, 1.10.0, 1.10.1, 1.10.2, 1.10.3, 1.10.4, 1.10.5, 1.10.6, 1.10.7, 1.10.8, 1.10.9, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.11.4, 1.11.5, 1.11.6, 1.11.7, 1.11.8, 1.11.9, 1.11.10, 1.11.11, 1.11.12, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.14.0, 1.14.1, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 1.16.0b0, 1.16.0b1, 1.16.0b2, 1.16.0b3, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.16.7, 1.16.8, 1.17.0, 1.18.0b0, 1.18.0b1, 1.18.0, 1.18.1, 1.19.0, 1.19.1, 1.19.2, 1.20.0b0, 1.20.0b1, 1.20.0, 1.21.0b0, 1.21.0b1, 1.21.0, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.22.5, 1.22.6, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.23.6, 1.24.0, 1.25.0, 1.26.0, 1.27.0, 1.28.0, 1.29.0) `

.

It is not for 3.8 though, understandably but unfortunately, that's the failing test.

@kba
Copy link
Member

kba commented Jan 6, 2026

We're only keeping support for end-of-life 3.8 because of processors that cannot be readily updated to 3.9 because they require tensorflow 1.*. However, as of now, this only pertains to two projects now (https://github.com/OCR-D/ocrd_keraslm/ and https://github.com/ASVLeipzig/cor-asv-ann/) and the maintainer will find a way to update those ASAP (🙏 @bertsky).

Since there are no fat containers in ocrd_all anymore that required a least common python version 3.8, I will release this now as-is so everything except those two projects is properly working again.

@kba kba merged commit a890d20 into master Jan 6, 2026
13 of 17 checks passed
@kba kba deleted the update_beanie_version branch January 6, 2026 16:34
@bertsky
Copy link
Collaborator

bertsky commented Jan 6, 2026

Since there are no fat containers in ocrd_all anymore that required a least common python version 3.8, I will release this now as-is so everything except those two projects is properly working again.

Not yet: ocrd_all:master is still a fat container, and its :maximum images only build if the TF1 components can be installed. But as long as we don't make new ocrd/all releases in that paradigm, we should be fine. And of course, OCR-D/ocrd_all#468 (bringing mutual independence of modules) is coming...

BTW, @kba, looking at the CD failures here, I believe you now need to modify the base image from ubuntu:20.04 to at least 22.04 to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants