Skip to content

Commit

Permalink
add hash method to flytefile to fix bug in interactive shell (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
granthamtaylor authored Oct 24, 2024
1 parent 5add665 commit 8017ae8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flytekit/types/file/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ def __repr__(self):
def __str__(self):
return self.path

def __hash__(self):
return hash(str(self.path))


class FlyteFilePathTransformer(AsyncTypeTransformer[FlyteFile]):
def __init__(self):
Expand Down
9 changes: 9 additions & 0 deletions tests/flytekit/unit/types/file/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ def test_new_auto_file():
ff = FlyteFile.new("my-file.txt")
cwd = FlyteContextManager.current_context().user_space_params.working_directory
assert cwd in ff.path

def test_file_is_hashable():

ff1 = FlyteFile.new("file1.txt")
ff2 = FlyteFile.new("file2.txt")

assert isinstance({ff1, ff2}, set)

assert isinstance(hash(ff1), int)

0 comments on commit 8017ae8

Please sign in to comment.