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 KeyboardInterrupt halts microbatch model execution #10879

Conversation

QMalcolm
Copy link
Contributor

@QMalcolm QMalcolm commented Oct 17, 2024

Resolves #10862

Problem

A KeyboardInterrupt during the execution of microbatches would only cause the currently executing batch to stop, and then the rest of the batches (and job) would continue.

Solution

Make KeyboardInterrupts halt batch execution.

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.

@cla-bot cla-bot bot added the cla:yes label Oct 17, 2024
@QMalcolm
Copy link
Contributor Author

Need to figure out how to test this. I think we can mock a function called during ModelRunner._execute_microbatch_materialization to raise a KeyboardInterrupt, which we could then check causes execution to halt.

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.09%. Comparing base (8c6bec4) to head (e2869d5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10879      +/-   ##
==========================================
- Coverage   89.15%   89.09%   -0.06%     
==========================================
  Files         183      183              
  Lines       23529    23531       +2     
==========================================
- Hits        20977    20965      -12     
- Misses       2552     2566      +14     
Flag Coverage Δ
integration 86.39% <50.00%> (-0.15%) ⬇️
unit 62.74% <100.00%> (+0.47%) ⬆️

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

Components Coverage Δ
Unit Tests 62.74% <100.00%> (+0.47%) ⬆️
Integration Tests 86.39% <50.00%> (-0.15%) ⬇️

…l execution

Previously we were catching all execptions during microbatch model execution, and gracefully
handling them. This ensured that one failing batch didn't cause the rest of the batches to
fail / be skipped unnecessarily. However if there is a KeyboardInterrupt or SystemExit, execution
should halt. To get this to happen, we're now catching and reraising `KeybaordInterrupts`s and
`SystemExit`s.
@QMalcolm QMalcolm force-pushed the qmalcolm--10862-ensure-keyboard-interrupt-interrupts-microbatch-model-execution branch from 5c189ab to e2869d5 Compare October 30, 2024 21:24
@QMalcolm QMalcolm marked this pull request as ready for review October 30, 2024 21:26
@QMalcolm QMalcolm requested a review from a team as a code owner October 30, 2024 21:26
@@ -568,6 +568,9 @@ def _execute_microbatch_materialization(
# At least one batch has been inserted successfully!
incremental_batch = True

except (KeyboardInterrupt, SystemExit):
# reraise it for GraphRunnableTask.execute_nodes to handle
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be writing out run results in this case?

Copy link
Contributor Author

@QMalcolm QMalcolm Oct 30, 2024

Choose a reason for hiding this comment

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

The KeyboardInterrupt handler in GraphRunnableTask.execute_nodes should handle it

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

I have one question but otherwise LGTM!

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

Thanks for clarify! LGTM

@QMalcolm QMalcolm merged commit 289d2dd into main Oct 31, 2024
61 of 62 checks passed
@QMalcolm QMalcolm deleted the qmalcolm--10862-ensure-keyboard-interrupt-interrupts-microbatch-model-execution branch October 31, 2024 18:35
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.

[Bug] canceling a run of a microbatch model should cause remaining batches to be skipped
2 participants