mirror of https://github.com/explosion/spaCy.git
throw warning (instead of crashing) when temp dir can't be cleaned
This commit is contained in:
parent
efe7eb71f2
commit
894b8e7ff6
|
@ -243,8 +243,8 @@ def project_clone(
|
||||||
raise RuntimeError(f"Could not clone the repo '{repo}' into the temp dir '{tmp_dir}'.")
|
raise RuntimeError(f"Could not clone the repo '{repo}' into the temp dir '{tmp_dir}'.")
|
||||||
with (tmp_dir / ".git" / "info" / "sparse-checkout").open("w") as f:
|
with (tmp_dir / ".git" / "info" / "sparse-checkout").open("w") as f:
|
||||||
f.write(name)
|
f.write(name)
|
||||||
run_command(["git", "-C", tmp_dir, "fetch"])
|
run_command(["git", "-C", str(tmp_dir), "fetch"])
|
||||||
run_command(["git", "-C", tmp_dir, "checkout"])
|
run_command(["git", "-C", str(tmp_dir), "checkout"])
|
||||||
shutil.move(str(tmp_dir / Path(name).name), str(project_dir))
|
shutil.move(str(tmp_dir / Path(name).name), str(project_dir))
|
||||||
msg.good(f"Cloned project '{name}' from {repo}")
|
msg.good(f"Cloned project '{name}' from {repo}")
|
||||||
for sub_dir in DIRS:
|
for sub_dir in DIRS:
|
||||||
|
|
|
@ -132,6 +132,7 @@ class Warnings(object):
|
||||||
"are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.")
|
"are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.")
|
||||||
|
|
||||||
# TODO: fix numbering after merging develop into master
|
# TODO: fix numbering after merging develop into master
|
||||||
|
W091 = ("Could not clean/remove the temp directory at {dir}.")
|
||||||
W092 = ("Ignoring annotations for sentence starts, as dependency heads are set.")
|
W092 = ("Ignoring annotations for sentence starts, as dependency heads are set.")
|
||||||
W093 = ("Could not find any data to train the {name} on. Is your "
|
W093 = ("Could not find any data to train the {name} on. Is your "
|
||||||
"input data correctly formatted ?")
|
"input data correctly formatted ?")
|
||||||
|
|
|
@ -467,7 +467,10 @@ def make_tempdir():
|
||||||
"""
|
"""
|
||||||
d = Path(tempfile.mkdtemp())
|
d = Path(tempfile.mkdtemp())
|
||||||
yield d
|
yield d
|
||||||
shutil.rmtree(str(d))
|
try:
|
||||||
|
shutil.rmtree(str(d))
|
||||||
|
except PermissionError:
|
||||||
|
warnings.warn(Warnings.W091.format(dir=d))
|
||||||
|
|
||||||
|
|
||||||
def get_hash(data) -> str:
|
def get_hash(data) -> str:
|
||||||
|
|
Loading…
Reference in New Issue