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 monitor required arg of EarlyStopping callback #10328

Merged
merged 18 commits into from
Nov 9, 2021
Merged

Make monitor required arg of EarlyStopping callback #10328

merged 18 commits into from
Nov 9, 2021

Conversation

rhjohnstone
Copy link
Contributor

@rhjohnstone rhjohnstone commented Nov 3, 2021

What does this PR do?

Makes monitor a required argument of EarlyStopping callback, as one of the deprecated behaviours mentioned in #10312.

Does your PR introduce any breaking changes? If yes, please list them.

Yes. Users who logged the key "early_stop_on" and relied on EarlyStopping to default to monitor that key will have to change their code to EarlyStopping(monitor="early_stop_on").

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • 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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@awaelchli
Copy link
Contributor

awaelchli commented Nov 3, 2021

Great!

There are a few tests failing because the argument is now required. These tests need to be updated. Could you do it?
Here is the list:

FAILED tests/callbacks/test_early_stopping.py::test_pickling - TypeError: __i...
FAILED tests/callbacks/test_early_stopping.py::test_early_stopping_mode_options
FAILED tests/trainer/connectors/test_callback_connector.py::test_checkpoint_callbacks_are_last
FAILED tests/trainer/connectors/test_callback_connector.py::test_attach_model_callbacks
FAILED tests/trainer/connectors/test_callback_connector.py::test_attach_model_callbacks_override_info
FAILED tests/trainer/flags/test_fast_dev_run.py::test_callbacks_and_logger_not_called_with_fastdevrun[1]
FAILED tests/trainer/flags/test_fast_dev_run.py::test_callbacks_and_logger_not_called_with_fastdevrun[4]

If you want to check and run a test locally, you can do:

py.test -v tests/path/to/file.py::name_of_test

After that, we would need to include a new entry in our changelog in the "changed" section. Thanks for your help!

@awaelchli awaelchli added the feature Is an improvement or enhancement label Nov 3, 2021
@awaelchli awaelchli added this to the v1.6 milestone Nov 3, 2021
@awaelchli awaelchli added the breaking change Includes a breaking change label Nov 3, 2021
@awaelchli awaelchli self-assigned this Nov 3, 2021
@rhjohnstone
Copy link
Contributor Author

Thanks @awaelchli, I've fixed those tests. I now see that the docs (this page, I think) are failing because monitor is required. Unfortunately, I have no experience with the CLI (and hadn't ever seen those docs before!).

Is it as simple as changing

python ... \
    --trainer.callbacks=EarlyStopping \
    --trainer.callbacks.patience=5 \
    --trainer.callbacks=LearningRateMonitor \
    --trainer.callbacks.logging_interval=epoch

to

python ... \
    --trainer.callbacks=EarlyStopping \
    --trainer.callbacks.monitor=val_loss \
    --trainer.callbacks.patience=5 \
    --trainer.callbacks=LearningRateMonitor \
    --trainer.callbacks.logging_interval=epoch

etc.? I don't know if there's any special CLI behaviour when it comes to required vs optional args.

@awaelchli
Copy link
Contributor

@rhjohnstone I updated the "breaking changes" description in the PR :)

Copy link
Contributor

@tchaton tchaton 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 added the has conflicts label Nov 5, 2021
@mergify mergify bot removed the has conflicts label Nov 9, 2021
@carmocca carmocca enabled auto-merge (squash) November 9, 2021 15:24
@carmocca carmocca requested a review from awaelchli November 9, 2021 15:24
@mergify mergify bot added the ready PRs ready to be merged label Nov 9, 2021
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

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

small update to use it as kwarg

tests/callbacks/test_early_stopping.py Outdated Show resolved Hide resolved
tests/callbacks/test_early_stopping.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
tests/trainer/connectors/test_callback_connector.py Outdated Show resolved Hide resolved
@mergify mergify bot added the has conflicts label Nov 9, 2021
@mergify mergify bot removed the has conflicts label Nov 9, 2021
@carmocca carmocca merged commit c2f25d4 into Lightning-AI:master Nov 9, 2021
Raalsky pushed a commit to neptune-ai/pytorch-lightning that referenced this pull request Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Includes a breaking change 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.

5 participants