Skip to content

Commit 71e63c8

Browse files
committed
Skipped failing tests on torch<2
1 parent 328c281 commit 71e63c8

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

tests/ignite/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import torch
2+
from packaging.version import Version
23

34
from ignite.distributed.comp_models.base import _torch_version_gt_112
45

56

7+
_torch_version_lt_2 = Version(torch.__version__) < Version("2")
8+
9+
610
def is_mps_available_and_functional():
711
if not _torch_version_gt_112:
812
return False

tests/ignite/contrib/engines/test_common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
)
2828
from ignite.engine import Engine, Events
2929
from ignite.handlers import DiskSaver, TerminateOnNan
30+
from tests.ignite import _torch_version_lt_2
3031

3132

3233
class DummyModel(nn.Module):
@@ -577,6 +578,7 @@ def test_setup_wandb_logging(dirname):
577578
setup_wandb_logging(MagicMock())
578579

579580

581+
@pytest.mark.skipif(_torch_version_lt_2, reason="CleamML tests are failing on torch<2")
580582
def test_setup_clearml_logging():
581583
handlers.clearml_logger.ClearMLLogger.set_bypass_mode(True)
582584

tests/ignite/distributed/test_auto.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import ignite.distributed as idist
1414
from ignite.distributed.auto import auto_dataloader, auto_model, auto_optim, DistributedProxySampler
15-
from tests.ignite import is_mps_available_and_functional
15+
from tests.ignite import is_mps_available_and_functional, _torch_version_lt_2
1616

1717

1818
class DummyDS(Dataset):
@@ -310,8 +310,9 @@ def test_dist_proxy_sampler():
310310
with pytest.raises(TypeError, match=r"Argument sampler should be instance of torch Sampler"):
311311
DistributedProxySampler(None)
312312

313-
with pytest.raises(TypeError, match=r"Argument sampler should have length"):
314-
DistributedProxySampler(Sampler())
313+
if not _torch_version_lt_2:
314+
with pytest.raises(TypeError, match=r"Argument sampler should have length"):
315+
DistributedProxySampler(Sampler())
315316

316317
with pytest.raises(TypeError, match=r"Argument sampler must not be a distributed sampler already"):
317318
DistributedProxySampler(DistributedSampler(sampler, num_replicas=num_replicas, rank=0))

tests/ignite/handlers/test_clearml_logger.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
WeightsHistHandler,
2525
WeightsScalarHandler,
2626
)
27+
from tests.ignite import _torch_version_lt_2
2728

2829

2930
def test_no_clearml():
@@ -716,6 +717,7 @@ def weight_selector(n, _):
716717
assert mock_logger.grad_helper.add_histogram.call_count == 2
717718

718719

720+
@pytest.mark.skipif(_torch_version_lt_2, reason="CleamML tests are failing on torch<2")
719721
def test_integration(dirname):
720722
n_epochs = 5
721723
data = list(range(50))
@@ -743,6 +745,7 @@ def dummy_handler(engine, logger, event_name):
743745
logger.close()
744746

745747

748+
@pytest.mark.skipif(_torch_version_lt_2, reason="CleamML tests are failing on torch<2")
746749
def test_integration_as_context_manager(dirname):
747750
n_epochs = 5
748751
data = list(range(50))
@@ -768,6 +771,7 @@ def dummy_handler(engine, logger, event_name):
768771
trainer.run(data, max_epochs=n_epochs)
769772

770773

774+
@pytest.mark.skipif(_torch_version_lt_2, reason="CleamML tests are failing on torch<2")
771775
def test_clearml_logger_getattr_method(dirname):
772776
with pytest.warns(UserWarning, match="ClearMLSaver: running in bypass mode"):
773777
ClearMLLogger.set_bypass_mode(True)
@@ -789,6 +793,7 @@ def test_clearml_logger_getattr_method(dirname):
789793
logger.close()
790794

791795

796+
@pytest.mark.skipif(_torch_version_lt_2, reason="CleamML tests are failing on torch<2")
792797
def test_clearml_logger_get_task_bypass(dirname):
793798
with pytest.warns(UserWarning, match="ClearMLSaver: running in bypass mode"):
794799
ClearMLLogger.set_bypass_mode(True)

0 commit comments

Comments
 (0)