-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Storage: Add Blob.from_string
and Bucket.from_string
.
#8424
Storage: Add Blob.from_string
and Bucket.from_string
.
#8424
Conversation
storage/tests/unit/test_client.py
Outdated
@@ -821,3 +821,49 @@ def dummy_response(): | |||
self.assertEqual(page.remaining, 0) | |||
self.assertIsInstance(bucket, Bucket) | |||
self.assertEqual(bucket.name, blob_name) | |||
|
|||
def test_get_bucket_from_uri(self): |
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.
Please rename this testcase test_get_bucket_from_uri_w_valid_uri
.
storage/tests/unit/test_client.py
Outdated
self.assertIs(bucket.client, client) | ||
self.assertEqual(bucket.name, BUCKET_NAME) | ||
|
||
def test_get_blob_from_uri(self): |
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.
Please rename this testcase test_get_blob_from_uri_w_valid_uri
.
storage/tests/unit/test_client.py
Outdated
self.assertIs(blob.client, client) | ||
self.assertEqual(blob.name, "/b/") | ||
|
||
def test_get_bucket_with_invalid_uri(self): |
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.
Please rename this testcase test_get_bucket_from_uri_w_invalid_uri
and move it above the test_get_object_w_valid_uri
.
storage/tests/unit/test_client.py
Outdated
with pytest.raises(ValueError, match="URI scheme must be gs"): | ||
client.get_bucket_from_uri("http://bucket_name") | ||
|
||
def test_get_blob_with_invalid_uri(self): |
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.
Please rename this testcase test_get_blob_from_uri_w_invalid_uri
.
@@ -477,6 +477,37 @@ def list_buckets( | |||
extra_params=extra_params, | |||
) | |||
|
|||
def get_blob_from_uri(self, uri): |
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.
Please move this method below get_bucket_from_uri
.
"""Get a constructor for blob object by URI. | ||
|
||
:type uri: str | ||
:param uri: The blob uri pass to get blob object. |
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.
Please add an example of the expected form of the uri, e.g.:
"""Construct a blob object from a URI.
:type uri: str
:param uri:
The blob's URI, in the form
"gs://<bucket-name>/<blob-name>".
...
"""
"""Get a constructor for bucket object by URI. | ||
|
||
:type uri: str | ||
:param uri: The bucket uri pass to get bucket object. |
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.
Please add an example of the expected form of the uri, e.g.:
"""Construct a bucket from a URI.
:type uri: str
:param uri:
The bucket's URI, in the form
"gs://<bucket-name>".
...
"""
raise ValueError("URI scheme must be gs") | ||
|
||
bucket = Bucket(self, name=netloc) | ||
return Blob(path[1:], bucket) |
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.
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.
Yes. get_
implies actually making a GET request. This should call .reload()
.
Note: this doesn't actually fix #7693 yet. I'd prefer you refactor this to have a |
@tswast What is your expected usecase for having |
Per https://github.com/googleapis/google-cloud-python/issues/7762, the goal is to have |
"skipif" should be used instead of "skipIf", the latter is the thing from the unittest nodule.
Update Makefile test proto builder: - Use new 'conformance_tests' repo. - Handle updated file hierarchy, etc. Use new JSON format in 'test_cross_language.py'. - Copy in JSON testcase files from 'conformance-tests' repo.
…nt library generator. (googleapis#8712)
Add undocumented-but-required '/documents' to the database path. Closes googleapis#8717.
@HemangChothani please rebase your branch against the current master to pick up the unit test fixes merged yesterday in #9119. Also, can you please check your git configuration to ensure that the e-mail address used in the commits matches your CLA (one commit, 30617c2, has '[email protected]' as the e-mail address). |
…nd batch_predict() from AutoML Tables client (googleapis#9116)
…rame`. (googleapis#9084) * Specify the index data type in partial schema to `load_table_from_dataframe` to include it. If an index (or level of a multi-index) has a name and is present in the schema passed to `load_table_from_dataframe`, then that index will be serialized and written to the table. Otherwise, the index is omitted from the serialized table. * Don't include index if has same name as column name. * Move `load_table_dataframe` sample from `snippets.py` to `samples/`. Sample now demonstrates how to manually include the index with a partial schema definition. Update docs reference to new `load_table_dataframe` sample location.
* Make all system tests table columns NULL-able Autodetected schema assumes NULLABLE fields, thus use NULLABLE columns in test fixture. * Replace helper function with BQ client method The _add_rows() helper function is no longer needed, since client.load_table_from_json() essentially does the same. * Use explicit schema in data types decoding test * Adjust a comment related to partial schemas
…in a different project (googleapis#9139)
4b73404
to
58f2329
Compare
…loband bucket class
Doc string indention.
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
58f2329
to
38a2c93
Compare
Closing this PR due to something irrelevant happens and unable to fix it, So replacing this PR with new PR 9143 |
Fixes #7693