Skip to content

Commit dadc642

Browse files
committed
more pythonic
Signed-off-by: Martin Simonovsky <[email protected]>
1 parent 38e0132 commit dadc642

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

flytekit/remote/remote_fs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ async def _put_file(
145145
"""
146146
prefix = kwargs.pop(_PREFIX_KEY)
147147
lpath = pathlib.Path(lpath)
148-
relative_subdirectory = str(lpath.parent)[len(kwargs.pop(_LPATH_ROOT_KEY)):]
149-
if relative_subdirectory:
150-
prefix += relative_subdirectory
148+
relative_subdirectory = str(lpath.parent.relative_to(pathlib.Path(kwargs.pop(_LPATH_ROOT_KEY))))
149+
if relative_subdirectory != ".":
150+
prefix += "/" + relative_subdirectory
151151
_, native_url = self._remote.upload_file(
152152
lpath, self._remote.default_project, self._remote.default_domain, prefix
153153
)
@@ -239,7 +239,7 @@ async def _put(
239239

240240
kwargs[_PREFIX_KEY] = prefix
241241
kwargs[_HASHES_KEY] = file_info
242-
kwargs[_LPATH_ROOT_KEY] = lpath.rstrip(os.path.sep)
242+
kwargs[_LPATH_ROOT_KEY] = lpath
243243
res = await super()._put(lpath, REMOTE_PLACEHOLDER, recursive, callback, batch_size, **kwargs)
244244
if isinstance(res, list):
245245
res = self.extract_common(res)

0 commit comments

Comments
 (0)