-
Notifications
You must be signed in to change notification settings - Fork 132
fix: use direct adapter connection for run_query (bypass log parsing) #936
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4d657c4
fix: retry run_query on empty run_operation result (flaky fusion test)
devin-ai-integration[bot] c975eef
fix: add short delay between run_query retries
devin-ai-integration[bot] f1f1ca5
fix: scope run_query retry to fusion runner only
devin-ai-integration[bot] 4384897
fix: apply run_query retry to all runners (not fusion-only)
devin-ai-integration[bot] 268d3d0
fix: bypass run_operation log parsing with direct adapter connection
devin-ai-integration[bot] ae53f25
fix: fall back to run_operation for queries with non-ref Jinja
devin-ai-integration[bot] 69ac36e
refactor: address review comments - lazy init, source resolution, man…
devin-ai-integration[bot] 0ca8ca3
refactor: use tenacity for run_operation retry
devin-ai-integration[bot] 77f5ddc
chore: add tenacity as direct test dependency
devin-ai-integration[bot] 08a6ebb
fix: surface seed and init failures instead of swallowing them
devin-ai-integration[bot] 6b4acf9
refactor: early exit on init failure to reduce log noise
devin-ai-integration[bot] 148b1d9
Merge branch 'devin/1772105501-investigate-databricks-schema-failures…
devin-ai-integration[bot] 69e1213
Merge remote-tracking branch 'origin/master' into devin/1772040020-fi…
devin-ai-integration[bot] 4869797
refactor: address review comments - BaseAdapter type, custom Unsuppor…
devin-ai-integration[bot] b722905
refactor: log fallback to run_operation and use tenacity before_sleep…
devin-ai-integration[bot] 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,5 +1,6 @@ | ||
| import json | ||
| import os | ||
| import time | ||
| from contextlib import contextmanager, nullcontext | ||
| from pathlib import Path | ||
| from tempfile import NamedTemporaryFile | ||
|
|
@@ -59,14 +60,30 @@ def __init__( | |
| self.tmp_models_dir_path = self.models_dir_path / "tmp" | ||
| self.seeds_dir_path = self.project_dir_path / "data" | ||
|
|
||
| _RUN_QUERY_MAX_RETRIES = 3 | ||
| _RUN_QUERY_RETRY_DELAY_SECONDS = 0.5 | ||
|
|
||
| def run_query(self, prerendered_query: str): | ||
|
haritamar marked this conversation as resolved.
|
||
| results = json.loads( | ||
| self.dbt_runner.run_operation( | ||
| for attempt in range(1, self._RUN_QUERY_MAX_RETRIES + 1): | ||
|
Collaborator
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. maybe create a helper |
||
| run_operation_results = self.dbt_runner.run_operation( | ||
| "elementary.render_run_query", | ||
| macro_args={"prerendered_query": prerendered_query}, | ||
| )[0] | ||
| ) | ||
| if run_operation_results: | ||
| return json.loads(run_operation_results[0]) | ||
| logger.warning( | ||
| "run_operation('elementary.render_run_query') returned no output " | ||
| "(attempt %d/%d)", | ||
| attempt, | ||
| self._RUN_QUERY_MAX_RETRIES, | ||
| ) | ||
| if attempt < self._RUN_QUERY_MAX_RETRIES: | ||
| time.sleep(self._RUN_QUERY_RETRY_DELAY_SECONDS) | ||
| raise RuntimeError( | ||
| f"run_operation('elementary.render_run_query') returned no output " | ||
| f"after {self._RUN_QUERY_MAX_RETRIES} attempts. " | ||
| f"Query: {prerendered_query!r}" | ||
| ) | ||
| return results | ||
|
|
||
| @staticmethod | ||
| def read_table_query( | ||
|
|
||
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.
move these constants to the top of the file