|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 | """Test deprecated functionality which will be removed in v1.8.0."""
|
15 |
| -import time |
16 | 15 | from unittest import mock
|
17 | 16 | from unittest.mock import Mock
|
18 | 17 |
|
19 |
| -import numpy as np |
20 | 18 | import pytest
|
21 | 19 |
|
22 | 20 | from pytorch_lightning import Callback, Trainer
|
23 | 21 | from pytorch_lightning.callbacks import ModelCheckpoint
|
24 | 22 | from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel
|
25 |
| -from pytorch_lightning.profilers import AdvancedProfiler, SimpleProfiler |
26 | 23 | from pytorch_lightning.strategies.ipu import LightningIPUModule
|
27 | 24 | from pytorch_lightning.trainer.configuration_validator import _check_datamodule_checkpoint_hooks
|
28 | 25 | from pytorch_lightning.trainer.states import RunningStage
|
@@ -323,48 +320,6 @@ def on_pretrain_routine_end(self, trainer, pl_module):
|
323 | 320 | trainer.fit(model)
|
324 | 321 |
|
325 | 322 |
|
326 |
| -@pytest.mark.flaky(reruns=3) |
327 |
| -@pytest.mark.parametrize(["action", "expected"], [("a", [3, 1]), ("b", [2]), ("c", [1])]) |
328 |
| -def test_simple_profiler_iterable_durations(tmpdir, action: str, expected: list): |
329 |
| - """Ensure the reported durations are reasonably accurate.""" |
330 |
| - |
331 |
| - def _sleep_generator(durations): |
332 |
| - """the profile_iterable method needs an iterable in which we can ensure that we're properly timing how long |
333 |
| - it takes to call __next__""" |
334 |
| - for duration in durations: |
335 |
| - time.sleep(duration) |
336 |
| - yield duration |
337 |
| - |
338 |
| - def _get_python_cprofile_total_duration(profile): |
339 |
| - return sum(x.inlinetime for x in profile.getstats()) |
340 |
| - |
341 |
| - simple_profiler = SimpleProfiler() |
342 |
| - iterable = _sleep_generator(expected) |
343 |
| - |
344 |
| - with pytest.deprecated_call( |
345 |
| - match="`SimpleProfiler.profile_iterable` is deprecated in v1.6 and will be removed in v1.8." |
346 |
| - ): |
347 |
| - for _ in simple_profiler.profile_iterable(iterable, action): |
348 |
| - pass |
349 |
| - |
350 |
| - # we exclude the last item in the recorded durations since that's when StopIteration is raised |
351 |
| - np.testing.assert_allclose(simple_profiler.recorded_durations[action][:-1], expected, rtol=0.2) |
352 |
| - |
353 |
| - advanced_profiler = AdvancedProfiler(dirpath=tmpdir, filename="profiler") |
354 |
| - |
355 |
| - iterable = _sleep_generator(expected) |
356 |
| - |
357 |
| - with pytest.deprecated_call( |
358 |
| - match="`AdvancedProfiler.profile_iterable` is deprecated in v1.6 and will be removed in v1.8." |
359 |
| - ): |
360 |
| - for _ in advanced_profiler.profile_iterable(iterable, action): |
361 |
| - pass |
362 |
| - |
363 |
| - recorded_total_duration = _get_python_cprofile_total_duration(advanced_profiler.profiled_actions[action]) |
364 |
| - expected_total_duration = np.sum(expected) |
365 |
| - np.testing.assert_allclose(recorded_total_duration, expected_total_duration, rtol=0.2) |
366 |
| - |
367 |
| - |
368 | 323 | def test_v1_8_0_datamodule_checkpointhooks():
|
369 | 324 | class CustomBoringDataModuleSave(BoringDataModule):
|
370 | 325 | def on_save_checkpoint(self, checkpoint):
|
|
0 commit comments