Remove _file_exists since only Pathy remotes are supported

This commit is contained in:
Adriane Boyd 2022-11-25 11:28:13 +01:00
parent e174294350
commit d7c8747816
2 changed files with 2 additions and 28 deletions

View File

@ -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.

View File

@ -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: