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

scheduled removal of BaseProfiler.output_filename in favor of dirpath… #9214

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

- Removed deprecated property `Trainer.running_sanity_check` in favor of `Trainer.sanity_checking` ([#9209](https://github.com/PyTorchLightning/pytorch-lightning/pull/9209))


- Removed deprecated `BaseProfiler.output_filename` arg from it and its descendants in favor of `dirpath` and `filename` ([#9214](https://github.com/PyTorchLightning/pytorch-lightning/pull/9214))

### Fixed

- Fixed save/load/resume from checkpoint for DeepSpeed Plugin (
Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/profiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
trainer = Trainer(..., profiler=profiler)

The profiler's results will be printed at the completion of a training `fit()`. This profiler
report can be quite long, so you can also specify an `output_filename` to save the report instead
report can be quite long, so you can also specify a `dirpath` and `filename` to save the report instead
of logging it to the output in your terminal. The output below shows the profiling for the action
`get_train_batch`.

Expand Down
3 changes: 1 addition & 2 deletions pytorch_lightning/profiler/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(
dirpath: Optional[Union[str, Path]] = None,
filename: Optional[str] = None,
line_count_restriction: float = 1.0,
output_filename: Optional[str] = None,
) -> None:
"""
Args:
Expand All @@ -55,7 +54,7 @@ def __init__(
ValueError:
If you attempt to stop recording an action which was never started.
"""
super().__init__(dirpath=dirpath, filename=filename, output_filename=output_filename)
super().__init__(dirpath=dirpath, filename=filename)
self.profiled_actions: Dict[str, cProfile.Profile] = {}
self.line_count_restriction = line_count_restriction

Expand Down
10 changes: 0 additions & 10 deletions pytorch_lightning/profiler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from pathlib import Path
from typing import Any, Callable, Dict, Generator, Iterable, Optional, TextIO, Union

from pytorch_lightning.utilities import rank_zero_deprecation
from pytorch_lightning.utilities.cloud_io import get_filesystem

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -58,18 +57,9 @@ def __init__(
self,
dirpath: Optional[Union[str, Path]] = None,
filename: Optional[str] = None,
output_filename: Optional[str] = None,
) -> None:
self.dirpath = dirpath
self.filename = filename
if output_filename is not None:
rank_zero_deprecation(
"`Profiler` signature has changed in v1.3. The `output_filename` parameter has been removed in"
" favor of `dirpath` and `filename`. Support for the old signature will be removed in v1.5"
)
filepath = Path(output_filename)
self.dirpath = filepath.parent
self.filename = filepath.stem

self._output_file: Optional[TextIO] = None
self._write_stream: Optional[Callable] = None
Expand Down
3 changes: 1 addition & 2 deletions pytorch_lightning/profiler/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def __init__(
sort_by_key: Optional[str] = None,
record_functions: Set[str] = None,
record_module_names: bool = True,
output_filename: Optional[str] = None,
**profiler_kwargs: Any,
) -> None:
"""
Expand Down Expand Up @@ -274,7 +273,7 @@ def __init__(
If arg ``schedule`` is not a ``Callable``.
If arg ``schedule`` does not return a ``torch.profiler.ProfilerAction``.
"""
super().__init__(dirpath=dirpath, filename=filename, output_filename=output_filename)
super().__init__(dirpath=dirpath, filename=filename)

self._group_by_input_shapes = group_by_input_shapes and profiler_kwargs.get("record_shapes", False)
self._emit_nvtx = emit_nvtx
Expand Down
3 changes: 1 addition & 2 deletions pytorch_lightning/profiler/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(
dirpath: Optional[Union[str, Path]] = None,
filename: Optional[str] = None,
extended: bool = True,
output_filename: Optional[str] = None,
) -> None:
"""
Args:
Expand All @@ -53,7 +52,7 @@ def __init__(
If you attempt to start an action which has already started, or
if you attempt to stop recording an action which was never started.
"""
super().__init__(dirpath=dirpath, filename=filename, output_filename=output_filename)
super().__init__(dirpath=dirpath, filename=filename)
self.current_actions: Dict[str, float] = {}
self.recorded_durations = defaultdict(list)
self.extended = extended
Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/profiler/xla.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, port: int = 9012) -> None:
This Profiler will help you debug and optimize training workload performance
for your models using Cloud TPU performance tools.
"""
super().__init__(dirpath=None, filename=None, output_filename=None)
super().__init__(dirpath=None, filename=None)
self.port = port
self._recording_map: Dict = {}
self._step_recoding_map: Dict = {}
Expand Down
10 changes: 0 additions & 10 deletions tests/deprecated_api/test_remove_1-5.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.core.decorators import auto_move_data
from pytorch_lightning.plugins import DeepSpeedPlugin
from pytorch_lightning.profiler import AdvancedProfiler, BaseProfiler, PyTorchProfiler, SimpleProfiler
from tests.deprecated_api import no_deprecated_call
from tests.helpers import BoringDataModule, BoringModel
from tests.helpers.runif import RunIf
Expand All @@ -32,15 +31,6 @@ def test_v1_5_0_model_checkpoint_period(tmpdir):
ModelCheckpoint(dirpath=tmpdir, period=1)


@pytest.mark.parametrize("cls", (BaseProfiler, SimpleProfiler, AdvancedProfiler, PyTorchProfiler))
def test_v1_5_0_profiler_output_filename(tmpdir, cls):
filepath = str(tmpdir / "test.txt")
with pytest.deprecated_call(match="`output_filename` parameter has been removed"):
profiler = cls(output_filename=filepath)
assert profiler.dirpath == tmpdir
assert profiler.filename == "test"


def test_v1_5_0_auto_move_data():
with pytest.deprecated_call(match="deprecated in v1.3 and will be removed in v1.5.*was applied to `bar`"):

Expand Down