Skip to content
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

Merged
merged 8 commits into from
May 1, 2019

Conversation

lbristol88
Copy link
Contributor

@lbristol88 lbristol88 commented Apr 30, 2019

Part of issue: #7762

@tswast
@engelke

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 30, 2019
@lbristol88
Copy link
Contributor Author

@engelke

from google.cloud.exceptions import Conflict
from google.cloud.storage.bucket import Bucket

PROJECT = "PROJECT"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

]
)
data = {"error": {"message": "Conflict"}}
sent = {"name": BUCKET_NAME}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

"b?project=%s" % (PROJECT,),
]
)
sent = {"name": BUCKET_NAME, "billing": {"requesterPays": True}}
Copy link
Contributor

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

  1. 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)
  2. storage_class - What kind of bucket is this?
  3. requester_pays - Leave the argument to create_bucket unset and set it on the Bucket, instead. (We should deprecate requester_pays on create_bucket. Add that to the redesign list, too.)

Copy link
Contributor Author

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.

@crwilcox crwilcox added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@@ -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):
Copy link
Contributor

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).

Copy link
Contributor Author

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!

@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@@ -202,7 +202,7 @@ def batch(self):
"""
return Batch(client=self)

def get_bucket(self, bucket_name):
def get_bucket(self, bucket_or_name):
Copy link
Contributor

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).

Copy link
Contributor Author

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!

@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 30, 2019
@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 1, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 1, 2019
@tswast
Copy link
Contributor

tswast commented May 1, 2019

Python 2.7 test failure is due to #7841

____________ TestStorageNotificationCRUD.test_notification_explicit ____________
self = <tests.system.TestStorageNotificationCRUD testMethod=test_notification_explicit>
    def setUp(self):
        self.case_buckets_to_delete = []
>       self._initialize_topic()
tests/system.py:1181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/system.py:1166: in _initialize_topic
    from google.cloud.pubsub_v1 import PublisherClient
../pubsub/google/cloud/pubsub_v1/__init__.py:19: in <module>
    from google.cloud.pubsub_v1 import subscriber
../pubsub/google/cloud/pubsub_v1/subscriber/__init__.py:17: in <module>
    from google.cloud.pubsub_v1.subscriber.client import Client
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    from __future__ import absolute_import
    import pkg_resources
    import os
    import grpc
    from google.api_core import grpc_helpers
    from google.oauth2 import service_account
    from google.cloud.pubsub_v1 import _gapic
    from google.cloud.pubsub_v1 import types
    from google.cloud.pubsub_v1.gapic import subscriber_client
    from google.cloud.pubsub_v1.gapic.transports import subscriber_grpc_transport
    from google.cloud.pubsub_v1.subscriber import futures
>   from google.cloud.pubsub_v1.subscriber._protocol import streaming_pull_manager
E     File "/tmpfs/src/github/google-cloud-python/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 198
E       print(f"{messages_percent}, {bytes_percent}")
E                                                  ^
E   SyntaxError: invalid syntax

@tswast tswast merged commit ad2cbe0 into googleapis:master May 1, 2019
@tseaver
Copy link
Contributor

tseaver commented May 1, 2019

@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."

@tswast
Copy link
Contributor

tswast commented May 1, 2019

@tseaver I got the 👍 from @frankyn , who's the DPE that owns GCS.

We don't plan on making any breaking changes in the client with the redesign. The redesign is intended to ease the eventual transition to gRPC.

@frankyn
Copy link
Member

frankyn commented May 2, 2019

Sorry @tseaver, I did check it off with @tswast but didn't follow-up on the Github issue.

I'm also not sure about the meeting you're referring. @crwilcox is this a new spin off from the original libraries weekly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants