2020-12-06 13:01:43 +00:00
|
|
|
# Copyright The PyTorch Lightning team.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2020-03-06 17:00:05 +00:00
|
|
|
"""Test deprecated functionality which will be removed in vX.Y.Z"""
|
2020-04-23 21:34:47 +00:00
|
|
|
|
2020-11-17 23:29:09 +00:00
|
|
|
import pytest
|
2020-03-06 17:00:05 +00:00
|
|
|
|
2020-12-04 11:28:53 +00:00
|
|
|
from pytorch_lightning import LightningModule, Trainer
|
2020-12-04 16:59:38 +00:00
|
|
|
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
|
2020-10-23 04:29:12 +00:00
|
|
|
|
|
|
|
|
2020-12-21 23:23:33 +00:00
|
|
|
def test_v1_3_0_deprecated_arguments(tmpdir):
|
2020-11-02 05:18:20 +00:00
|
|
|
with pytest.deprecated_call(match='will no longer be supported in v1.3'):
|
2020-10-30 03:47:37 +00:00
|
|
|
callback = ModelCheckpoint()
|
|
|
|
Trainer(checkpoint_callback=callback, callbacks=[], default_root_dir=tmpdir)
|
|
|
|
|
2020-11-21 12:38:42 +00:00
|
|
|
# Deprecate prefix
|
|
|
|
with pytest.deprecated_call(match='will be removed in v1.3'):
|
2020-12-04 15:11:58 +00:00
|
|
|
ModelCheckpoint(prefix='temp')
|
|
|
|
|
|
|
|
# Deprecate auto mode
|
|
|
|
with pytest.deprecated_call(match='will be removed in v1.3'):
|
|
|
|
ModelCheckpoint(mode='auto')
|
|
|
|
|
|
|
|
with pytest.deprecated_call(match='will be removed in v1.3'):
|
|
|
|
EarlyStopping(mode='auto')
|
2020-11-21 12:38:42 +00:00
|
|
|
|
2020-12-04 11:28:53 +00:00
|
|
|
with pytest.deprecated_call(match="The setter for self.hparams in LightningModule is deprecated"):
|
2021-02-06 13:22:10 +00:00
|
|
|
|
2020-12-04 11:28:53 +00:00
|
|
|
class DeprecatedHparamsModel(LightningModule):
|
2021-02-06 13:22:10 +00:00
|
|
|
|
2020-12-04 11:28:53 +00:00
|
|
|
def __init__(self, hparams):
|
|
|
|
super().__init__()
|
|
|
|
self.hparams = hparams
|
2021-02-06 13:22:10 +00:00
|
|
|
|
2020-12-04 11:28:53 +00:00
|
|
|
DeprecatedHparamsModel({})
|