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

Replace direct version string comparison with packaging.version.parse() #1863

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion magic_pdf/model/doc_analyze_by_custom_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
import paddle
paddle.disable_signal_handler()

from packaging import version
from loguru import logger

from magic_pdf.model.batch_analyze import BatchAnalyze
from magic_pdf.model.sub_modules.model_utils import get_vram

try:
import torchtext
if torchtext.__version__ >= '0.18.0':

if version.parse(torchtext.__version__) >= version.parse('0.18.0'):
torchtext.disable_torchtext_deprecation_warning()
except ImportError:
pass
Expand Down
3 changes: 2 additions & 1 deletion magic_pdf/model/pdf_extract_kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import yaml
from loguru import logger
from PIL import Image
from packaging import version

os.environ['NO_ALBUMENTATIONS_UPDATE'] = '1' # 禁止albumentations检查更新

try:
import torchtext

if torchtext.__version__ >= '0.18.0':
if version.parse(torchtext.__version__) >= version.parse('0.18.0'):
torchtext.disable_torchtext_deprecation_warning()
except ImportError:
pass
Expand Down
3 changes: 2 additions & 1 deletion magic_pdf/pdf_parse_union_core_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import statistics
import time
from typing import List
from packaging import version

import cv2
import fitz
Expand All @@ -30,7 +31,7 @@
try:
import torchtext

if torchtext.__version__ >= '0.18.0':
if version.parse(torchtext.__version__) >= version.parse('0.18.0'):
torchtext.disable_torchtext_deprecation_warning()
except ImportError:
pass
Expand Down