From 6a3b162ca3c699ba78a5e6305157808786b3b9bb Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sat, 28 Sep 2024 12:28:45 +0200 Subject: [PATCH 1/5] up --- src/mistral_common/tokens/tokenizers/multimodal.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mistral_common/tokens/tokenizers/multimodal.py b/src/mistral_common/tokens/tokenizers/multimodal.py index 153aadd..cd118b2 100644 --- a/src/mistral_common/tokens/tokenizers/multimodal.py +++ b/src/mistral_common/tokens/tokenizers/multimodal.py @@ -1,4 +1,5 @@ import base64 +import logging from dataclasses import dataclass from io import BytesIO from typing import Tuple, Union @@ -14,6 +15,9 @@ SpecialImageIDs, ) +logger = logging.getLogger(__name__) + + _cv2_installed: bool try: import cv2 @@ -21,6 +25,14 @@ _cv2_installed = True except ImportError: _cv2_installed = False +except Exception: + # cv2 has lots of import problems: https://github.com/opencv/opencv-python/issues/884 + # for better UX, let's simple skip import errors for now + logger.warn( + "You seem to have a broken installation of opencv. " + "Please follow : https://github.com/opencv/opencv-python/issues/884 to correct your environment." + " Skipped cv2 import." + ) def is_cv2_installed() -> bool: From 8970dcc5ed72111df7ea90ae0f4806ce43e6cf7d Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sat, 28 Sep 2024 12:32:46 +0200 Subject: [PATCH 2/5] up --- src/mistral_common/tokens/tokenizers/multimodal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mistral_common/tokens/tokenizers/multimodal.py b/src/mistral_common/tokens/tokenizers/multimodal.py index cd118b2..d91d30d 100644 --- a/src/mistral_common/tokens/tokenizers/multimodal.py +++ b/src/mistral_common/tokens/tokenizers/multimodal.py @@ -29,9 +29,9 @@ # cv2 has lots of import problems: https://github.com/opencv/opencv-python/issues/884 # for better UX, let's simple skip import errors for now logger.warn( - "You seem to have a broken installation of opencv. " - "Please follow : https://github.com/opencv/opencv-python/issues/884 to correct your environment." - " Skipped cv2 import." + "Warning: Your installation of OpenCV appears to be broken. " + "Please follow the instructions at https://github.com/opencv/opencv-python/issues/884 " + "to correct your environment. The import of cv2 has been skipped." ) From 1a7c9cf6b44b7f9a6d2c1a8d1a854104dd033b4a Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sun, 29 Sep 2024 14:32:39 +0200 Subject: [PATCH 3/5] Up --- src/mistral_common/tokens/tokenizers/multimodal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mistral_common/tokens/tokenizers/multimodal.py b/src/mistral_common/tokens/tokenizers/multimodal.py index d91d30d..b44b881 100644 --- a/src/mistral_common/tokens/tokenizers/multimodal.py +++ b/src/mistral_common/tokens/tokenizers/multimodal.py @@ -25,11 +25,11 @@ _cv2_installed = True except ImportError: _cv2_installed = False -except Exception: +except Exception as e: # cv2 has lots of import problems: https://github.com/opencv/opencv-python/issues/884 # for better UX, let's simple skip import errors for now - logger.warn( - "Warning: Your installation of OpenCV appears to be broken. " + logger.warning( + f"Warning: Your installation of OpenCV appears to be broken: {e}." "Please follow the instructions at https://github.com/opencv/opencv-python/issues/884 " "to correct your environment. The import of cv2 has been skipped." ) From 38c387ba32bac51df940dcf67a8db2b9afb2c82a Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sun, 29 Sep 2024 14:34:00 +0200 Subject: [PATCH 4/5] Update src/mistral_common/tokens/tokenizers/multimodal.py --- src/mistral_common/tokens/tokenizers/multimodal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mistral_common/tokens/tokenizers/multimodal.py b/src/mistral_common/tokens/tokenizers/multimodal.py index b44b881..0498213 100644 --- a/src/mistral_common/tokens/tokenizers/multimodal.py +++ b/src/mistral_common/tokens/tokenizers/multimodal.py @@ -27,7 +27,7 @@ _cv2_installed = False except Exception as e: # cv2 has lots of import problems: https://github.com/opencv/opencv-python/issues/884 - # for better UX, let's simple skip import errors for now + # for better UX, let's simply skip all errors that might arise from import for now logger.warning( f"Warning: Your installation of OpenCV appears to be broken: {e}." "Please follow the instructions at https://github.com/opencv/opencv-python/issues/884 " From f66340b6b6c7c0a6dc953d509c7588323d076bf9 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sun, 29 Sep 2024 14:34:51 +0200 Subject: [PATCH 5/5] update version --- pyproject.toml | 2 +- src/mistral_common/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1be08ac..46da2e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mistral_common" -version = "1.4.3" +version = "1.4.4" description = "" authors = ["bam4d "] readme = "README.md" diff --git a/src/mistral_common/__init__.py b/src/mistral_common/__init__.py index aa56ed4..c0f285b 100644 --- a/src/mistral_common/__init__.py +++ b/src/mistral_common/__init__.py @@ -1 +1 @@ -__version__ = "1.4.3" +__version__ = "1.4.4"