Skip to content

Commit f4f9b9a

Browse files
authored
🐞 Fix installation package issues (#2395)
* Update the coverage settings Signed-off-by: Samet Akcay <samet.akcay@intel.com> * Remove VlmAd's relative import Signed-off-by: Samet Akcay <samet.akcay@intel.com> * Revert relative imports Signed-off-by: Samet Akcay <samet.akcay@intel.com> * Add type checking Signed-off-by: Samet Akcay <samet.akcay@intel.com> --------- Signed-off-by: Samet Akcay <samet.akcay@intel.com>
1 parent 31952db commit f4f9b9a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies = [
3434
"jsonargparse[signatures]>=4.27.7",
3535
"docstring_parser", # CLI help-formatter
3636
"rich_argparse", # CLI help-formatter
37+
"lightning-utilities",
3738
]
3839

3940
[project.optional-dependencies]
@@ -293,11 +294,15 @@ pythonpath = "src"
293294
# COVERAGE CONFIGURATION #
294295
[tool.coverage.report]
295296
exclude_lines = [
296-
"except ImportError",
297+
"pragma: no cover",
298+
"def __repr__",
299+
"raise NotImplementedError",
300+
"if TYPE_CHECKING:",
301+
"@abstractmethod",
302+
"pass",
297303
"raise ImportError",
298-
"except ApiException",
299-
"raise ApiException",
300304
"raise ValueError",
305+
"except ImportError:",
301306
]
302307

303308
[tool.coverage.paths]

src/anomalib/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class UnknownModelError(ModuleNotFoundError):
5858
"Rkde",
5959
"Stfpm",
6060
"Uflow",
61-
"AiVad",
6261
"VlmAd",
6362
"WinClip",
63+
"AiVad",
6464
]
6565

6666
logger = logging.getLogger(__name__)

src/anomalib/models/image/vlm_ad/backends/huggingface.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55

66
import logging
77
from pathlib import Path
8+
from typing import TYPE_CHECKING
89

910
from lightning_utilities.core.imports import package_available
1011
from PIL import Image
11-
from transformers.modeling_utils import PreTrainedModel
1212

1313
from anomalib.models.image.vlm_ad.utils import Prompt
1414

1515
from .base import Backend
1616

17-
if package_available("transformers"):
18-
import transformers
17+
if TYPE_CHECKING:
1918
from transformers.modeling_utils import PreTrainedModel
2019
from transformers.processing_utils import ProcessorMixin
20+
21+
if package_available("transformers"):
22+
import transformers
2123
else:
2224
transformers = None
2325

@@ -39,7 +41,7 @@ def __init__(
3941
self._model: PreTrainedModel | None = None
4042

4143
@property
42-
def processor(self) -> ProcessorMixin:
44+
def processor(self) -> "ProcessorMixin":
4345
"""Get the Huggingface processor."""
4446
if self._processor is None:
4547
if transformers is None:
@@ -49,7 +51,7 @@ def processor(self) -> ProcessorMixin:
4951
return self._processor
5052

5153
@property
52-
def model(self) -> PreTrainedModel:
54+
def model(self) -> "PreTrainedModel":
5355
"""Get the Huggingface model."""
5456
if self._model is None:
5557
if transformers is None:

0 commit comments

Comments
 (0)