Skip to content

Commit

Permalink
Made FlyteFile.new_remote_file use name arg (#2499)
Browse files Browse the repository at this point in the history
Signed-off-by: pryce-turner <[email protected]>
  • Loading branch information
pryce-turner authored Jun 18, 2024
1 parent 29662e7 commit 0be183e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flytekit/types/file/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def new_remote_file(cls, name: typing.Optional[str] = None) -> FlyteFile:
Create a new FlyteFile object with a remote path.
"""
ctx = FlyteContextManager.current_context()
r = ctx.file_access.get_random_string()
r = name or ctx.file_access.get_random_string()
remote_path = ctx.file_access.join(ctx.file_access.raw_output_prefix, r)
return cls(path=remote_path)

Expand Down
6 changes: 6 additions & 0 deletions tests/flytekit/unit/core/test_flyte_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,9 @@ def test_join():
def test_headers():
assert FlyteFilePathTransformer.get_additional_headers("xyz") == {}
assert len(FlyteFilePathTransformer.get_additional_headers(".gz")) == 1


def test_new_remote_file():
nf = FlyteFile.new_remote_file(name="foo.txt")
assert isinstance(nf, FlyteFile)
assert nf.path.endswith('foo.txt')

0 comments on commit 0be183e

Please sign in to comment.