Skip to content

Honor depth limits and include directories in recursive find - #411

Open
shcheklein wants to merge 55 commits into
mainfrom
fix/fs-find-traversal
Open

shcheklein wants to merge 55 commits into
mainfrom
fix/fs-find-traversal

Conversation

@shcheklein

@shcheklein shcheklein commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Fixes #325. This PR builds on #409 and #408.

find() honors maxdepth and withdirs, sorts both output formats, and warns callers using the deprecated positional boolean detail. Cached folder IDs allow warm traversal across multiple levels in one Drive request. Current parent links determine the returned paths.

The filesystem extra requires fsspec 2024.2.0 or newer. The Ubuntu Python 3.11 job tests that minimum. Bounded glob expansion delegates to fsspec. The tests cover depth 1 through 3, glob expansion, sorting, file and directory mounts, and exact cold and warm request counts. The wide fixture takes seven requests cold and six warm.

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AI-generated review of 31de6118ae3e7d21aeb05d7e3a83bdadbfdf1720.

Good fix for maxdepth, withdirs, glob, and expand_path (including fsspec>=2021.07.0 maxdepth=0 and positional find(path, True) compatibility). Inline comments focus on simplifying find() (it doubled from ~48 to ~99 lines mainly due to duplicated self.info(path) fallbacks for untyped mount IDs), avoiding extra info() calls on directories with only subdirectories, and a key-vs-entry["name"] trailing-slash mismatch when detail=True, withdirs=True.

Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/test/test_fs_listing.py Resolved

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AI-generated re-review of 1dc810a85e2268d42dad294c541740083ae99102 (from scratch).

Big improvement—the duplicated self.info() fallback is gone, key == entry["name"] is now consistent via _directory_entry, known_dir = True in the loop avoids extra stat calls on subdirs-only mounts, and the unit + live tests are thorough.

No standalone bugs found; two small cross-PR alignment notes with #409 inline.

Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
@shcheklein
shcheklein changed the base branch from fix/fs-directory-cache-invalidation to fix/fs-create-directories November 22, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A cached named directory deleted or trashed externally can still appear in find results because its existence and trash status are not revalidated before inclusion.

1 open issue
What changed in this PR

This PR improves the Drive filesystem’s recursive discovery, building on the directory-cache and creation work to support fsspec traversal options.

Changes:

  • Adds depth limits, optional directory inclusion, sorted results, and a warning for legacy positional detail.
  • Uses cached folder IDs to batch traversal while deriving paths from current parent links.
  • Expands traversal and request-count tests, and raises the minimum fsspec version to 2024.2.0.
File Description
pyproject.toml Raises the minimum fsspec dependency.
pydrive2/​test/​test_fs.py Adds live depth, directory, glob, and expansion checks.
pydrive2/​test/​test_fs_unit.py Adds traversal, mount, sorting, and request-count coverage.
pydrive2/​test/​test_fs_listing.py Removes the wide-directory test replaced by HTTP-level coverage.
pydrive2/​fs/​spec.py Implements bounded traversal, directory results, and positional compatibility.
docs/​fsspec.rst Documents the dependency minimum and traversal conventions.
.github/​workflows/​test.yml Tests minimum fsspec on Ubuntu with Python 3.11.

Review effort: Balanced

Comment thread pydrive2/fs/spec.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The cache-dependent maxdepth filter lacks warm-cache depth-2/3 tests verifying returned paths and queried parent IDs when descendants beyond the limit are cached.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread pydrive2/fs/spec.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The finite-depth cache filter lacks warm depth-2/3 tests covering returned paths and exact queried parent IDs, leaving depth limits, request batching, and cached boundary-folder exclusion unverified.

1 open issue

Review effort: Balanced

Base automatically changed from fix/fs-create-directories to main November 26, 2026 23:26

This branch has not been deployed

No deployments
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.

Review and fix issues with find

2 participants