You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, mmengine.fileio.list_dir_or_file doesn't support glob pattern matching when listing files. While Python's built-in glob.glob exists, it only works with local filesystem and cannot be used with other storage backends.
Proposed Solution
Add two new API functions:
defglob(pattern, *, recursive=False, backend_args=None):
"""Return a list of paths matching a pathname pattern. """passdefiglob(pattern, *, recursive=False, backend_args=None):
"""Return an iterator yielding paths matching a pathname pattern. """pass
Example usage:
frommmengine.fileioimportglob# List all jpg files in a directoryfiles=glob('s3://bucket/path/*.jpg', backend_args={'access_key': '...'})
# Recursively find all .png files files=glob('local/path/**/*.png', recursive=True)
Having a backend-agnostic glob implementation would:
Provide consistent pattern matching across different storage backends
Simplify file filtering without manual pattern matching
Match the functionality users expect from standard file operations
Improve code readability when working with specific file patterns
Would appreciate feedback on this proposal. Thank you!
The text was updated successfully, but these errors were encountered:
shenshanf
changed the title
[Feature Request] Add glob pattern support to list_dir_or_file for cross-backend file filtering
[Feature Request] Add glob/iglob API for pattern-based file listing across different storage backends markdownCopy## Feature Description
Feb 11, 2025
shenshanf
changed the title
[Feature Request] Add glob/iglob API for pattern-based file listing across different storage backends markdownCopy## Feature Description
[Feature Request] Add glob/iglob API for pattern-based file listing across different storage backends
Feb 11, 2025
Currently,
mmengine.fileio.list_dir_or_file
doesn't support glob pattern matching when listing files. While Python's built-inglob.glob
exists, it only works with local filesystem and cannot be used with other storage backends.Proposed Solution
Add two new API functions:
Example usage:
Current workaround requires manual filtering:
Having a backend-agnostic glob implementation would:
Would appreciate feedback on this proposal. Thank you!
The text was updated successfully, but these errors were encountered: