-
Notifications
You must be signed in to change notification settings - Fork 112
Use HF buckets as backend #465
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
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
eec4c28
changes
abidlabs b692cb9
add changeset
gradio-pr-bot 9d47c81
Merge branch 'main' into buckets
abidlabs e8ad7bb
changes
abidlabs 7cdf4dc
Merge branch 'main' into buckets
abidlabs 7bbeec0
changes
abidlabs 24065b9
changes
abidlabs 373cd1c
changes
abidlabs 86e4e4a
changes
abidlabs cb70208
changes
abidlabs ff34a10
changes
abidlabs d99b52c
changes
abidlabs 1a15854
changes
abidlabs 2745725
changes
abidlabs e194431
changes
abidlabs 7877aca
changes
abidlabs 4b65a6b
changes
abidlabs ba330ec
changes
abidlabs bc5979e
changes
abidlabs e2652c2
changes
abidlabs 819a40e
changes
abidlabs 63f21de
changes
abidlabs fa3c6b8
changes
abidlabs 757e351
changes
abidlabs db63340
changes
abidlabs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "trackio": minor | ||
| --- | ||
|
|
||
| feat:Use HF buckets as backend |
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
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,40 @@ | ||
| import sqlite3 | ||
|
|
||
| import huggingface_hub | ||
| from huggingface_hub import sync_bucket | ||
|
|
||
| from trackio.sqlite_storage import SQLiteStorage | ||
| from trackio.utils import MEDIA_DIR, TRACKIO_DIR | ||
|
|
||
|
|
||
| def create_bucket_if_not_exists(bucket_id: str, private: bool | None = None) -> None: | ||
| huggingface_hub.create_bucket(bucket_id, private=private or False, exist_ok=True) | ||
|
|
||
|
|
||
| def download_bucket_to_trackio_dir(bucket_id: str) -> None: | ||
| TRACKIO_DIR.mkdir(parents=True, exist_ok=True) | ||
| sync_bucket( | ||
| source=f"hf://buckets/{bucket_id}", | ||
| dest=str(TRACKIO_DIR), | ||
| quiet=True, | ||
| ) | ||
|
|
||
|
|
||
| def upload_project_to_bucket(project: str, bucket_id: str) -> None: | ||
| db_path = SQLiteStorage.get_project_db_path(project) | ||
| if not db_path.exists(): | ||
| raise FileNotFoundError(f"No database found for project '{project}'") | ||
|
|
||
| with sqlite3.connect(str(db_path), timeout=30.0) as conn: | ||
| conn.execute("PRAGMA wal_checkpoint(TRUNCATE)") | ||
|
|
||
| files_to_add = [(str(db_path), db_path.name)] | ||
|
|
||
| media_dir = MEDIA_DIR / project | ||
| if media_dir.exists(): | ||
| for media_file in media_dir.rglob("*"): | ||
| if media_file.is_file(): | ||
| rel = media_file.relative_to(TRACKIO_DIR) | ||
| files_to_add.append((str(media_file), str(rel))) | ||
|
|
||
| huggingface_hub.batch_bucket_files(bucket_id, add=files_to_add) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For #457