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

Handle KeyboardInterrupt during training #2134

Merged
merged 10 commits into from
Jun 15, 2020

Conversation

moi90
Copy link
Contributor

@moi90 moi90 commented Jun 9, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Fixes #2079 by introducing a on_interrupted callback where the cause of the interruption can be examined, e.g. by using sys.exc_info().

@pep8speaks
Copy link

pep8speaks commented Jun 9, 2020

Hello @moi90! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-06-14 15:23:13 UTC

@mergify
Copy link
Contributor

mergify bot commented Jun 9, 2020

This pull request is now in conflict... :(

@mergify mergify bot requested a review from a team June 9, 2020 15:22
@Borda Borda added the feature Is an improvement or enhancement label Jun 9, 2020
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

LGTM 🤖

@mergify mergify bot requested a review from a team June 9, 2020 17:13
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #2134 into master will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #2134   +/-   ##
======================================
  Coverage      87%     87%           
======================================
  Files          68      68           
  Lines        5180    5187    +7     
======================================
+ Hits         4508    4515    +7     
  Misses        672     672           

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

looks great, also the testing is nice.
I propose to change the name to simply on_interrupt for consistency, because for example we have on_test_end and not on_test_ended.

@mergify mergify bot requested a review from a team June 9, 2020 20:24
@moi90
Copy link
Contributor Author

moi90 commented Jun 9, 2020

@awaelchli Yes, you are right. I will change it accordingly.

@Borda
Copy link
Member

Borda commented Jun 9, 2020

looks great, also the testing is nice.
I propose to change the name to simply on_interrupt for consistency, because for example we have on_test_end and not on_test_ended.

I think it is about calling something extra on the interrupt, but true that the interruption status is in Trainer...

@mergify
Copy link
Contributor

mergify bot commented Jun 9, 2020

This pull request is now in conflict... :(

@moi90
Copy link
Contributor Author

moi90 commented Jun 10, 2020

@Borda What is your point? Should it be on_interrupt or on_interrupted?

@Borda
Copy link
Member

Borda commented Jun 11, 2020

@Borda What is your point? Should it be on_interrupt or on_interrupted?

I would choose on_interrupted
cc: @PyTorchLightning/core-contributors @williamFalcon

@awaelchli
Copy link
Contributor

@Borda why so?

arguments for on_interrupt:

  • consistent with rest of callback naming, i.e. interrupt is the noun that refers to the interrupt the same way batch_end refers to the end.
  • easier to remember since it follows the name pattern of the other callbacks
  • closer to English language (can form a sentence)
  • shorter/simpler

arguments for on_interrupted:

  • ?

@williamFalcon
Copy link
Contributor

williamFalcon commented Jun 11, 2020

on_interrupt to be consistent is my vote. all callbacks are set in the present tense for PL.

@Borda
Copy link
Member

Borda commented Jun 11, 2020

I said I would choose on_interrupted, but do not have any strong preference...

@williamFalcon williamFalcon added this to the 0.8.0 milestone Jun 13, 2020
@williamFalcon williamFalcon added the priority: 0 High priority task label Jun 13, 2020
@Borda Borda requested a review from awaelchli June 14, 2020 10:59
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

looks great, also the test.
thanks!

CHANGELOG.md Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team June 14, 2020 11:22
Borda and others added 2 commits June 14, 2020 13:46
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
@williamFalcon
Copy link
Contributor

@Borda can you rename to on_keyboard_interrupt?

unless this catches any general interrupt?

@Borda
Copy link
Member

Borda commented Jun 14, 2020

Borda can you rename to on_keyboard_interrupt?
unless this catches any general interrupt?

@williamFalcon renamed
cc: @awaelchli @moi90 @justusschock

Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

LGTM

@Borda Borda merged commit fd1693e into Lightning-AI:master Jun 15, 2020
@moi90
Copy link
Contributor Author

moi90 commented Jun 16, 2020

Great, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement priority: 0 High priority task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle KeyboardInterrupt during training
6 participants