File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
google/cloud/documentai_toolbox/wrappers Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -573,13 +573,21 @@ def from_batch_process_metadata(
573573 if metadata .state != documentai .BatchProcessMetadata .State .SUCCEEDED :
574574 raise ValueError (f"Batch Process Failed: { metadata .state_message } " )
575575
576- return [
577- Document . from_gcs (
578- * gcs_utilities .split_gcs_uri (process . output_gcs_destination ),
579- gcs_input_uri = process .input_gcs_source ,
576+ documents : List [ Document ] = []
577+ for process in metadata . individual_process_statuses :
578+ gcs_bucket , gcs_prefix = gcs_utilities .split_gcs_uri (
579+ process .output_gcs_destination
580580 )
581- for process in list (metadata .individual_process_statuses )
582- ]
581+ documents .append (
582+ Document .from_gcs (
583+ gcs_bucket_name = gcs_bucket ,
584+ # Trailing slash added because it's missing from output_gcs_destination.
585+ # https://github.com/googleapis/python-documentai-toolbox/issues/271
586+ gcs_prefix = f"{ gcs_prefix } /" ,
587+ gcs_input_uri = process .input_gcs_source ,
588+ )
589+ )
590+ return documents
583591
584592 @classmethod
585593 def from_batch_process_operation (
You can’t perform that action at this time.
0 commit comments