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

Handle patterns matching folders in hash_files #929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/neuro_flow/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ async def hash_files_relative(ctx: CallCtx, root: LocalPath, *patterns: str) ->
# resolve() restores the case.
relative_fname = fname.resolve().relative_to(root.resolve()).as_posix()
hasher.update(relative_fname.encode("utf-8"))
if not fname.is_file():
continue
with fname.open("rb", buffering=0) as stream:
read = stream.readinto(buffer)
while read:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qwerty
4 changes: 2 additions & 2 deletions tests/unit/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ async def test_fmt(client: Client) -> None:


async def test_hash_files(client: Client) -> None:
expr = StrExpr(POS, POS, "${{ hash_files('Dockerfile', 'requirements/*.txt') }}")
expr = StrExpr(POS, POS, "${{ hash_files('Dockerfile', 'requirements/**/*') }}")
folder = LocalPath(__file__).parent / "hash_files"
ret = await expr.eval(Root({"flow": {"workspace": folder}}, client))
assert ret == "081fde04651e1184890a0470501bff3db8e0014260224e07acf5688e70e0edbe"
assert ret == "a8174f2c445c954da64b20abbd4fce62e094cd95ba7344c13fba79f5037bcbe2"


async def test_lower(client: Client) -> None:
Expand Down