mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Make project pull order insensitive (#6131)
This commit is contained in:
parent
e2ffe51fb5
commit
17a6b0a173
|
@ -27,19 +27,32 @@ def project_pull_cli(
|
||||||
|
|
||||||
|
|
||||||
def project_pull(project_dir: Path, remote: str, *, verbose: bool = False):
|
def project_pull(project_dir: Path, remote: str, *, verbose: bool = False):
|
||||||
|
# TODO: We don't have tests for this :(. It would take a bit of mockery to
|
||||||
|
# set up. I guess see if it breaks first?
|
||||||
config = load_project_config(project_dir)
|
config = load_project_config(project_dir)
|
||||||
if remote in config.get("remotes", {}):
|
if remote in config.get("remotes", {}):
|
||||||
remote = config["remotes"][remote]
|
remote = config["remotes"][remote]
|
||||||
storage = RemoteStorage(project_dir, remote)
|
storage = RemoteStorage(project_dir, remote)
|
||||||
for cmd in config.get("commands", []):
|
commands = list(config.get("commands", []))
|
||||||
deps = [project_dir / dep for dep in cmd.get("deps", [])]
|
# We use a while loop here because we don't know how the commands
|
||||||
if any(not dep.exists() for dep in deps):
|
# will be ordered. A command might need dependencies from one that's later
|
||||||
continue
|
# in the list.
|
||||||
cmd_hash = get_command_hash("", "", deps, cmd["script"])
|
while commands:
|
||||||
for output_path in cmd.get("outputs", []):
|
for i, cmd in enumerate(list(commands)):
|
||||||
url = storage.pull(output_path, command_hash=cmd_hash)
|
deps = [project_dir / dep for dep in cmd.get("deps", [])]
|
||||||
yield url, output_path
|
if all(dep.exists() for dep in deps):
|
||||||
|
cmd_hash = get_command_hash("", "", deps, cmd["script"])
|
||||||
|
for output_path in cmd.get("outputs", []):
|
||||||
|
url = storage.pull(output_path, command_hash=cmd_hash)
|
||||||
|
yield url, output_path
|
||||||
|
|
||||||
out_locs = [project_dir / out for out in cmd.get("outputs", [])]
|
out_locs = [project_dir / out for out in cmd.get("outputs", [])]
|
||||||
if all(loc.exists() for loc in out_locs):
|
if all(loc.exists() for loc in out_locs):
|
||||||
update_lockfile(project_dir, cmd)
|
update_lockfile(project_dir, cmd)
|
||||||
|
# We remove the command from the list here, and break, so that
|
||||||
|
# we iterate over the loop again.
|
||||||
|
commands.remove(i)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# If we didn't break the for loop, break the while loop.
|
||||||
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user