Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cosmos_framework/utils/easy_io/backends/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def isfile(self, filepath: Union[str, Path]) -> bool:
pass

@abstractmethod
def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> str:
def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> Union[str, Path]:
pass

@abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions cosmos_framework/utils/easy_io/backends/boto3_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def join_path(
self,
filepath: Union[str, Path],
*filepaths: Union[str, Path],
) -> str:
) -> Union[str, Path]:
r"""Concatenate all file paths.

Join one or more filepath components intelligently. The return value
Expand All @@ -294,7 +294,7 @@ def join_path(
filepath (str or Path): Path to be concatenated.

Returns:
str: The result after concatenation.
str or Path: The result after concatenation.

Examples:
>>> backend = Boto3Backend()
Expand Down
2 changes: 1 addition & 1 deletion cosmos_framework/utils/easy_io/backends/http_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def isdir(self, filepath: Union[str, Path]) -> bool:
def isfile(self, filepath: Union[str, Path]) -> bool:
raise NotImplementedError(f"isfile not supported in {self.name}")

def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> str:
def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> Union[str, Path]:
raise NotImplementedError(f"join_path not supported in {self.name}")

@contextmanager
Expand Down
10 changes: 6 additions & 4 deletions cosmos_framework/utils/easy_io/backends/local_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def isfile(self, filepath: Union[str, Path]) -> bool:
"""
return osp.isfile(filepath)

def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> str:
def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> Union[str, Path]:
r"""Concatenate all file paths.

Join one or more filepath components intelligently. The return value
Expand All @@ -197,7 +197,7 @@ def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) ->
filepath (str or Path): Path to be concatenated.

Returns:
str: The result of concatenation.
str or Path: The result of concatenation. Returns a Path if any input is a Path.

Examples:
>>> backend = LocalBackend()
Expand All @@ -207,8 +207,10 @@ def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) ->
>>> backend.join_path(filepath1, filepath2, filepath3)
'/path/of/dir/dir2/path/of/file'
"""
# TODO, if filepath or filepaths are Path, should return Path
return osp.join(filepath, *filepaths)
result = osp.join(filepath, *filepaths)
if isinstance(filepath, Path) or any(isinstance(p, Path) for p in filepaths):
return Path(result)
return result

@contextmanager
def get_local_path(
Expand Down
4 changes: 2 additions & 2 deletions cosmos_framework/utils/easy_io/backends/msc_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def join_path(
self,
filepath: Union[str, Path],
*filepaths: Union[str, Path],
) -> str:
) -> Union[str, Path]:
r"""Concatenate all file paths.

Join one or more filepath components intelligently. The return value
Expand All @@ -564,7 +564,7 @@ def join_path(
filepath (str or Path): Path to be concatenated.

Returns:
str: The result after concatenation.
str or Path: The result after concatenation.

Examples:
>>> backend = MSCBackend()
Expand Down
2 changes: 1 addition & 1 deletion cosmos_framework/utils/easy_io/easy_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def join_path(
backend_key (str, optional): The key to get the backend from register.

Returns:
str: The result of concatenation.
str or Path: The result of concatenation. Returns a Path if any input is a Path.

Examples:
>>> filepath1 = '/path/of/dir1'
Expand Down
4 changes: 2 additions & 2 deletions cosmos_framework/utils/easy_io/file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def isfile(self, filepath: Union[str, Path]) -> bool:
"""
return self.client.isfile(filepath)

def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> str:
def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) -> Union[str, Path]:
r"""Concatenate all file paths.

Join one or more filepath components intelligently. The return value
Expand All @@ -385,7 +385,7 @@ def join_path(self, filepath: Union[str, Path], *filepaths: Union[str, Path]) ->
filepath (str or Path): Path to be concatenated.

Returns:
str: The result of concatenation.
str or Path: The result of concatenation. Returns a Path if any input is a Path.
"""
return self.client.join_path(filepath, *filepaths)

Expand Down