diff --git a/pytorch_lightning/profiler/base.py b/pytorch_lightning/profiler/base.py index 4e90d8adc3..d453095b24 100644 --- a/pytorch_lightning/profiler/base.py +++ b/pytorch_lightning/profiler/base.py @@ -62,7 +62,6 @@ class BaseProfiler(AbstractProfiler): self._output_file: Optional[TextIO] = None self._write_stream: Optional[Callable] = None self._local_rank: Optional[int] = None - self._log_dir: Optional[str] = None self._stage: Optional[str] = None @contextmanager @@ -157,7 +156,6 @@ class BaseProfiler(AbstractProfiler): """Execute arbitrary pre-profiling set-up steps.""" self._stage = stage self._local_rank = local_rank - self._log_dir = log_dir self.dirpath = self.dirpath or log_dir def teardown(self, stage: Optional[str] = None) -> None: diff --git a/tests/profiler/test_profiler.py b/tests/profiler/test_profiler.py index f27f4ab1c6..8d92c4318b 100644 --- a/tests/profiler/test_profiler.py +++ b/tests/profiler/test_profiler.py @@ -111,10 +111,10 @@ def test_simple_profiler_deepcopy(tmpdir): assert deepcopy(simple_profiler) -def test_simple_profiler_log_dir(tmpdir): +def test_simple_profiler_dirpath(tmpdir): """Ensure the profiler dirpath defaults to `trainer.log_dir` when not present.""" profiler = SimpleProfiler(filename="profiler") - assert profiler._log_dir is None + assert profiler.dirpath is None model = BoringModel() trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, profiler=profiler) @@ -122,7 +122,7 @@ def test_simple_profiler_log_dir(tmpdir): expected = tmpdir / "lightning_logs" / "version_0" assert trainer.log_dir == expected - assert profiler._log_dir == trainer.log_dir + assert profiler.dirpath == trainer.log_dir assert expected.join("fit-profiler.txt").exists() @@ -131,7 +131,7 @@ def test_simple_profiler_with_nonexisting_log_dir(tmpdir): nonexisting_tmpdir = tmpdir / "nonexisting" profiler = SimpleProfiler(filename="profiler") - assert profiler._log_dir is None + assert profiler.dirpath is None model = BoringModel() trainer = Trainer( @@ -142,7 +142,7 @@ def test_simple_profiler_with_nonexisting_log_dir(tmpdir): expected = nonexisting_tmpdir / "lightning_logs" / "version_0" assert expected.exists() assert trainer.log_dir == expected - assert profiler._log_dir == trainer.log_dir + assert profiler.dirpath == trainer.log_dir assert expected.join("fit-profiler.txt").exists() @@ -151,7 +151,6 @@ def test_simple_profiler_with_nonexisting_dirpath(tmpdir): nonexisting_tmpdir = tmpdir / "nonexisting" profiler = SimpleProfiler(dirpath=nonexisting_tmpdir, filename="profiler") - assert profiler._log_dir is None model = BoringModel() trainer = Trainer(