Skip to content

Commit 7ecb9fe

Browse files
committed
fix: Added trailing slash to gcs_prefix in from_batch_process_metadata()
1 parent ec28a76 commit 7ecb9fe

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

google/cloud/documentai_toolbox/wrappers/document.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)