From 465785a672ea74e1c2b7d56440abdb9e7736c462 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 4 Sep 2020 21:15:55 +0200 Subject: [PATCH] Fix project pull and push --- spacy/cli/project/pull.py | 3 ++- spacy/cli/project/push.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spacy/cli/project/pull.py b/spacy/cli/project/pull.py index 655e2f459..edcd410bd 100644 --- a/spacy/cli/project/pull.py +++ b/spacy/cli/project/pull.py @@ -40,5 +40,6 @@ def project_pull(project_dir: Path, remote: str, *, verbose: bool = False): url = storage.pull(output_path, command_hash=cmd_hash) yield url, output_path - if cmd.get("outputs") and all(loc.exists() for loc in cmd["outputs"]): + out_locs = [project_dir / out for out in cmd.get("outputs", [])] + if all(loc.exists() for loc in out_locs): update_lockfile(project_dir, cmd) diff --git a/spacy/cli/project/push.py b/spacy/cli/project/push.py index fcee2231a..26495412d 100644 --- a/spacy/cli/project/push.py +++ b/spacy/cli/project/push.py @@ -45,10 +45,19 @@ def project_push(project_dir: Path, remote: str): ) for output_path in cmd.get("outputs", []): output_loc = project_dir / output_path - if output_loc.exists(): + if output_loc.exists() and _is_not_empty_dir(output_loc): url = storage.push( output_path, command_hash=cmd_hash, content_hash=get_content_hash(output_loc), ) yield output_path, url + + +def _is_not_empty_dir(loc: Path): + if not loc.is_dir(): + return True + elif any(_is_not_empty_dir(child) for child in loc.iterdir()): + return True + else: + return False