Skip to content
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

Ensure run results artifact get written during "after run hooks" #10941

Merged

Conversation

QMalcolm
Copy link
Contributor

@QMalcolm QMalcolm commented Oct 30, 2024

Resolves #10934

Problem

Occasionally there would be an unhandled exception during the execution of on run end hooks. Because the exception wasn't being handled, the run_results.json artifact was not being written.

Solution

Handle more exception cases during the execution of on run end hooks.

Demo

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 89.12%. Comparing base (dd77210) to head (c7ce8e9).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10941      +/-   ##
==========================================
- Coverage   89.19%   89.12%   -0.08%     
==========================================
  Files         183      183              
  Lines       23496    23508      +12     
==========================================
- Hits        20958    20951       -7     
- Misses       2538     2557      +19     
Flag Coverage Δ
integration 86.42% <33.33%> (-0.17%) ⬇️
unit 62.29% <40.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.29% <40.00%> (+0.21%) ⬆️
Integration Tests 86.42% <33.33%> (-0.17%) ⬇️

Previously in `get_execution_status` if a non `DbtRuntimeError` exception was
raised, the finally would be entered, but the `status`/`message` would not be
set, and thus a `status not defined` exception would get raised on attempting
to return. Tangentially, there is another issue where somehow the `node_status`
is becoming `None`. In all my playing with `get_execution_status` I found that
trying to return an undefined variable in the `finally` caused an undefined
variable exception. However, if in some python version, it instead just handed
back `None`, then this fix should also solve that.
@QMalcolm QMalcolm force-pushed the qmalcolm--ensure-run-results-artifact-during-after-run-hooks branch from 0801f6e to 2929b89 Compare October 30, 2024 14:09
@QMalcolm QMalcolm marked this pull request as ready for review October 30, 2024 14:31
@QMalcolm QMalcolm requested a review from a team as a code owner October 30, 2024 14:31
@@ -94,11 +94,16 @@ def get_execution_status(sql: str, adapter: BaseAdapter) -> Tuple[RunStatus, str
response, _ = adapter.execute(sql, auto_begin=False, fetch=False)
status = RunStatus.Success
message = response._message
except (KeyboardInterrupt, SystemExit):
raise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking my own understanding -- these are eventually handled further along, here: https://github.com/dbt-labs/dbt-core/pull/10941/files#diff-299afe4cac0de7af89561129dd7c55a07bd53c06baafff397b51b460bc631bceR804?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct!

@QMalcolm QMalcolm merged commit 7f5abdc into main Oct 30, 2024
57 of 60 checks passed
@QMalcolm QMalcolm deleted the qmalcolm--ensure-run-results-artifact-during-after-run-hooks branch October 30, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing run_results.json from failed runs (versionless)
2 participants