-
Notifications
You must be signed in to change notification settings - Fork 898
[checkpoint] Support fsspec checkpoint paths #3730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YassineYousfi
wants to merge
7
commits into
pytorch:main
Choose a base branch
from
commaai:checkpoint-fs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+159
−43
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e56f90c
checkpoint fsspec
YassineYousfi 2fe263f
add to deps
YassineYousfi 5647a0b
Use DCP storage auto-selection for checkpoints
YassineYousfi fc0288a
rm fsspec from ci requirements
YassineYousfi 5b0f207
oops here too
YassineYousfi 6ebd410
fs absolute + catch purge errors + rm unused
YassineYousfi e19a289
better to ignore here
YassineYousfi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| import os | ||
| import posixpath | ||
| from typing import IO, cast | ||
|
|
||
| from fsspec.core import url_to_fs | ||
|
|
||
|
|
||
| def join_path(path: str, *parts: str) -> str: | ||
| if not parts: | ||
| return path | ||
| if not path: | ||
| return posixpath.join(*parts) | ||
| return posixpath.join(path.rstrip("/"), *parts) | ||
|
|
||
|
|
||
| def basename(path: str) -> str: | ||
| return posixpath.basename(path.rstrip("/")) | ||
|
|
||
|
|
||
| def open_file(path: str, mode: str) -> IO[bytes]: | ||
| filesystem, fs_path = url_to_fs(path) | ||
| if any(flag in mode for flag in ("w", "a", "x", "+")): | ||
| parent = posixpath.dirname(fs_path) | ||
| if parent: | ||
| filesystem.makedirs(parent, exist_ok=True) | ||
| return cast(IO[bytes], filesystem.open(fs_path, mode)) | ||
|
YassineYousfi marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| def exists(path: str) -> bool: | ||
| filesystem, fs_path = url_to_fs(path) | ||
| return filesystem.exists(fs_path) | ||
|
|
||
|
|
||
| def isdir(path: str) -> bool: | ||
| filesystem, fs_path = url_to_fs(path) | ||
| if filesystem.isfile(fs_path): | ||
| return False | ||
| return filesystem.isdir(fs_path) or bool(ls(path)) | ||
|
|
||
|
|
||
| def ls(path: str) -> list[str]: | ||
| filesystem, fs_path = url_to_fs(path) | ||
| try: | ||
| return [os.fspath(entry) for entry in filesystem.ls(fs_path, detail=False)] | ||
| except (FileNotFoundError, NotADirectoryError): | ||
| return [] | ||
|
|
||
|
|
||
| def rm(path: str, *, recursive: bool = False) -> None: | ||
| filesystem, fs_path = url_to_fs(path) | ||
| try: | ||
| filesystem.rm(fs_path, recursive=recursive) | ||
| except FileNotFoundError: | ||
| pass | ||
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.
Uh oh!
There was an error while loading. Please reload this page.