Repository navigation
Retry transient Drive API errors on discovery-client calls - #71
Closed
Light2Dark wants to merge 76 commits into
Closed
Light2Dark wants to merge 76 commits into
Light2Dark wants to merge 76 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
add uv, pyrefly, commit CI
add logo, docs, contributing.md
update links, remove text
add test-coverage
Request mimeType and reject non-folder IDs so a regular file passed as
root_file_id no longer masquerades as an empty directory under ls("").
Add a TODO for the conflicting drive vs shared-drive root_file_id case
(issue #2) to handle in a follow-up.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add integration tests asserting a file ID is rejected as root (NotADirectoryError) and a folder ID lists its children. Introduce a typed DriveConfig + make_fs factory fixture in conftest so live filesystems are built from env in one place and tests can create multiple instances with a shared teardown. Add tests to pyrefly search-path and document Drive API constants. Co-authored-by: Cursor <cursoragent@cursor.com>
check root id is valid
Enforce that a scoped drive and root_file_id agree: reject a folder root whose driveId differs from the configured drive, and raise on a shared-drive root_file_id that conflicts with an already-set drive (previously a silent no-op). Also resolve the `drive` argument by id or name (was name-only) and correct the docstring accordingly. Co-authored-by: Cursor <cursoragent@cursor.com>
…tency Validate drive/root consistency; accept drive id or name
update image, add service account docs
- conftest: collapse unreachable pytest.skip branch in make_fs
- test_core_fs: replace export AttributeError test with strict xfail
documenting that export() calls a nonexistent path_to_file_id
- test_integration: assert info("") against the real root, not TESTDIR;
drop dangling issue reference from dircache xfail reason
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update existing files in place instead of creating duplicates (#22)
switch to uv, and modernize CI yaml (fsspec#58)
discard() called a nonexistent self.fs._call, so any transaction rollback or aborted upload raised AttributeError. Rewrite it to DELETE the resumable session URI via the owned transport, append supportsAllDrives, accept Google's 499 cancel status, and clear self.location. The two existing tests only passed because they monkeypatched the missing _call in; replace them with real ones. While adding a multi-chunk integration test (previously commented out), found that multi-block resumable uploads were silently broken: the code assumed the server accepted the whole buffer per PUT, but Google only stores intermediate data up to a 256 KiB-aligned boundary and reports the real end in the Range header. The old code ignored it and over-advanced offset, so the final commit never matched and the file never committed. Add _consume_accepted to re-buffer the unaccepted tail and return False (fsspec's "buffer not fully consumed" signal), with guards that raise on protocol-violating responses (no Range, end behind offset, over-report). Other changes: - Replace -O-strippable assert status checks with raise IOError across _upload_chunk and _initiate_upload. - Own the authenticated transport (AuthorizedHttp) instead of reaching into the discovery client's private files()._http, sharing one transport with build(). No new dependency. - Add _authed_request wrapper so the untyped transport call returns a typed (httplib2.Response, bytes). Tests: discard/rollback, multi-chunk upload, and the full _consume_accepted / _parse_range_end branch matrix (unit + live integration). 121 unit tests pass; 16 integration pass against a live shared drive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… cancel - _parse_range_end: validate the documented bytes=0-<end> shape instead of splitting on any dash. A non-zero start, missing dash, or non-integer end now returns None, so a malformed/unexpected header re-buffers everything rather than miscounting accepted bytes. (cubic + CodeRabbit) - discard(): force supportsAllDrives=true via a query-aware helper (_with_supports_all_drives) instead of a substring check, which previously treated supportsAllDrives=false as already set. (CodeRabbit) - test_transaction_rollback_discards_upload: assert f.location is None after rollback to prove the resumable session was actually cancelled, not just that the file was never committed. (cubic + CodeRabbit) Added unit tests for both helpers (non-zero-start/garbled ranges; the =false override case). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The final chunk sends a concrete total (bytes X-Y/total) and expects a 200/201 that commits the object. A 308 there means the server did NOT finalize, but it was funneled into _consume_accepted as if it were a normal partial-consumption signal. Since commit()/close() flush exactly once and ignore the return, that left the upload unfinalized (file_id unset) while the handle closed — silently. Raise IOError when final=True (and autocommit, i.e. we sent a concrete total) and the server returns 308. The condition mirrors the concrete-total header branch, so intermediate wildcard chunks still re-buffer as before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
add a comment, and do a small test cleanup
fix cache stashing and retrieval
PR #51 (merged from master) added test_rm_deletes_file and test_rmdir_deletes_empty_directory that mock info() without capabilities, tripping the canDelete check in _rm. Provide deletable capabilities via the existing _deletable_info helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- _info_by_id: drop reserved keys (fileId/fields/supportsAllDrives) from forwarded **kwargs to avoid TypeError - ls/info: normalize a blank/whitespace field mask to None so it keeps the cache fast path instead of forcing a fresh listing / files.get - _rm: raise ValueError on the filesystem root instead of a misleading PermissionError - use a relative import for utils; readonly_fs skips without GDRIVE_FSSPEC_DRIVE Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Permission-aware rm and dircache correctness fixes
rm to trash by default
update references to new repo
change from master
* add multiple profiles testing * add back removed * update docstring * fix lint
Collaborator
Author
|
Closing — opened against the wrong repo. Retargeting to marimo-team/gdrive-fsspec main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #21 (partial)
_NUM_RETRIESfrom 2 to 5 and passnum_retrieson everygoogleapiclient.execute()call (list, get, create, delete, trash, drives, about, downloads).num_retriestoMediaIoBaseDownload.next_chunk()inexport()so chunked exports survive rate limits and 5xx errors.googleapiclient's built-in backoff, which only retries transient failures (5xx, 429, rate-limit 403s, transport errors) and leaves definitive client errors like 404/permission 403 alone.Resumable upload HTTP (
_authed_request) is intentionally out of scope for this PR.Checklist
drive, notdrive)Made with Cursor