-
Notifications
You must be signed in to change notification settings - Fork 139
feat(cli): add datachain bucket status command #1717
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
amritghimire
wants to merge
14
commits into
main
Choose a base branch
from
feat/bucket-status-cmd
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.
Open
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
856bea6
feat(cli): add `datachain bucket status` command
amritghimire 717d344
Merge branch 'main' into feat/bucket-status-cmd
amritghimire f618be1
fix(bucket-status): address PR review feedback on anon probe kwargs a…
amritghimire 44a0d21
Merge branch 'main' into feat/bucket-status-cmd
amritghimire 70cc1ea
fix(bucket-status): error on URI with path component
amritghimire bd97a03
Merge branch 'main' into feat/bucket-status-cmd
amritghimire 41e5cb6
Merge branch 'main' into feat/bucket-status-cmd
amritghimire ec0a246
fix(bucket-status): address PR review feedback and fix Azure anon probe
amritghimire 26bd989
Fix for gcs
amritghimire 3a6fa86
Merge branch 'main' into feat/bucket-status-cmd
amritghimire dce825c
Fix test
amritghimire f8c3828
Refactor bucket status handling for Azure and GCS clients
amritghimire 862bd64
Merge branch 'main' into feat/bucket-status-cmd
amritghimire 3bc2e4d
Add missing test coverage
amritghimire 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
Some comments aren't visible on the classic Files Changed page.
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
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,21 @@ | ||
| import sys | ||
|
|
||
| from datachain.client import bucket_status | ||
|
|
||
|
|
||
| def bucket_status_cmd(uri: str, client_config: dict | None = None) -> int: | ||
| """Check existence and access of a bucket/container. | ||
|
|
||
| Returns 0 if bucket exists, 1 if not found. | ||
| Raises on network errors. | ||
| """ | ||
| status = bucket_status(uri, **(client_config or {})) | ||
|
|
||
| if status.exists: | ||
| print("Status: exists") | ||
| print(f"Access: {status.access}") | ||
| else: | ||
| print("Status: not found") | ||
| if status.error: | ||
| print(f"Error: {status.error}", file=sys.stderr) | ||
| return 0 if status.exists else 1 |
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 |
|---|---|---|
| @@ -1,3 +1,23 @@ | ||
| from .fsspec import Client | ||
| from .fsspec import BucketStatus, Client | ||
|
|
||
| __all__ = ["Client"] | ||
|
|
||
| def bucket_status(uri: str, **client_config) -> BucketStatus: | ||
| """Check bucket existence and access level without listing objects. | ||
|
|
||
| Args: | ||
| uri: Bucket URI, e.g. "s3://my-bucket/", "gs://my-bucket/", "az://my-container/" | ||
| **client_config: Storage client configuration (anon, aws_key, etc.) | ||
| For Azure, pass ``account_name`` to enable anonymous access detection. | ||
| Without it, Azure container status detection may fail and report the | ||
| container as non-existent or access as ``denied``. | ||
|
|
||
| Returns: | ||
| BucketStatus(exists, access) where access is one of: | ||
| 'anonymous', 'authenticated', 'denied' | ||
| """ | ||
| client_cls = Client.get_implementation(uri) | ||
| name, _ = client_cls.split_url(uri) | ||
| return client_cls.bucket_status(name, **client_config) | ||
|
|
||
|
|
||
| __all__ = ["BucketStatus", "Client", "bucket_status"] | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.