Remove deprecated `is_overridden(model=...)` (#10507)
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
This commit is contained in:
parent
8b0cb47cc0
commit
794c4b08c0
|
@ -57,6 +57,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
### Removed
|
||||
|
||||
- Removed deprecated parameter `method` in `pytorch_lightning.utilities.model_helpers.is_overridden` ([#10507](https://github.com/PyTorchLightning/pytorch-lightning/pull/10507))
|
||||
|
||||
|
||||
- Remove deprecated method `ClusterEnvironment.creates_children` ([#10339](https://github.com/PyTorchLightning/pytorch-lightning/issues/10339))
|
||||
|
||||
|
||||
|
|
|
@ -12,26 +12,13 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from functools import partial
|
||||
from typing import Optional, Type, Union
|
||||
from typing import Optional, Type
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytorch_lightning as pl
|
||||
from pytorch_lightning.utilities import rank_zero_deprecation
|
||||
|
||||
|
||||
def is_overridden(
|
||||
method_name: str,
|
||||
instance: Optional[object] = None,
|
||||
parent: Optional[Type[object]] = None,
|
||||
model: Optional[Union["pl.LightningModule", "pl.LightningDataModule"]] = None,
|
||||
) -> bool:
|
||||
if model is not None and instance is None:
|
||||
rank_zero_deprecation(
|
||||
"`is_overriden(model=...)` has been deprecated and will be removed in v1.6."
|
||||
"Please use `is_overriden(instance=...)`"
|
||||
)
|
||||
instance = model
|
||||
|
||||
def is_overridden(method_name: str, instance: Optional[object] = None, parent: Optional[Type[object]] = None) -> bool:
|
||||
if instance is None:
|
||||
# if `self.lightning_module` was passed as instance, it can be `None`
|
||||
return False
|
||||
|
|
|
@ -17,7 +17,6 @@ from unittest.mock import call, Mock
|
|||
import pytest
|
||||
|
||||
from pytorch_lightning import Trainer
|
||||
from pytorch_lightning.utilities.model_helpers import is_overridden
|
||||
from tests.helpers import BoringModel
|
||||
|
||||
|
||||
|
@ -50,14 +49,6 @@ def test_v1_6_0_reload_dataloaders_every_epoch(tmpdir):
|
|||
assert tracker.mock_calls == expected_sequence
|
||||
|
||||
|
||||
def test_v1_6_0_is_overridden_model():
|
||||
model = BoringModel()
|
||||
with pytest.deprecated_call(match="and will be removed in v1.6"):
|
||||
assert is_overridden("validation_step", model=model)
|
||||
with pytest.deprecated_call(match="and will be removed in v1.6"):
|
||||
assert not is_overridden("foo", model=model)
|
||||
|
||||
|
||||
def test_v1_6_0_deprecated_disable_validation():
|
||||
trainer = Trainer()
|
||||
with pytest.deprecated_call(match="disable_validation` is deprecated in v1.4"):
|
||||
|
|
Loading…
Reference in New Issue