-
Notifications
You must be signed in to change notification settings - Fork 301
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
Added alt prefix head to FlyteFile.new_remote #2601
Changes from 2 commits
e905d31
f614ede
bbfbe17
3dc30a9
8419de4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -454,6 +454,27 @@ def join( | |
f = fs.unstrip_protocol(f) | ||
return f | ||
|
||
def get_new_path( | ||
self, | ||
fs: typing.Optional[fsspec.AbstractFileSystem] = None, | ||
alt: typing.Optional[str] = None, | ||
stem: typing.Optional[str] = None, | ||
unstrip: bool = False, | ||
) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a docstring? Make sure to add examples. |
||
fs = fs or self.raw_output_fs | ||
pref = self.raw_output_prefix | ||
s_pref = pref.split(fs.sep) | ||
if alt: | ||
s_pref[2] = alt | ||
if stem: | ||
s_pref.append(stem) | ||
else: | ||
s_pref.append(self.get_random_string()) | ||
p = fs.sep.join(s_pref) | ||
if unstrip: | ||
p = fs.unstrip_protocol(p) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used atm, right? Let's postpone on making this function more complex than it has to be to address the needs of this PR. |
||
return p | ||
|
||
def get_random_local_path(self, file_path_or_file_name: typing.Optional[str] = None) -> str: | ||
""" | ||
Use file_path_or_file_name, when you want a random directory, but want to preserve the leaf file name | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from flytekit.types.file import FlyteFile | ||
from flytekit import FlyteContextManager | ||
|
||
def test_new_remote_alt(): | ||
ff = FlyteFile.new_remote_file(alt="my-alt-prefix", name="my-file.txt") | ||
assert "my-alt-prefix" in ff.path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this function to something more descriptive?