Skip to content

Commit

Permalink
chore: added increased timeout on flaky batch request (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
munkhuushmgl authored and holtskinner committed Jan 3, 2023
1 parent 2774619 commit 87b9220
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion batch_parse_form_v1beta2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def batch_parse_form(
project_id="YOUR_PROJECT_ID",
input_uri="gs://cloud-samples-data/documentai/form.pdf",
destination_uri="gs://your-bucket-id/path/to/save/results/",
timeout=90
):
"""Parse a form"""

Expand Down Expand Up @@ -80,7 +81,7 @@ def batch_parse_form(
operation = client.batch_process_documents(batch_request)

# Wait for the operation to finish
operation.result()
operation.result(timeout)

# Results are written to GCS. Use a regex to find
# output files
Expand Down
2 changes: 1 addition & 1 deletion batch_parse_form_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ def setup_teardown():


def test_batch_parse_form(capsys):
batch_parse_form_v1beta2.batch_parse_form(PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI)
batch_parse_form_v1beta2.batch_parse_form(PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI, 120)
out, _ = capsys.readouterr()
assert "Output files" in out
3 changes: 2 additions & 1 deletion batch_parse_table_v1beta2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def batch_parse_table(
project_id="YOUR_PROJECT_ID",
input_uri="gs://cloud-samples-data/documentai/form.pdf",
destination_uri="gs://your-bucket-id/path/to/save/results/",
timeout=90
):
"""Parse a form"""

Expand Down Expand Up @@ -88,7 +89,7 @@ def batch_parse_table(
operation = client.batch_process_documents(batch_request)

# Wait for the operation to finish
operation.result()
operation.result(timeout)

# Results are written to GCS. Use a regex to find
# output files
Expand Down
2 changes: 1 addition & 1 deletion batch_parse_table_v1beta2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ def setup_teardown():


def test_batch_parse_table(capsys):
batch_parse_table_v1beta2.batch_parse_table(PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI)
batch_parse_table_v1beta2.batch_parse_table(PROJECT_ID, INPUT_URI, BATCH_OUTPUT_URI, 120)
out, _ = capsys.readouterr()
assert "Output files:" in out

0 comments on commit 87b9220

Please sign in to comment.