mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 21:30:22 +03:00
Remove _file_exists since only Pathy remotes are supported
This commit is contained in:
parent
e174294350
commit
d7c8747816
|
@ -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)
|
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:
|
def upload_file(src: Path, dest: Union[str, "FluidPath"]) -> None:
|
||||||
"""Upload a file.
|
"""Upload a file.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
||||||
from wasabi import msg
|
from wasabi import msg
|
||||||
|
|
||||||
from .._util import get_hash, get_checksum, upload_file, download_file
|
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 ...util import get_minor_version, ENV_VARS, check_bool_env_var
|
||||||
from ...git_info import GIT_VERSION
|
from ...git_info import GIT_VERSION
|
||||||
from ... import about
|
from ... import about
|
||||||
|
@ -43,7 +43,7 @@ class RemoteStorage:
|
||||||
if not loc.exists():
|
if not loc.exists():
|
||||||
raise IOError(f"Cannot push {loc}: does not exist.")
|
raise IOError(f"Cannot push {loc}: does not exist.")
|
||||||
url = self.make_url(path, command_hash, content_hash)
|
url = self.make_url(path, command_hash, content_hash)
|
||||||
if _file_exists(url):
|
if url.exists():
|
||||||
return url
|
return url
|
||||||
tmp: Path
|
tmp: Path
|
||||||
with make_tempdir() as tmp:
|
with make_tempdir() as tmp:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user