-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass python model timeout to polling instead of retry #766
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
622b420
Pass python model timeout to polling instead of retry
colin-rogers-dbt cbadae3
Merge branch 'main' into fixDataprocPollingTimeout
colin-rogers-dbt ad1f979
rename retry to result_polling_policy
colin-rogers-dbt dad61de
Merge branch 'main' into fixDataprocPollingTimeout
colin-rogers-dbt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Fixes | ||
body: Pass python model timeout to polling operation so model execution times out | ||
as expected. | ||
time: 2023-06-09T13:27:27.279842-07:00 | ||
custom: | ||
Author: colin-rogers-dbt | ||
Issue: "577" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from typing import Dict, Union | ||
|
||
from dbt.adapters.base import PythonJobHelper | ||
from google.api_core.future.polling import POLLING_PREDICATE | ||
|
||
from dbt.adapters.bigquery import BigQueryConnectionManager, BigQueryCredentials | ||
from dbt.adapters.bigquery.connections import DataprocBatchConfig | ||
from google.api_core import retry | ||
|
@@ -43,7 +45,7 @@ def __init__(self, parsed_model: Dict, credential: BigQueryCredentials) -> None: | |
self.timeout = self.parsed_model["config"].get( | ||
"timeout", self.credential.job_execution_timeout_seconds or 60 * 60 * 24 | ||
) | ||
self.retry = retry.Retry(maximum=10.0, deadline=self.timeout) | ||
self.retry = retry.Retry(predicate=POLLING_PREDICATE, maximum=10.0, timeout=self.timeout) | ||
self.client_options = ClientOptions( | ||
api_endpoint="{}-dataproc.googleapis.com:443".format(self.credential.dataproc_region) | ||
) | ||
|
@@ -98,7 +100,7 @@ def _submit_dataproc_job(self) -> dataproc_v1.types.jobs.Job: | |
"job": job, | ||
} | ||
) | ||
response = operation.result(retry=self.retry) | ||
response = operation.result(polling=self.retry) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we consider rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call, I think |
||
# check if job failed | ||
if response.status.state == 6: | ||
raise ValueError(response.status.details) | ||
|
@@ -123,7 +125,7 @@ def _submit_dataproc_job(self) -> dataproc_v1.types.jobs.Job: | |
operation = self.job_client.create_batch(request=request) # type: ignore | ||
# this takes quite a while, waiting on GCP response to resolve | ||
# (not a google-api-core issue, more likely a dataproc serverless issue) | ||
response = operation.result(retry=self.retry) | ||
response = operation.result(polling=self.retry) | ||
return response | ||
# there might be useful results here that we can parse and return | ||
# Dataproc job output is saved to the Cloud Storage bucket | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://googleapis.dev/python/google-api-core/latest/_modules/google/api_core/future/polling.html
predicate=POLLING_PREDICATE,
is already a default so you can skip itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My read on this is that if we supply a custom
Retry
to polling (i.e. that replaces theDEFAULT_POLLING
retry) it won't necessarily add the default polling predicateThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I guess you're right, the
DEFAULT_POLLING
is not used anymore then and the retry constructor doesn't have a predicate by default