From 6678bd80c22de22ee4497bc68c6c98480f481198 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Sat, 27 Jun 2020 20:57:26 +0200 Subject: [PATCH] Check if deps exist in non-DVC commands --- spacy/cli/project.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spacy/cli/project.py b/spacy/cli/project.py index d1c6e603d..d59537bb8 100644 --- a/spacy/cli/project.py +++ b/spacy/cli/project.py @@ -281,8 +281,15 @@ def project_run(project_dir: Path, subcommand: str, *dvc_args) -> None: dvc_cmd = ["dvc", "repro", subcommand, *dvc_args] run_command(dvc_cmd) else: + cmd = commands[subcommand] + # Deps in non-DVC commands aren't tracked, but if they're defined, + # make sure they exist before running the command + for dep in cmd.get("deps", []): + if not (project_dir / dep).exists(): + err = f"Missing dependency specified by command '{subcommand}': {dep}" + msg.fail(err, exits=1) with working_dir(project_dir): - run_commands(commands[subcommand]["script"], variables) + run_commands(cmd["script"], variables) @project_cli.command("exec")