17
17
from labelbox .orm .db_object import DbObject , Updateable , Deletable
18
18
from labelbox .orm .model import Entity , Field , Relationship
19
19
from labelbox .pagination import PaginatedCollection
20
- from labelbox .data .serialization import LBV1Converter
21
20
22
21
try :
23
22
datetime .fromisoformat # type: ignore[attr-defined]
24
23
except AttributeError :
25
24
from backports .datetime_fromisoformat import MonkeyPatch
26
25
MonkeyPatch .patch_fromisoformat ()
27
26
27
+ try :
28
+ from labelbox .data .serialization import LBV1Converter
29
+ except ImportError :
30
+ pass
31
+
28
32
logger = logging .getLogger (__name__ )
29
33
30
34
@@ -175,6 +179,7 @@ def video_label_generator(self, timeout_seconds=60):
175
179
raise ValueError (
176
180
"frames key not found in the first label. Cannot export video data."
177
181
)
182
+ _check_converter_import ()
178
183
return LBV1Converter .deserialize_video (json_data , self .client )
179
184
180
185
def label_generator (self , timeout_seconds = 60 ):
@@ -186,6 +191,7 @@ def label_generator(self, timeout_seconds=60):
186
191
"""
187
192
json_data = self .export_labels (download = True ,
188
193
timeout_seconds = timeout_seconds )
194
+ _check_converter_import ()
189
195
return LBV1Converter .deserialize (json_data )
190
196
191
197
def export_labels (self , download = False , timeout_seconds = 60 ):
@@ -647,3 +653,11 @@ class LabelingParameterOverride(DbObject):
647
653
"consensus average_benchmark_agreement last_activity_time" )
648
654
LabelerPerformance .__doc__ = (
649
655
"Named tuple containing info about a labeler's performance." )
656
+
657
+
658
+ def _check_converter_import ():
659
+ if 'LBV1Converter' not in globals ():
660
+ raise ImportError (
661
+ "Missing dependencies to import converter. "
662
+ "Use `pip install labelbox[data]` to add missing dependencies. "
663
+ "or download raw json with project.export_labels()" )
0 commit comments