From aeebc6678dfa6612fe2a59a50e221324d92e27d9 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 26 Aug 2020 10:26:57 +0200 Subject: [PATCH] Small cleanup and adjustments --- spacy/cli/init_config.py | 2 ++ spacy/cli/project/assets.py | 12 +----------- spacy/cli/project/run.py | 3 +++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/spacy/cli/init_config.py b/spacy/cli/init_config.py index 723068106..b5335df51 100644 --- a/spacy/cli/init_config.py +++ b/spacy/cli/init_config.py @@ -154,6 +154,8 @@ def save_config(config: Config, output_file: Path, is_stdout: bool = False) -> N if is_stdout: print(config.to_str()) else: + if not output_file.parent.exists(): + output_file.parent.mkdir(parents=True) config.to_disk(output_file, interpolate=False) msg.good("Saved config", output_file) msg.text("You can now add your data and train your model:") diff --git a/spacy/cli/project/assets.py b/spacy/cli/project/assets.py index f78c4f617..e33a82acc 100644 --- a/spacy/cli/project/assets.py +++ b/spacy/cli/project/assets.py @@ -10,15 +10,6 @@ from .._util import project_cli, Arg, PROJECT_FILE, load_project_config, get_che from .._util import download_file, git_sparse_checkout -# TODO: find a solution for caches -# CACHES = [ -# Path.home() / ".torch", -# Path.home() / ".caches" / "torch", -# os.environ.get("TORCH_HOME"), -# Path.home() / ".keras", -# ] - - @project_cli.command("assets") def project_assets_cli( # fmt: off @@ -99,7 +90,6 @@ def fetch_asset( RETURNS (Optional[Path]): The path to the fetched asset or None if fetching the asset failed. """ - # TODO: add support for caches dest_path = (project_path / dest).resolve() if dest_path.exists() and checksum: # If there's already a file, check for checksum @@ -134,7 +124,7 @@ def convert_asset_url(url: str) -> str: RETURNS (str): The converted URL. """ # If the asset URL is a regular GitHub URL it's likely a mistake - if re.match(r"(http(s?)):\/\/github.com", url): + if re.match(r"(http(s?)):\/\/github.com", url) and "releases/download" not in url: converted = url.replace("github.com", "raw.githubusercontent.com") converted = re.sub(r"/(tree|blob)/", "/", converted) msg.warn( diff --git a/spacy/cli/project/run.py b/spacy/cli/project/run.py index 6e1deeeee..7b579314b 100644 --- a/spacy/cli/project/run.py +++ b/spacy/cli/project/run.py @@ -101,6 +101,9 @@ def print_run_help(project_dir: Path, subcommand: Optional[str] = None) -> None: print(f"For command details, run: {help_cmd}") else: print("") + title = config.get("title") + if title: + print(f"{title}\n") if config_commands: print(f"Available commands in {PROJECT_FILE}") print(f"Usage: {COMMAND} project run [COMMAND] {project_loc}")