66from pathlib import Path
77from typing import Dict , Union , Iterable
88from urllib .parse import urlparse
9+ import requests
10+ import ndjson
911
1012from labelbox import utils
1113from labelbox .schema .data_row import DataRow
@@ -166,8 +168,9 @@ def export_queued_data_rows(self, timeout_seconds=120):
166168 Args:
167169 timeout_seconds (float): Max waiting time, in seconds.
168170 Returns:
169- URL of the data file with this DataRow information. If the server didn't
170- generate during the `timeout_seconds` period, None is returned.
171+ Data row fields for all data rows in the queue as json
172+ Raises:
173+ LabelboxError: if the export fails or is unable to download within the specified time.
171174 """
172175 id_param = "projectId"
173176 query_str = """mutation GetQueuedDataRowsExportUrlPyApi($%s: ID!)
@@ -178,7 +181,10 @@ def export_queued_data_rows(self, timeout_seconds=120):
178181 res = self .client .execute (query_str , {id_param : self .uid })
179182 res = res ["exportQueuedDataRows" ]
180183 if res ["status" ] == "COMPLETE" :
181- return res ["downloadUrl" ]
184+ download_url = res ["downloadUrl" ]
185+ response = requests .get (download_url )
186+ response .raise_for_status ()
187+ return ndjson .loads (response .text )
182188 elif res ["status" ] == "FAILED" :
183189 raise LabelboxError ("Data row export failed." )
184190
0 commit comments