@@ -116,6 +116,7 @@ def __init__(self, dataset_id, client, name=None):
116
116
self ._client = client
117
117
# NOTE: Optionally set name on creation such that the property access doesn't need to hit the server
118
118
self ._name = name
119
+ self ._is_scene = None
119
120
120
121
def __repr__ (self ):
121
122
if os .environ .get ("NUCLEUS_DEBUG" , None ):
@@ -141,10 +142,13 @@ def name(self) -> str:
141
142
@property
142
143
def is_scene (self ) -> bool :
143
144
"""Whether or not the dataset contains scenes exclusively."""
145
+ if self ._is_scene is not None :
146
+ return self ._is_scene
144
147
response = self ._client .make_request (
145
148
{}, f"dataset/{ self .id } /is_scene" , requests .get
146
149
)[DATASET_IS_SCENE_KEY ]
147
- return response
150
+ self ._is_scene = response
151
+ return self ._is_scene
148
152
149
153
@property
150
154
def model_runs (self ) -> List [str ]:
@@ -1375,6 +1379,25 @@ def get_scene(self, reference_id: str) -> Scene:
1375
1379
return VideoScene .from_json (response )
1376
1380
return LidarScene .from_json (response )
1377
1381
1382
+ def get_scene_from_item_ref_id (
1383
+ self , item_reference_id : str
1384
+ ) -> Optional [Scene ]:
1385
+ """Given a dataset item reference ID, find the Scene it belongs to."""
1386
+ if not self .is_scene :
1387
+ print (
1388
+ f"Dataset { self .id } is not a scene. Cannot call this endpoint."
1389
+ )
1390
+ return None
1391
+
1392
+ response = self ._client .make_request (
1393
+ payload = None ,
1394
+ route = f"dataset/{ self .id } /scene/{ item_reference_id } ?from_item=1" ,
1395
+ requests_command = requests .get ,
1396
+ )
1397
+ if FRAME_RATE_KEY in response or VIDEO_URL_KEY in response :
1398
+ return VideoScene .from_json (response )
1399
+ return LidarScene .from_json (response )
1400
+
1378
1401
def export_predictions (self , model ):
1379
1402
"""Fetches all predictions of a model that were uploaded to the dataset.
1380
1403
0 commit comments