@@ -116,6 +116,7 @@ def __init__(self, dataset_id, client, name=None):
116116 self ._client = client
117117 # NOTE: Optionally set name on creation such that the property access doesn't need to hit the server
118118 self ._name = name
119+ self ._is_scene = None
119120
120121 def __repr__ (self ):
121122 if os .environ .get ("NUCLEUS_DEBUG" , None ):
@@ -141,10 +142,13 @@ def name(self) -> str:
141142 @property
142143 def is_scene (self ) -> bool :
143144 """Whether or not the dataset contains scenes exclusively."""
145+ if self ._is_scene is not None :
146+ return self ._is_scene
144147 response = self ._client .make_request (
145148 {}, f"dataset/{ self .id } /is_scene" , requests .get
146149 )[DATASET_IS_SCENE_KEY ]
147- return response
150+ self ._is_scene = response
151+ return self ._is_scene
148152
149153 @property
150154 def model_runs (self ) -> List [str ]:
@@ -1375,6 +1379,25 @@ def get_scene(self, reference_id: str) -> Scene:
13751379 return VideoScene .from_json (response )
13761380 return LidarScene .from_json (response )
13771381
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+
13781401 def export_predictions (self , model ):
13791402 """Fetches all predictions of a model that were uploaded to the dataset.
13801403
0 commit comments