-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #12 Pull Request resolved: facebookexternal/stl_tasks#12 It's useful to return the best_model_path after training. e.g. F6 + multimodality needs it to publish the best model Reviewed By: tangbinh Differential Revision: D33716125 fbshipit-source-id: 2c8a5cd37d430062b7273c3fbebb0d58843f3b1d
- Loading branch information
1 parent
b67e5a2
commit 84bf109
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
|
||
#!/usr/bin/env python3 | ||
|
||
# pyre-strict | ||
from pytorch_lightning.callbacks import ModelCheckpoint | ||
from torchrecipes.core.base_train_app import BaseTrainApp | ||
from torchrecipes.core.conf import TrainerConf | ||
from torchrecipes.core.test_utils.test_base import BaseTrainAppTestCase | ||
|
||
|
||
class TestTrainApp(BaseTrainAppTestCase): | ||
def test_ckpt_callback_fallback_to_default(self) -> None: | ||
app = BaseTrainApp(None, TrainerConf(), None) | ||
app._set_trainer_params(trainer_params={}) | ||
self.assertIsNotNone(app._checkpoint_callback) | ||
self.assertIsNone(app._checkpoint_callback.monitor) | ||
|
||
def test_ckpt_callback_user_provided(self) -> None: | ||
app = BaseTrainApp(None, TrainerConf(), None) | ||
self.mock_callable(app, "get_callbacks").to_return_value( | ||
[ModelCheckpoint(monitor="some_metrics")] | ||
) | ||
app._set_trainer_params(trainer_params={}) | ||
self.assertIsNotNone(app._checkpoint_callback) | ||
self.assertEqual(app._checkpoint_callback.monitor, "some_metrics") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters