48
48
from lightning .pytorch .utilities .imports import _TORCHVISION_AVAILABLE
49
49
from lightning_utilities import compare_version
50
50
from lightning_utilities .test .warning import no_warning_call
51
+ from packaging .version import Version
51
52
from tensorboard .backend .event_processing import event_accumulator
52
53
from tensorboard .plugins .hparams .plugin_data_pb2 import HParamsPluginData
53
54
from torch .optim import SGD
@@ -64,6 +65,14 @@ def lazy_instance(*args, **kwargs):
64
65
return None
65
66
66
67
68
+ _xfail_python_ge_3_11_9 = pytest .mark .xfail (
69
+ # https://github.com/omni-us/jsonargparse/issues/484
70
+ Version (f"{ sys .version_info .major } .{ sys .version_info .minor } .{ sys .version_info .micro } " ) >= Version ("3.11.9" ),
71
+ strict = False ,
72
+ reason = "jsonargparse + Python 3.11.9 compatibility issue" ,
73
+ )
74
+
75
+
67
76
@contextmanager
68
77
def mock_subclasses (baseclass , * subclasses ):
69
78
"""Mocks baseclass so that it only has the given child subclasses."""
@@ -347,6 +356,7 @@ def test_save_to_log_dir_false_error():
347
356
)
348
357
349
358
359
+ @_xfail_python_ge_3_11_9
350
360
def test_lightning_cli_logger_save_config (cleandir ):
351
361
class LoggerSaveConfigCallback (SaveConfigCallback ):
352
362
def __init__ (self , * args , ** kwargs ) -> None :
@@ -736,6 +746,7 @@ def add_arguments_to_parser(self, parser):
736
746
assert cli .trainer .lr_scheduler_configs [0 ].scheduler .step_size == 50
737
747
738
748
749
+ @_xfail_python_ge_3_11_9
739
750
@pytest .mark .parametrize ("use_generic_base_class" , [False , True ])
740
751
def test_lightning_cli_optimizers_and_lr_scheduler_with_link_to (use_generic_base_class ):
741
752
class MyLightningCLI (LightningCLI ):
@@ -782,7 +793,7 @@ def __init__(self, optim1: dict, optim2: dict, scheduler: dict):
782
793
assert isinstance (cli .model .scheduler , torch .optim .lr_scheduler .ExponentialLR )
783
794
784
795
785
- @pytest . mark . skipif ( compare_version ( "jsonargparse" , operator . lt , "4.21.3" ), reason = "vulnerability with failing imports" )
796
+ @_xfail_python_ge_3_11_9
786
797
def test_lightning_cli_optimizers_and_lr_scheduler_with_callable_type ():
787
798
class TestModel (BoringModel ):
788
799
def __init__ (
@@ -953,6 +964,7 @@ def __init__(self, foo, bar=5):
953
964
self .bar = bar
954
965
955
966
967
+ @_xfail_python_ge_3_11_9
956
968
def test_lightning_cli_model_short_arguments ():
957
969
with mock .patch ("sys.argv" , ["any.py" , "fit" , "--model=BoringModel" ]), mock .patch (
958
970
"lightning.pytorch.Trainer._fit_impl"
@@ -977,6 +989,7 @@ def __init__(self, foo, bar=5):
977
989
self .bar = bar
978
990
979
991
992
+ @_xfail_python_ge_3_11_9
980
993
def test_lightning_cli_datamodule_short_arguments ():
981
994
# with set model
982
995
with mock .patch ("sys.argv" , ["any.py" , "fit" , "--data=BoringDataModule" ]), mock .patch (
@@ -1022,6 +1035,7 @@ def test_lightning_cli_datamodule_short_arguments():
1022
1035
assert cli .parser .groups ["data" ].group_class is BoringDataModule
1023
1036
1024
1037
1038
+ @_xfail_python_ge_3_11_9
1025
1039
@pytest .mark .parametrize ("use_class_path_callbacks" , [False , True ])
1026
1040
def test_callbacks_append (use_class_path_callbacks ):
1027
1041
"""This test validates registries are used when simplified command line are being used."""
@@ -1065,6 +1079,7 @@ def test_callbacks_append(use_class_path_callbacks):
1065
1079
assert all (t in callback_types for t in expected )
1066
1080
1067
1081
1082
+ @_xfail_python_ge_3_11_9
1068
1083
def test_optimizers_and_lr_schedulers_reload (cleandir ):
1069
1084
base = ["any.py" , "--trainer.max_epochs=1" ]
1070
1085
input = base + [
@@ -1096,6 +1111,7 @@ def test_optimizers_and_lr_schedulers_reload(cleandir):
1096
1111
LightningCLI (BoringModel , run = False )
1097
1112
1098
1113
1114
+ @_xfail_python_ge_3_11_9
1099
1115
def test_optimizers_and_lr_schedulers_add_arguments_to_parser_implemented_reload (cleandir ):
1100
1116
class TestLightningCLI (LightningCLI ):
1101
1117
def __init__ (self , * args ):
@@ -1349,6 +1365,7 @@ def test_cli_help_message():
1349
1365
assert "Implements Adam" in shorthand_help .getvalue ()
1350
1366
1351
1367
1368
+ @_xfail_python_ge_3_11_9
1352
1369
def test_cli_reducelronplateau ():
1353
1370
with mock .patch (
1354
1371
"sys.argv" , ["any.py" , "--optimizer=Adam" , "--lr_scheduler=ReduceLROnPlateau" , "--lr_scheduler.monitor=foo" ]
@@ -1359,6 +1376,7 @@ def test_cli_reducelronplateau():
1359
1376
assert config ["lr_scheduler" ]["scheduler" ].monitor == "foo"
1360
1377
1361
1378
1379
+ @_xfail_python_ge_3_11_9
1362
1380
def test_cli_configureoptimizers_can_be_overridden ():
1363
1381
class MyCLI (LightningCLI ):
1364
1382
def __init__ (self ):
@@ -1403,6 +1421,7 @@ def __init__(self, activation: torch.nn.Module = lazy_instance(torch.nn.LeakyReL
1403
1421
assert cli .model .activation is not model .activation
1404
1422
1405
1423
1424
+ @_xfail_python_ge_3_11_9
1406
1425
def test_ddpstrategy_instantiation_and_find_unused_parameters (mps_count_0 ):
1407
1426
strategy_default = lazy_instance (DDPStrategy , find_unused_parameters = True )
1408
1427
with mock .patch ("sys.argv" , ["any.py" , "--trainer.strategy.process_group_backend=group" ]):
@@ -1418,6 +1437,7 @@ def test_ddpstrategy_instantiation_and_find_unused_parameters(mps_count_0):
1418
1437
assert strategy_default is not cli .config_init .trainer .strategy
1419
1438
1420
1439
1440
+ @_xfail_python_ge_3_11_9
1421
1441
def test_cli_logger_shorthand ():
1422
1442
with mock .patch ("sys.argv" , ["any.py" ]):
1423
1443
cli = LightningCLI (TestModel , run = False , trainer_defaults = {"logger" : False })
@@ -1448,6 +1468,7 @@ def _test_logger_init_args(logger_name, init, unresolved=None):
1448
1468
assert data ["dict_kwargs" ] == unresolved
1449
1469
1450
1470
1471
+ @_xfail_python_ge_3_11_9
1451
1472
def test_comet_logger_init_args ():
1452
1473
_test_logger_init_args (
1453
1474
"CometLogger" ,
@@ -1463,6 +1484,7 @@ def test_comet_logger_init_args():
1463
1484
strict = False ,
1464
1485
reason = "TypeError on Windows when parsing" ,
1465
1486
)
1487
+ @_xfail_python_ge_3_11_9
1466
1488
def test_neptune_logger_init_args ():
1467
1489
_test_logger_init_args (
1468
1490
"NeptuneLogger" ,
@@ -1471,6 +1493,7 @@ def test_neptune_logger_init_args():
1471
1493
)
1472
1494
1473
1495
1496
+ @_xfail_python_ge_3_11_9
1474
1497
def test_tensorboard_logger_init_args ():
1475
1498
_test_logger_init_args (
1476
1499
"TensorBoardLogger" ,
@@ -1482,6 +1505,7 @@ def test_tensorboard_logger_init_args():
1482
1505
)
1483
1506
1484
1507
1508
+ @_xfail_python_ge_3_11_9
1485
1509
def test_wandb_logger_init_args ():
1486
1510
_test_logger_init_args (
1487
1511
"WandbLogger" ,
@@ -1566,6 +1590,7 @@ def __init__(self, a_func: Callable = torch.nn.Softmax):
1566
1590
assert "a_func: torch.nn.Softmax" in out .getvalue ()
1567
1591
1568
1592
1593
+ @_xfail_python_ge_3_11_9
1569
1594
def test_pytorch_profiler_init_args ():
1570
1595
from lightning .pytorch .profilers import Profiler , PyTorchProfiler
1571
1596
0 commit comments