-
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
Phase 1 Update create_bucket to take Bucket object within Storage Client #7820
Conversation
storage/tests/unit/test_client.py
Outdated
from google.cloud.exceptions import Conflict | ||
from google.cloud.storage.bucket import Bucket | ||
|
||
PROJECT = "PROJECT" |
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.
nit: since these are just local variables, use lower-case letters.
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.
Changed variable names to lower-case on all tests I'm working on.
storage/tests/unit/test_client.py
Outdated
] | ||
) | ||
data = {"error": {"message": "Conflict"}} | ||
sent = {"name": BUCKET_NAME} |
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.
nit: I recommend moving this down near the assertion and calling it json_expected
to align with json_sent
.
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.
Renamed sent
to json_expected
on all relevant tests for consistency and moved down as directed.
storage/tests/unit/test_client.py
Outdated
"b?project=%s" % (PROJECT,), | ||
] | ||
) | ||
sent = {"name": BUCKET_NAME, "billing": {"requesterPays": True}} |
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.
In addition to requesterPays
, let's set some properties on the bucket object in this test. The properties I most want to see are
location - Which region is this bucket belonging to?(actually, that's not settable yet. Let's add that to the list in the redesign doc if it's not there yet)storage_class
- What kind of bucket is this?requester_pays
- Leave the argument tocreate_bucket
unset and set it on the Bucket, instead. (We should deprecaterequester_pays
oncreate_bucket
. Add that to the redesign list, too.)
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.
Added storage_class property and adjusted requester_pays as directed. Included requester_pays and location comment in the redesign doc.
@@ -398,7 +398,7 @@ class Bucket(_PropertyMixin): | |||
https://cloud.google.com/storage/docs/storage-classes | |||
""" | |||
|
|||
def __init__(self, client, name=None, user_project=None): | |||
def __init__(self, client=None, name=None, user_project=None): |
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.
Let's make this update as a separate PR, as I think we'll want to show better error messages in the existing Bucket methods when client
isn't supplied (for example, say what method to call instead on Client).
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.
Took this file out of review - please disregard, thanks!
@@ -202,7 +202,7 @@ def batch(self): | |||
""" | |||
return Batch(client=self) | |||
|
|||
def get_bucket(self, bucket_name): | |||
def get_bucket(self, bucket_or_name): |
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.
I'd prefer this to be a separate PR, too, but it's okay this once. In general a PR should correspond to 1 easily-described change (new feature / bug fix). Now this PR has 2 new features (but they are related, at least).
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.
Took this file out of review - please disregard, thanks!
@@ -265,8 +266,8 @@ def create_bucket(self, bucket_name, requester_pays=None, project=None): | |||
To set additional properties when creating a bucket, such as the | |||
bucket location, use :meth:`~.Bucket.create`. | |||
|
|||
:type bucket_name: str | |||
:param bucket_name: The bucket name to create. | |||
:type bucket_or_name: str or resource |
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.
Could you make the docstring for create_bucket
follow the same pattern as we use in BigQuery. These :type:
and :param:
are Sphinx/RST-style, but we are migrating to Google-style.
Docs on Google-style are at https://sphinxcontrib-napoleon.readthedocs.io/en/latest/ with an example file at https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-google
We had to do this for BigQuery too. Basically, as we update each method we migrate it to the Google-style.
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.
Updated docstring to reflect Google-style.
Python 2.7 test failure is due to #7841
|
@tswast Hmm, I wasn't aware that this redesign had actually been approved: in fact I asked about that in yesterdays storage sync call, and got a "no, still under consideration." |
Part of issue: #7762
@tswast
@engelke