From d1949766f8cddd424e2fac3a68b275bebe13d3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Mon, 29 Apr 2024 14:51:56 +0200 Subject: [PATCH] Fix TensorBoardLogger test on Windows (#19824) --- requirements/fabric/base.txt | 2 +- requirements/pytorch/base.txt | 2 +- .../tests_pytorch/loggers/test_tensorboard.py | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements/fabric/base.txt b/requirements/fabric/base.txt index 4cac78e19bf23..7487dd9b754b3 100644 --- a/requirements/fabric/base.txt +++ b/requirements/fabric/base.txt @@ -3,7 +3,7 @@ numpy >=1.17.2, <1.27.0 torch >=2.0.0, <2.4.0 -fsspec[http] >=2022.5.0, <2023.11.0 +fsspec[http] >=2022.5.0, <2024.4.0 packaging >=20.0, <=23.1 typing-extensions >=4.4.0, <4.10.0 lightning-utilities >=0.8.0, <0.12.0 diff --git a/requirements/pytorch/base.txt b/requirements/pytorch/base.txt index 9af0b13c15ccd..4993a918af099 100644 --- a/requirements/pytorch/base.txt +++ b/requirements/pytorch/base.txt @@ -5,7 +5,7 @@ numpy >=1.17.2, <1.27.0 torch >=2.0.0, <2.4.0 tqdm >=4.57.0, <4.67.0 PyYAML >=5.4, <6.1.0 -fsspec[http] >=2022.5.0, <2023.11.0 +fsspec[http] >=2022.5.0, <2024.4.0 torchmetrics >=0.7.0, <1.3.0 # needed for using fixed compare_version packaging >=20.0, <=23.1 typing-extensions >=4.4.0, <4.10.0 diff --git a/tests/tests_pytorch/loggers/test_tensorboard.py b/tests/tests_pytorch/loggers/test_tensorboard.py index 61e689831ac1a..2ee033f893340 100644 --- a/tests/tests_pytorch/loggers/test_tensorboard.py +++ b/tests/tests_pytorch/loggers/test_tensorboard.py @@ -109,7 +109,6 @@ def test_tensorboard_no_name(tmp_path, name): assert os.listdir(tmp_path / "version_0") -@mock.patch.dict(os.environ, {}, clear=True) def test_tensorboard_log_sub_dir(tmp_path): class TestLogger(TensorBoardLogger): # for reproducibility @@ -141,14 +140,15 @@ def name(self): trainer = Trainer(**trainer_args, logger=logger) assert trainer.logger.log_dir == os.path.join(explicit_save_dir, "name", "version", "sub_dir") - # test env var (`$`) handling - test_env_dir = "some_directory" - os.environ["TEST_ENV_DIR"] = test_env_dir - save_dir = "$TEST_ENV_DIR/tmp" - explicit_save_dir = f"{test_env_dir}/tmp" - logger = TestLogger(save_dir, sub_dir="sub_dir") - trainer = Trainer(**trainer_args, logger=logger) - assert trainer.logger.log_dir == os.path.join(explicit_save_dir, "name", "version", "sub_dir") + with mock.patch.dict(os.environ, {}): + # test env var (`$`) handling + test_env_dir = "some_directory" + os.environ["TEST_ENV_DIR"] = test_env_dir + save_dir = "$TEST_ENV_DIR/tmp" + explicit_save_dir = f"{test_env_dir}/tmp" + logger = TestLogger(save_dir, sub_dir="sub_dir") + trainer = Trainer(**trainer_args, logger=logger) + assert trainer.logger.log_dir == os.path.join(explicit_save_dir, "name", "version", "sub_dir") @pytest.mark.parametrize("step_idx", [10, None])