From e2265f08645a91bc8c415d743e94b1e47d01246e Mon Sep 17 00:00:00 2001 From: Paul O'Leary McCann Date: Mon, 12 Sep 2022 18:24:55 +0900 Subject: [PATCH] Handle case in DVC where no commands are appropriate If only have commands with no deps or outputs (admittedly unlikely), you get a weird error about the dvc file not existing. This gives explicit output instead. --- spacy/cli/project/dvc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spacy/cli/project/dvc.py b/spacy/cli/project/dvc.py index 2cff9b9f6..f45911c5a 100644 --- a/spacy/cli/project/dvc.py +++ b/spacy/cli/project/dvc.py @@ -138,6 +138,16 @@ def update_dvc_config( dvc_cmd.append("--always-changed") full_cmd = [*dvc_cmd, *deps_cmd, *outputs_cmd, *outputs_nc_cmd, *project_cmd] dvc_commands.append(full_cmd) + + if not dvc_commands: + # If we don't check for this, then there will be an error when reading the + # config, since DVC wouldn't create it. + msg.fail( + "No usable commands for DVC found. This can happen if none of your " + "commands have dependencies or outputs.", + exits=1, + ) + with working_dir(path): for c in dvc_commands: dvc_command = ["dvc", *c]