|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | | -import errno |
15 | | -import operator |
16 | 14 | import os |
17 | | -import re |
18 | 15 | from unittest import mock |
19 | 16 | from unittest.mock import ANY, Mock |
20 | 17 |
|
21 | 18 | import pytest |
22 | 19 | import torch |
23 | | -from lightning_utilities.core.imports import compare_version |
24 | 20 |
|
25 | 21 | from lightning.pytorch import Trainer |
26 | 22 | from lightning.pytorch.callbacks import Callback, ModelCheckpoint |
@@ -109,31 +105,6 @@ def test_hpc_max_ckpt_version(tmp_path): |
109 | 105 | ) |
110 | 106 |
|
111 | 107 |
|
112 | | -def test_local_cross_device_checkpoint(tmpdir): |
113 | | - """Test that the _CheckpointConnector can write local cross-device files or raises an error if fsspec<2025.5.0.""" |
114 | | - model = BoringModel() |
115 | | - # hardcoding dir since `tmp_path` can be windows path |
116 | | - trainer = Trainer( |
117 | | - default_root_dir="memory://test_ckpt_for_fsspec", limit_train_batches=1, limit_val_batches=1, max_epochs=1 |
118 | | - ) |
119 | | - trainer.fit(model) |
120 | | - # Simulate the behavior of fsspec when writing to a local file system but other device. |
121 | | - with ( |
122 | | - mock.patch("os.rename", side_effect=OSError(errno.EXDEV, "Invalid cross-device link")), |
123 | | - mock.patch("os.chmod", side_effect=PermissionError("Operation not permitted")), |
124 | | - ): |
125 | | - if compare_version("fsspec", operator.lt, "2025.5.0"): |
126 | | - with pytest.raises( |
127 | | - RuntimeError, |
128 | | - match=re.escape( |
129 | | - 'Upgrade fsspec to enable cross-device local checkpoints: pip install "fsspec[http]>=2025.5.0"' |
130 | | - ), |
131 | | - ): |
132 | | - trainer.save_checkpoint(tmpdir + "/test_ckpt_for_fsspec/hpc_ckpt.ckpt") |
133 | | - else: |
134 | | - trainer.save_checkpoint(tmpdir + "/test_ckpt_for_fsspec/hpc_ckpt.ckpt") |
135 | | - |
136 | | - |
137 | 108 | def test_ckpt_for_fsspec(): |
138 | 109 | """Test that the _CheckpointConnector is able to write to fsspec file systems.""" |
139 | 110 | model = BoringModel() |
|
0 commit comments