Merge branch 'develop' of https://github.com/explosion/spaCy into develop

This commit is contained in:
Matthew Honnibal 2020-08-27 19:47:26 +02:00
commit c558ca4485

View File

@ -6,6 +6,7 @@ from wasabi import msg
import srsly import srsly
import hashlib import hashlib
import typer import typer
from click import NoSuchOption
from typer.main import get_command from typer.main import get_command
from contextlib import contextmanager from contextlib import contextmanager
from thinc.config import Config, ConfigValidationError from thinc.config import Config, ConfigValidationError
@ -72,9 +73,10 @@ def parse_config_overrides(args: List[str]) -> Dict[str, Any]:
opt = args.pop(0) opt = args.pop(0)
err = f"Invalid CLI argument '{opt}'" err = f"Invalid CLI argument '{opt}'"
if opt.startswith("--"): # new argument if opt.startswith("--"): # new argument
orig_opt = opt
opt = opt.replace("--", "") opt = opt.replace("--", "")
if "." not in opt: if "." not in opt:
msg.fail(f"{err}: can't override top-level section", exits=1) raise NoSuchOption(orig_opt)
if "=" in opt: # we have --opt=value if "=" in opt: # we have --opt=value
opt, value = opt.split("=", 1) opt, value = opt.split("=", 1)
opt = opt.replace("-", "_") opt = opt.replace("-", "_")
@ -262,6 +264,7 @@ def upload_file(src: Path, dest: Union[str, "Pathy"]) -> None:
url (str): The destination URL to upload to. url (str): The destination URL to upload to.
""" """
import smart_open import smart_open
dest = str(dest) dest = str(dest)
with smart_open.open(dest, mode="wb") as output_file: with smart_open.open(dest, mode="wb") as output_file:
with src.open(mode="rb") as input_file: with src.open(mode="rb") as input_file:
@ -277,6 +280,7 @@ def download_file(src: Union[str, "Pathy"], dest: Path, *, force: bool = False)
If False, the download will be skipped. If False, the download will be skipped.
""" """
import smart_open import smart_open
if dest.exists() and not force: if dest.exists() and not force:
return None return None
src = str(src) src = str(src)