2828 BOX_TYPE ,
2929 CATEGORY_TYPE ,
3030 CUBOID_TYPE ,
31+ EXPORTED_SCALE_TASK_INFO_ROWS ,
3132 ITEM_KEY ,
3233 KEYPOINTS_TYPE ,
3334 LAST_PAGE ,
3940 POLYGON_TYPE ,
4041 PREDICTIONS_KEY ,
4142 REFERENCE_ID_KEY ,
43+ SCALE_TASK_INFO_KEY ,
44+ SCENE_KEY ,
4245 SEGMENTATION_TYPE ,
4346)
4447from .dataset_item import DatasetItem
@@ -161,7 +164,7 @@ def format_dataset_item_response(response: dict) -> dict:
161164 Args:
162165 response: JSON dictionary response from REST endpoint
163166 Returns:
164- item_dict: A dictionary with two entries, one for the dataset item, and annother
167+ item_dict: A dictionary with two entries, one for the dataset item, and another
165168 for all of the associated annotations.
166169 """
167170 if ANNOTATIONS_KEY not in response :
@@ -188,6 +191,33 @@ def format_dataset_item_response(response: dict) -> dict:
188191 }
189192
190193
194+ def format_scale_task_info_response (response : dict ) -> Union [Dict , List [Dict ]]:
195+ """Format the raw client response into api objects.
196+
197+ Args:
198+ response: JSON dictionary response from REST endpoint
199+ Returns:
200+ A dictionary with two entries, one for the dataset item, and another
201+ for all of the associated Scale tasks.
202+ """
203+ if EXPORTED_SCALE_TASK_INFO_ROWS not in response :
204+ # Payload is empty so an error occurred
205+ return response
206+
207+ ret = []
208+ for row in response [EXPORTED_SCALE_TASK_INFO_ROWS ]:
209+ if ITEM_KEY in row :
210+ ret .append (
211+ {
212+ ITEM_KEY : DatasetItem .from_json (row [ITEM_KEY ]),
213+ SCALE_TASK_INFO_KEY : row [SCALE_TASK_INFO_KEY ],
214+ }
215+ )
216+ elif SCENE_KEY in row :
217+ ret .append (row )
218+ return ret
219+
220+
191221def convert_export_payload (api_payload , has_predictions : bool = False ):
192222 """Helper function to convert raw JSON to API objects
193223
0 commit comments