Skip to content

feat(files): colab upload/download -r (upstream #267) with its review applied - #22

Merged
arlinamid merged 2 commits into
mainfrom
feat/recursive-transfer
Nov 20, 2026
Merged

arlinamid merged 2 commits into
mainfrom
feat/recursive-transfer

Conversation

@arlinamid

Copy link
Copy Markdown
Owner

Takes upstream googlecolab#267 (-r / --recursive for colab upload and colab download, by Koji Shukawa, kept as the commit author) before Google merges it, and applies the review comments from Google on it:

  • no ntpath import; a drive-prefixed entry name is still refused on Windows via os.path.splitdrive (the fork runs on Windows, where C:x would have been written as x);
  • simpler posixpath.join;
  • _is_local_symlink: on POSIX islink("link/") is False, so a symlinked destination with a trailing slash was written through;
  • HTTP errors keep the fork's message without the URL (it carries the runtime proxy token).

Conflicts with the fork were resolved keeping the fork's behavior (token-free errors, colab edit creating an empty file when the download fails); the fork's tests now patch requests.Session.request, since ContentsClient reuses one session.

Tests: full suite 1337 passed. Live on a Colab web UI runtime: a tree with subfolders and an empty folder uploaded with -r and downloaded back identical.

🤖 Generated with Claude Code

zoutei and others added 2 commits November 20, 2026 03:14
Add recursive directory transfer support to `colab upload` and `colab download` via the Jupyter Contents API and reuse a persistent requests.Session in ContentsClient for HTTP keep-alive.

- Add ContentsClient.mkdir, _ensure_dir, upload_dir, and download_dir, preserving empty directories, skipping symlinks on upload, normalizing remote paths, and validating remote entry names, local canonical symlink/containment safety, and recursion depth
- Support single-file download -r targets (including existing or trailing-slash local directories) and reject missing file content
- Reuse a persistent requests.Session in ContentsClient with close()/context-manager cleanup (reopening a fresh client after $EDITOR in colab edit) and redact colab-runtime-proxy-token from HTTPError messages
- Update README, design doc, and unit tests
… transfers

Google's review of googlecolab#267 asked for these changes; the fork takes the PR
before Google merges it, so it applies them here:

- No `ntpath` import. A drive-prefixed entry name ("C:x") is still
  refused on Windows through os.path.splitdrive, which is ntpath there
  and a no-op elsewhere (on Windows "C:x" would have been written as "x").
- `posixpath.join` without the empty-path special cases.
- `_is_local_symlink`: on POSIX islink("link/") is False because the
  slash resolves the link, so a symlinked destination given with a
  trailing slash was written through.
- HTTP errors keep the fork's message without the URL, which carries
  the runtime proxy token.

Tested live on a Colab web UI runtime: a tree with subfolders and an
empty folder uploaded with -r and downloaded back identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arlinamid
arlinamid merged commit 6b38289 into main Nov 20, 2026
11 checks passed
arlinamid added a commit that referenced this pull request Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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