6
6
from pathlib import Path
7
7
from typing import Dict , Union , Iterable
8
8
from urllib .parse import urlparse
9
+ import requests
10
+ import ndjson
9
11
10
12
from labelbox import utils
11
13
from labelbox .schema .data_row import DataRow
@@ -166,8 +168,9 @@ def export_queued_data_rows(self, timeout_seconds=120):
166
168
Args:
167
169
timeout_seconds (float): Max waiting time, in seconds.
168
170
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.
171
174
"""
172
175
id_param = "projectId"
173
176
query_str = """mutation GetQueuedDataRowsExportUrlPyApi($%s: ID!)
@@ -178,7 +181,10 @@ def export_queued_data_rows(self, timeout_seconds=120):
178
181
res = self .client .execute (query_str , {id_param : self .uid })
179
182
res = res ["exportQueuedDataRows" ]
180
183
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 )
182
188
elif res ["status" ] == "FAILED" :
183
189
raise LabelboxError ("Data row export failed." )
184
190
0 commit comments