Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
docs(samples): Added field_mask to batch_process samples
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner committed Nov 9, 2022
1 parent f7b2bfd commit fe20578
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# input_mime_type = "application/pdf"
# gcs_output_bucket = "YOUR_OUTPUT_BUCKET_NAME" # Format: gs://bucket
# gcs_output_uri_prefix = "YOUR_OUTPUT_URI_PREFIX" # Format: directory/subdirectory/
# field_mask = "text,entities,pages.pageNumber" # Optional. The fields to return in the Document object.


def batch_process_documents_processor_version(
Expand All @@ -40,6 +41,7 @@ def batch_process_documents_processor_version(
input_mime_type: str,
gcs_output_bucket: str,
gcs_output_uri_prefix: str,
field_mask: str = None,
timeout: int = 400,
):

Expand Down Expand Up @@ -67,7 +69,7 @@ def batch_process_documents_processor_version(
destination_uri = f"{gcs_output_bucket}/{gcs_output_uri_prefix}/"

gcs_output_config = documentai.DocumentOutputConfig.GcsOutputConfig(
gcs_uri=destination_uri
gcs_uri=destination_uri, field_mask=field_mask
)

# Where to write results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
gcs_input_uri = "gs://cloud-samples-data/documentai/invoice.pdf"
input_mime_type = "application/pdf"
gcs_output_uri_prefix = uuid4()
field_mask = "text,pages.pageNumber"
BUCKET_NAME = f"document-ai-python-{uuid4()}"


Expand Down Expand Up @@ -56,6 +57,7 @@ def test_batch_process_documents_processor_version(capsys, test_bucket):
input_mime_type=input_mime_type,
gcs_output_bucket=f"gs://{test_bucket}",
gcs_output_uri_prefix=gcs_output_uri_prefix,
field_mask=field_mask,
)
out, _ = capsys.readouterr()

Expand Down
4 changes: 3 additions & 1 deletion samples/snippets/batch_process_documents_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# input_mime_type = "application/pdf"
# gcs_output_bucket = "YOUR_OUTPUT_BUCKET_NAME" # Format: gs://bucket
# gcs_output_uri_prefix = "YOUR_OUTPUT_URI_PREFIX" # Format: directory/subdirectory/
# field_mask = "text,entities,pages.pageNumber" # Optional. The fields to return in the Document object.


def batch_process_documents(
Expand All @@ -38,6 +39,7 @@ def batch_process_documents(
input_mime_type: str,
gcs_output_bucket: str,
gcs_output_uri_prefix: str,
field_mask: str = None,
timeout: int = 400,
):

Expand Down Expand Up @@ -65,7 +67,7 @@ def batch_process_documents(
destination_uri = f"{gcs_output_bucket}/{gcs_output_uri_prefix}/"

gcs_output_config = documentai.DocumentOutputConfig.GcsOutputConfig(
gcs_uri=destination_uri
gcs_uri=destination_uri, field_mask=field_mask
)

# Where to write results
Expand Down
2 changes: 2 additions & 0 deletions samples/snippets/batch_process_documents_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
gcs_input_uri = "gs://cloud-samples-data/documentai/invoice.pdf"
input_mime_type = "application/pdf"
gcs_output_uri_prefix = uuid4()
field_mask = "text,pages.pageNumber"
BUCKET_NAME = f"document-ai-python-{uuid4()}"


Expand Down Expand Up @@ -54,6 +55,7 @@ def test_batch_process_documents(capsys, test_bucket):
input_mime_type=input_mime_type,
gcs_output_bucket=f"gs://{test_bucket}",
gcs_output_uri_prefix=gcs_output_uri_prefix,
field_mask=field_mask,
)
out, _ = capsys.readouterr()

Expand Down

0 comments on commit fe20578

Please sign in to comment.