diff --git a/src/lightning/pytorch/cli.py b/src/lightning/pytorch/cli.py index 1942ce6d156e5..73525f748ce07 100644 --- a/src/lightning/pytorch/cli.py +++ b/src/lightning/pytorch/cli.py @@ -483,9 +483,9 @@ def link_optimizers_and_lr_schedulers(parser: LightningArgumentParser) -> None: def parse_arguments(self, parser: LightningArgumentParser, args: ArgsType) -> None: """Parses command line arguments and stores it in ``self.config``.""" if args is not None and len(sys.argv) > 1: - raise ValueError( + rank_zero_warn( "LightningCLI's args parameter is intended to run from within Python like if it were from the command " - "line. To prevent mistakes it is not allowed to provide both args and command line arguments, got: " + "line. To prevent mistakes it is not recommended to provide both args and command line arguments, got: " f"sys.argv[1:]={sys.argv[1:]}, args={args}." ) if isinstance(args, (dict, Namespace)): diff --git a/tests/tests_pytorch/test_cli.py b/tests/tests_pytorch/test_cli.py index 34bbc4f4d19ba..eb95a074b6d78 100644 --- a/tests/tests_pytorch/test_cli.py +++ b/tests/tests_pytorch/test_cli.py @@ -1538,8 +1538,6 @@ def test_lightning_cli_with_args_given(args): assert cli.model.foo == 456 -def test_lightning_cli_args_and_sys_argv_exception(): - with mock.patch("sys.argv", ["", "--model.foo=456"]), pytest.raises( - ValueError, match="LightningCLI's args parameter " - ): +def test_lightning_cli_args_and_sys_argv_warning(): + with mock.patch("sys.argv", ["", "--model.foo=456"]), pytest.warns(Warning, match="LightningCLI's args parameter "): LightningCLI(TestModel, run=False, args=["--model.foo=789"])