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

STORAGE: Does a connection need to be bound to anything other than a Batch or Iterator? #728

Closed
dhermes opened this issue Mar 13, 2015 · 5 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@dhermes
Copy link
Contributor

dhermes commented Mar 13, 2015

Run

$ git grep -n '\.connection' -- gcloud/datastore/ | egrep -v test | egrep -v 'datastore\.connection'
$ git grep -n '\.connection' -- gcloud/storage/ | egrep -v test | egrep -v 'storage\.connection'

to compare uses.

@dhermes dhermes added the api: storage Issues related to the Cloud Storage API. label Mar 13, 2015
@dhermes dhermes added this to the Storage Stable milestone Mar 13, 2015
@dhermes dhermes self-assigned this Mar 14, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Mar 14, 2015

I'm going to start this work in a series of small changes (I'm guessing there will be a lot of test re-factoring).

Please protest if there are any issues.

UPDATE: After starting this, it seems quite daunting.

After checking blob.py and bucket.py it seems the following methods all use a connection.

From git grep -e '^ def' -- gcloud/storage/blob.py (edited by me):

def generate_signed_url(self, expiration, method='GET'):
def exists(self):
def rename(self, new_name):
def delete(self):
def download_to_file(self, file_obj):
def download_to_filename(self, filename):
def download_as_string(self):
def upload_from_file(self, file_obj, rewind=False, ...
def upload_from_filename(self, filename, ...
def upload_from_string(self, data, ...
def make_public(self):  # Maybe not?

From git grep -e '^ def' -- gcloud/storage/bucket.py (edited by me):

def __iter__(self):
def __contains__(self, blob_name):
def exists(self):
def create(self, project=None):
def get_blob(self, blob_name):
def get_all_blobs(self):
def iterator(self, prefix=None, delimiter=None, max_results=None,
def delete(self, force=False):
def delete_blob(self, blob_name):
def delete_blobs(self, blobs, on_error=None):
def copy_blob(self, blob, destination_bucket, new_name=None):
def upload_file(self, filename, blob_name=None):
def upload_file_object(self, file_obj, blob_name=None):
def make_public(self, recursive=False, future=False):

(Updated March 31, 2015)

@dhermes
Copy link
Contributor Author

dhermes commented Mar 23, 2015

@tseaver We have some methods which make HTTP requests for historical reasons only:

Also Blob.make_public doesn't really fit the rest of methods, but that makes an HTTP request via the ObjectACL. It seems hairier to unwind this.

@tseaver
Copy link
Contributor

tseaver commented Mar 26, 2015

I think we could easily change the metadata-updating methods to drop the call (and require calling patch()). Maybe ACL updates should also require an explict patch or save call?

@dhermes
Copy link
Contributor Author

dhermes commented Mar 27, 2015

@tseaver I agree. Being more declarative was the original goal of #545. I tried to sketch a way (in #761) to make these properties, but some of them are a bit involved (i.e. have multiple values associated).

We could look into using apitools generated clients at some point?

@dhermes
Copy link
Contributor Author

dhermes commented Mar 31, 2015

@tseaver Removing __iter__ and __contains__ is impossible if no Connection is bound to a Bucket. As I mention in #761, using __iter__ is pretty scary for large applications / buckets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

No branches or pull requests

2 participants