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

Make trainer.state a read-only property #3109

Merged
merged 2 commits into from
Aug 24, 2020

Conversation

zerogerc
Copy link
Contributor

@zerogerc zerogerc commented Aug 23, 2020

What does this PR do?

Follow-up on #2541 to make trainer state read-only.

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 your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@mergify mergify bot requested a review from a team August 23, 2020 07:12
@codecov
Copy link

codecov bot commented Aug 23, 2020

Codecov Report

Merging #3109 into master will decrease coverage by 1%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #3109    +/-   ##
=======================================
- Coverage      90%     89%    -1%     
=======================================
  Files          81      82     +1     
  Lines        7780    8320   +540     
=======================================
+ Hits         6995    7410   +415     
- Misses        785     910   +125     

@Borda Borda added the feature Is an improvement or enhancement label Aug 24, 2020
@Borda Borda added this to the 0.9.x milestone Aug 24, 2020
@Borda
Copy link
Member

Borda commented Aug 24, 2020

good work, but I would rather add also setter which main checks that the values in TrainerState type :]

@justusschock
Copy link
Member

@Borda I would prefer to keep it read-only as well. everything that is exposed will most likely be used by users in some way. And checking for valid arguments is quite hard. We can check for types, but even arguments with correct types may be wrong w.r.t. to trainer's flow.

Comment on lines 55 to 58
if exiting is not None:
self.state = exiting
self._state = exiting
else:
self.state = state_before
self._state = state_before
Copy link
Member

Choose a reason for hiding this comment

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

self._state = exiting if exiting is not None else state_before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for fixing this =)

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

To me this looks completely fine :D

Making things, the user isn't expected to change directly read-only is always a good idea I think :D

@mergify mergify bot requested a review from a team August 24, 2020 09:03
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

@mergify mergify bot requested a review from a team August 24, 2020 09:27
@Borda Borda added the ready PRs ready to be merged label Aug 24, 2020
Copy link
Member

@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.

I like to see this ❤️

@Borda Borda merged commit 2d42ec0 into Lightning-AI:master Aug 24, 2020
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 ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants