@@ -462,7 +462,9 @@ def data_row_for_external_id(self, external_id) -> "DataRow":
462462 external_id )
463463 return data_rows [0 ]
464464
465- def export_data_rows (self , timeout_seconds = 120 ) -> Generator :
465+ def export_data_rows (self ,
466+ timeout_seconds = 120 ,
467+ include_metadata : bool = False ) -> Generator :
466468 """ Returns a generator that produces all data rows that are currently
467469 attached to this dataset.
468470
@@ -477,23 +479,24 @@ def export_data_rows(self, timeout_seconds=120) -> Generator:
477479 LabelboxError: if the export fails or is unable to download within the specified time.
478480 """
479481 id_param = "datasetId"
480- query_str = """mutation GetDatasetDataRowsExportUrlPyApi($%s: ID!)
481- {exportDatasetDataRows(data:{datasetId: $%s }) {downloadUrl createdAt status}}
482- """ % (id_param , id_param )
482+ metadata_param = "includeMetadataInput"
483+ query_str = """mutation GetDatasetDataRowsExportUrlPyApi($%s: ID!, $%s: Boolean!)
484+ {exportDatasetDataRows(data:{datasetId: $%s , includeMetadataInput: $%s}) {downloadUrl createdAt status}}
485+ """ % (id_param , metadata_param , id_param , metadata_param )
483486 sleep_time = 2
484487 while True :
485- res = self .client .execute (query_str , {id_param : self .uid })
488+ res = self .client .execute (query_str , {
489+ id_param : self .uid ,
490+ metadata_param : include_metadata
491+ })
486492 res = res ["exportDatasetDataRows" ]
487493 if res ["status" ] == "COMPLETE" :
488494 download_url = res ["downloadUrl" ]
489495 response = requests .get (download_url )
490496 response .raise_for_status ()
491497 reader = ndjson .reader (StringIO (response .text ))
492- # TODO: Update result to parse metadataFields when resolver returns
493- return (Entity .DataRow (self .client , {
494- ** result , 'metadataFields' : [],
495- 'customMetadata' : []
496- }) for result in reader )
498+ return (
499+ Entity .DataRow (self .client , result ) for result in reader )
497500 elif res ["status" ] == "FAILED" :
498501 raise LabelboxError ("Data row export failed." )
499502
0 commit comments