Understanding Virtual Directories in AIStore: The —nr and —no-dirs Flags
Understanding Virtual Directories in AIStore: The —nr and —no-dirs Flags
Understanding Virtual Directories in AIStore: The —nr and —no-dirs Flags
AIStore supports the concept of virtual directories, allowing for hierarchical organization of objects within buckets.
When listing objects via supported APIs (or CLI ais ls), two important flags control how these virtual directories are handled: --nr (non-recursive) and --no-dirs. Understanding the interaction between these flags is essential.
In AIStore, virtual directories are indicated implicitly by using the slash (/) character in object names.
For example, an object named data/logs/file1.log implies virtual directories data/ and data/logs/.
Unlike traditional POSIX filesystems, the virtual directories are derived from the object names and provide a hierarchical view of your stored objects.
--nr (Non-Recursive)--no-dirs/)--nr is specifiedThe interaction between these flags can be confusing but follows a logical pattern:
--nr: Shows only top-level entries (both objects and directories) without recursing--no-dirs: Lists all objects recursively but hides virtual directory entries--nr --no-dirs: Shows only immediate objects (no directories, no recursion)The default behavior shows all objects recursively and hides virtual directories:
Using Unix-style path notation produces the same result:
A more complex example showing recursive listing with a specific prefix:
You can also use Unix-style directory notation, which is equivalent to the previous command:
The --nr flag shows only top-level entries without recursing into subdirectories:
This is especially useful for exploring directory structure at a specific depth:
The --no-dirs flag is implied by default and can be explicitly specified to hide directory entries:
Similarly, with a more complex structure:
When both --nr and --no-dirs flags are used together, only immediate objects are shown (no directories and no recursion):
In this case, no results appear because there are only directories at the top level. The --nr flag restricts listing to immediate objects, while --no-dirs excludes the virtual directories.
You can view both directories and objects at a specific level using --nr:
This shows both the current directory and immediate objects without recursing further.
Note: --no-dirs is implied by default
The --all flag shows both objects and directories at all levels
--nr flag is particularly useful when exploring a bucket’s structure level by level--nr, only the immediate level below the prefix is shown--nr won’t affect the output