From 9cddb2a634edeb295966a3ebb84e2fb86c682a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Redzy=C5=84ski?= Date: Wed, 10 Nov 2021 23:19:38 +0100 Subject: [PATCH 1/2] argparse: dont override cmd Related: #6956, https://bugs.python.org/issue45235 --- dvc/command/experiments.py | 4 ++-- dvc/command/run.py | 4 ++-- dvc/command/stage.py | 4 ++-- tests/func/test_cli.py | 2 +- tests/unit/command/test_experiments.py | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py index eb136f09ce..1ca4d1fe5f 100644 --- a/dvc/command/experiments.py +++ b/dvc/command/experiments.py @@ -814,7 +814,7 @@ class CmdExperimentsInit(CmdBase): def run(self): from dvc.command.stage import parse_cmd - cmd = parse_cmd(self.args.cmd) + cmd = parse_cmd(self.args.command) if not self.args.interactive and not cmd: raise InvalidArgumentError("command is not specified") @@ -1416,7 +1416,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) experiments_init_parser.add_argument( - "cmd", + "command", nargs=argparse.REMAINDER, help="Command to execute.", metavar="command", diff --git a/dvc/command/run.py b/dvc/command/run.py index 0798940617..e511d192db 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -23,7 +23,7 @@ def run(self): self.args.outs_persist_no_cache, self.args.checkpoints, self.args.params, - self.args.cmd, + self.args.command, ] ): # pragma: no cover logger.error( @@ -36,7 +36,7 @@ def run(self): kwargs = vars(self.args) kwargs.update( { - "cmd": parse_cmd(self.args.cmd), + "cmd": parse_cmd(self.args.command), "fname": kwargs.pop("file"), "no_exec": (self.args.no_exec or bool(self.args.checkpoints)), "run_cache": not kwargs.pop("no_run_cache"), diff --git a/dvc/command/stage.py b/dvc/command/stage.py index aab3c1c652..f8afe45c5b 100644 --- a/dvc/command/stage.py +++ b/dvc/command/stage.py @@ -129,7 +129,7 @@ def run(self): kwargs = vars(self.args) kwargs.update( { - "cmd": parse_cmd(kwargs.pop("cmd")), + "cmd": parse_cmd(kwargs.pop("command")), "params": parse_params(self.args.params), } ) @@ -281,7 +281,7 @@ def _add_common_args(parser): ), ) parser.add_argument( - "cmd", + "command", nargs=argparse.REMAINDER, help="Command to execute.", metavar="command", diff --git a/tests/func/test_cli.py b/tests/func/test_cli.py index 0792761550..e1cb844d36 100644 --- a/tests/func/test_cli.py +++ b/tests/func/test_cli.py @@ -66,7 +66,7 @@ def test(self): self.assertEqual(args.outs, [out1, out2]) self.assertEqual(args.outs_no_cache, [out_no_cache1, out_no_cache2]) self.assertEqual(args.file, fname) - self.assertEqual(args.cmd, [cmd, arg1, arg2]) + self.assertEqual(args.command, [cmd, arg1, arg2]) cmd_cls.repo.close() diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py index 3b00c47167..42cb9dd4b2 100644 --- a/tests/unit/command/test_experiments.py +++ b/tests/unit/command/test_experiments.py @@ -590,3 +590,4 @@ def test_experiments_init_config(dvc, mocker): "plots": "plots", "live": "dvclive", } + assert m.call_args[1]["overrides"] == {"cmd": "cmd"} From 283444c2d898ed31986cc03b9093b44503dde203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Redzy=C5=84ski?= Date: Wed, 10 Nov 2021 23:20:38 +0100 Subject: [PATCH 2/2] gha: limit python version to 3.9.7 Related: https://bugs.python.org/issue45235 Closes: #6956 --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index deb613aa83..403a002cd0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -45,7 +45,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest, macos-latest] - pyv: ["3.7", "3.8", "3.9", "3.10"] + pyv: ["3.7", "3.8", "3.9.7", "3.10"] exclude: # no wheels for pygit2 yet - os: windows-latest