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

Add wildcard support for paths() and streams() (fixes #54) #60

Merged
merged 2 commits into from
Jul 1, 2021

Conversation

JuhaKiili
Copy link
Contributor

@JuhaKiili JuhaKiili commented Jun 23, 2021

What

For a single Valohai input, we have .path() .paths() .stream() .streams().

This PR introduces a new parameter filter_path, which allows filtering a subset of all the files of the input, based on their file path. Wildcards are supported for both single and double notation.

Example: valohai.inputs("myinput").paths("folder/**/foo/*.jpg")

Why

If your input has multiple files, but you just want one (or subset).

Before this PR:

import fnmatch
for path in fnmatch.filter(valohai.inputs("myinput").paths(), "weights.pb"):
  print(path)

After this PR:

path = valohai.inputs("myinput").path("weights.pb"):

Also supports stuff like:

for image_path in valohai.inputs("myinput").paths("folder/**/foo/*.jpg"):
  print(image_path)

@JuhaKiili JuhaKiili force-pushed the input-wildcards branch 2 times, most recently from a8d3b41 to 71e0538 Compare June 23, 2021 13:28
@JuhaKiili JuhaKiili requested a review from ruksi June 23, 2021 13:29
Copy link
Member

@ruksi ruksi left a comment

Choose a reason for hiding this comment

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

lgtm, you might want to add the test mentioned in the TODO though?

tests/test_inputs.py Outdated Show resolved Hide resolved
@JuhaKiili JuhaKiili requested a review from ruksi June 30, 2021 12:01
@JuhaKiili
Copy link
Contributor Author

Removed the TODO about mangled paths PR + handled all the merge conflicts with master.

@ruksi
Copy link
Member

ruksi commented Jul 1, 2021

🥇

@ruksi ruksi merged commit 1bb2f0f into master Jul 1, 2021
@ruksi ruksi deleted the input-wildcards branch July 1, 2021 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants