Skip to content

Commit aeff029

Browse files
author
Matt Sokoloff
committed
fix import
1 parent f609801 commit aeff029

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

labelbox/schema/project.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@
1717
from labelbox.orm.db_object import DbObject, Updateable, Deletable
1818
from labelbox.orm.model import Entity, Field, Relationship
1919
from labelbox.pagination import PaginatedCollection
20-
from labelbox.data.serialization import LBV1Converter
20+
21+
logger = logging.getLogger(__name__)
2122

2223
try:
2324
datetime.fromisoformat # type: ignore[attr-defined]
2425
except AttributeError:
2526
from backports.datetime_fromisoformat import MonkeyPatch
2627
MonkeyPatch.patch_fromisoformat()
2728

28-
logger = logging.getLogger(__name__)
29+
try:
30+
from labelbox.data.serialization import LBV1Converter
31+
except ImportError:
32+
pass
2933

3034

3135
class Project(DbObject, Updateable, Deletable):
@@ -175,6 +179,7 @@ def video_label_generator(self, timeout_seconds=60):
175179
raise ValueError(
176180
"frames key not found in the first label. Cannot export video data."
177181
)
182+
_check_converter_import()
178183
return LBV1Converter.deserialize_video(json_data, self.client)
179184

180185
def label_generator(self, timeout_seconds=60):
@@ -186,6 +191,13 @@ def label_generator(self, timeout_seconds=60):
186191
"""
187192
json_data = self.export_labels(download=True,
188193
timeout_seconds=timeout_seconds)
194+
195+
if 'LBV1Converter' not in dir():
196+
raise ImportError(
197+
"Missing depdencies to import converter. "
198+
"Use `pip install labelbox[data]` to add missing dependencies. "
199+
"Or download raw jso with project.export_labels()")
200+
_check_converter_import()
189201
return LBV1Converter.deserialize(json_data)
190202

191203
def export_labels(self, download=False, timeout_seconds=60):
@@ -647,3 +659,11 @@ class LabelingParameterOverride(DbObject):
647659
"consensus average_benchmark_agreement last_activity_time")
648660
LabelerPerformance.__doc__ = (
649661
"Named tuple containing info about a labeler's performance.")
662+
663+
664+
def _check_converter_import():
665+
if 'LBV1Converter' not in dir():
666+
raise ImportError(
667+
"Missing depdencies to import converter. "
668+
"Use `pip install labelbox[data]` to add missing dependencies. "
669+
"Or download raw jso with project.export_labels()")

0 commit comments

Comments
 (0)