From d7c87478168377a917766f831681f02e0d308f10 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Fri, 25 Nov 2022 11:28:13 +0100 Subject: [PATCH] Remove _file_exists since only Pathy remotes are supported --- spacy/cli/_util.py | 26 -------------------------- spacy/cli/project/remote_storage.py | 4 ++-- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/spacy/cli/_util.py b/spacy/cli/_util.py index 62aa56525..7ce006108 100644 --- a/spacy/cli/_util.py +++ b/spacy/cli/_util.py @@ -331,32 +331,6 @@ def import_code(code_path: Optional[Union[Path, str]]) -> None: msg.fail(f"Couldn't load Python code: {code_path}", e, exits=1) -def _file_exists(src: Union[str, "FluidPath"]) -> bool: - """Check if a (remote) file exists, if possible. - - src (str / FluidPath): The URL to check. - """ - try: - from pathy import Pathy - - if isinstance(src, (Pathy, Path)): - if src.exists(): - return True - except Exception: - pass - - try: - import smart_open - - with smart_open.open(src, mode="rb", compression="disable") as input_file: - pass - return True - except Exception: - pass - - return False - - def upload_file(src: Path, dest: Union[str, "FluidPath"]) -> None: """Upload a file. diff --git a/spacy/cli/project/remote_storage.py b/spacy/cli/project/remote_storage.py index 1fb750f88..076541580 100644 --- a/spacy/cli/project/remote_storage.py +++ b/spacy/cli/project/remote_storage.py @@ -8,7 +8,7 @@ from pathlib import Path from wasabi import msg from .._util import get_hash, get_checksum, upload_file, download_file -from .._util import ensure_pathy, make_tempdir, _file_exists +from .._util import ensure_pathy, make_tempdir from ...util import get_minor_version, ENV_VARS, check_bool_env_var from ...git_info import GIT_VERSION from ... import about @@ -43,7 +43,7 @@ class RemoteStorage: if not loc.exists(): raise IOError(f"Cannot push {loc}: does not exist.") url = self.make_url(path, command_hash, content_hash) - if _file_exists(url): + if url.exists(): return url tmp: Path with make_tempdir() as tmp: