Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip copying files to the remote path if the directory is empty #1345

Merged
merged 8 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def put(self, from_path: str, to_path: str, recursive: bool = False):
from fsspec.utils import other_paths

lfs = LocalFileSystem()
lpaths = lfs.expand_path(from_path, recursive=recursive)
try:
lpaths = lfs.expand_path(from_path, recursive=recursive)
except FileNotFoundError:
# In some cases, there is no file in the original directory, so we just skip copying the file to the remote path
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a debug log here mentioning that the file does not exist?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's do that @pingsutw

return
rpaths = other_paths(lpaths, to_path)
for l, r in zip(lpaths, rpaths):
fs.put_file(l, r)
Expand Down
5 changes: 4 additions & 1 deletion tests/flytekit/unit/core/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from collections import OrderedDict
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from textwrap import dedent

import pandas
Expand Down Expand Up @@ -1648,7 +1649,9 @@ def wf(a: ut) -> ut:
assert wf(a=2.0) == 2.0
file = tempfile.NamedTemporaryFile(delete=False)
assert isinstance(wf(a=FlyteFile(file.name)), FlyteFile)
assert isinstance(wf(a=FlyteSchema()), FlyteSchema)
flyteSchema = FlyteSchema()
flyteSchema.open().write(pd.DataFrame({"Name": ["Tom", "Joseph"], "Age": [1, 22]}))
assert isinstance(wf(a=flyteSchema), FlyteSchema)
assert wf(a=[1, 2, 3]) == [1, 2, 3]
assert wf(a={"a": 1}) == {"a": 1}

Expand Down