Skip to content

Commit

Permalink
Merge branch 'main' of github.com:latchbio/latch
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanAbd committed Jan 25, 2023
2 parents 70f4d23 + 29caa84 commit 8560c5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 7 additions & 8 deletions latch/types/directory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os import PathLike
from typing import Annotated, Optional, Type, Union, get_args, get_origin
from typing import Optional, Type, Union, get_args, get_origin

from flytekit.core.annotation import FlyteAnnotation
from flytekit.core.context_manager import FlyteContext, FlyteContextManager
Expand Down Expand Up @@ -56,21 +56,20 @@ def __init__(
remote_path: Optional[PathLike] = None,
**kwargs,
):

if path is None:
raise ValueError("Unable to instantiate LatchDir with None")

# Cast PathLike objects so that LatchDir has consistent JSON
# representation.
self.path = str(path)

if _is_valid_url(path) and remote_path is None:
self._remote_directory = str(path)
if _is_valid_url(self.path) and remote_path is None:
self._remote_directory = self.path
else:
self._remote_directory = None if remote_path is None else str(remote_path)

if kwargs.get("downloader") is not None:
super().__init__(path, kwargs["downloader"], remote_path)
super().__init__(self.path, kwargs["downloader"], self._remote_directory)
else:

def downloader():
Expand All @@ -89,7 +88,7 @@ def downloader():
is_multipart=True,
)

super().__init__(path, downloader, self._remote_directory)
super().__init__(self.path, downloader, self._remote_directory)

@property
def local_path(self) -> str:
Expand All @@ -99,7 +98,7 @@ def local_path(self) -> str:
# user wishing to access the file without using `open`.
self.__fspath__()

return self.path
return str(self.path)

@property
def remote_path(self) -> Optional[str]:
Expand Down Expand Up @@ -149,7 +148,7 @@ def to_python_value(
"Casting from Pathlike to LatchDir is currently not supported."
)


while get_origin(expected_python_type) == Annotated:
expected_python_type = get_args(expected_python_type)[0]

Expand Down
8 changes: 4 additions & 4 deletions latch/types/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def __init__(
# representation.
self.path = str(path)

if _is_valid_url(path) and remote_path is None:
if _is_valid_url(self.path) and remote_path is None:
self._remote_path = str(path)
else:
self._remote_path = None if remote_path is None else str(remote_path)

if kwargs.get("downloader") is not None:
super().__init__(path, kwargs["downloader"], remote_path)
super().__init__(self.path, kwargs["downloader"], self._remote_path)
else:

def downloader():
Expand All @@ -91,7 +91,7 @@ def downloader():
is_multipart=False,
)

super().__init__(path, downloader, self._remote_path)
super().__init__(self.path, downloader, self._remote_path)

@property
def local_path(self) -> str:
Expand All @@ -101,7 +101,7 @@ def local_path(self) -> str:
# user wishing to access the file without using `open`.
self.__fspath__()

return self.path
return str(self.path)

@property
def remote_path(self) -> Optional[str]:
Expand Down

0 comments on commit 8560c5e

Please sign in to comment.