Skip to content

Commit 4fcd756

Browse files
markurtzrahul-tuli
authored andcommitted
Add import error messages for integrations now that auto install has been removed (#1030)
(cherry picked from commit 4e03e41)
1 parent 3d129fc commit 4fcd756

File tree

6 files changed

+49
-1
lines changed

6 files changed

+49
-1
lines changed

Diff for: src/deepsparse/image_classification/__init__.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@
1616
from deepsparse.analytics import deepsparse_analytics as _analytics
1717

1818

19-
_analytics.send_event("python__image_classification__init")
19+
try:
20+
import torchvision as _torchvision
21+
22+
import cv2 as _cv2
23+
except ImportError:
24+
raise ImportError(
25+
"Please install deepsparse[image_classification] to use this pathway"
26+
)
2027

2128

2229
from .constants import *
2330
from .pipelines import *
2431
from .schemas import *
32+
33+
34+
_analytics.send_event("python__image_classification__init")

Diff for: src/deepsparse/open_pif_paf/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# flake8: noqa
1515
from deepsparse.analytics import deepsparse_analytics as _analytics
1616

17+
18+
try:
19+
import cv2 as _cv2
20+
import openpifpaf as _openpifpaf
21+
except ImportError:
22+
raise ImportError("Please install deepsparse[openpifpaf] to use this pathway")
23+
1724
from .utils import *
1825

1926

Diff for: src/deepsparse/server/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121

2222
from deepsparse.analytics import deepsparse_analytics as _analytics
2323

24+
25+
try:
26+
import uvicorn as _uvicorn
27+
from fastapi import FastAPI as _FastAPI
28+
from starlette.responses import RedirectResponse as _RedirectResponse
29+
except ImportError:
30+
raise ImportError("Please install deepsparse[server] to use this pathway")
31+
2432
from .cli import main
2533

2634

Diff for: src/deepsparse/transformers/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
_analytics.send_event("python__transformers__init")
2828

2929

30+
try:
31+
import transformers as _transformers
32+
33+
import datasets as _datasets
34+
except ImportError:
35+
raise ImportError("Please install deepsparse[transformers] to use this pathway")
36+
37+
3038
_LOGGER = _logging.getLogger(__name__)
3139

3240

Diff for: src/deepsparse/yolo/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
from deepsparse.analytics import deepsparse_analytics as _analytics
1818

19+
20+
try:
21+
import torchvision as _torchvision
22+
23+
import cv2 as _cv2
24+
except ImportError:
25+
raise ImportError("Please install deepsparse[yolo] to use this pathway")
26+
1927
from .annotate import *
2028
from .pipelines import *
2129
from .schemas import *

Diff for: src/deepsparse/yolov8/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616

1717
from deepsparse.analytics import deepsparse_analytics as _analytics
1818

19+
20+
try:
21+
import ultralytics as _ultralytics
22+
except ImportError:
23+
raise ImportError("Please install deepsparse[yolov8] to use this pathway")
24+
25+
1926
from .annotate import *
2027
from .pipelines import *
2128
from .schemas import *

0 commit comments

Comments
 (0)