Title: Smooth out API surfaces before M1 · Issue #336 · googleapis/google-cloud-python · GitHub
Open Graph Title: Smooth out API surfaces before M1 · Issue #336 · googleapis/google-cloud-python
X Title: Smooth out API surfaces before M1 · Issue #336 · googleapis/google-cloud-python
Description: Current offenders: There is no way to allocate_ids without explicitly using protobufs. I have partially addressed (Implemented in #436). Transactions don't give any indication of success or failure (i.e. commit or rollback in __exit__). ...
Open Graph Description: Current offenders: There is no way to allocate_ids without explicitly using protobufs. I have partially addressed (Implemented in #436). Transactions don't give any indication of success or failure...
X Description: Current offenders: There is no way to allocate_ids without explicitly using protobufs. I have partially addressed (Implemented in #436). Transactions don't give any indication of success or fai...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/336
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Smooth out API surfaces before M1","articleBody":"Current offenders:\n1. ~~There is no way to [`allocate_ids`](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/regression/datastore.py#L30) without explicitly using protobufs. I have partially [addressed](https://github.com/dhermes/gcloud-python/commit/0860e5902541eeb6146a3fb0f55ec66465b3dc39)~~ (Implemented in #436).\n2. ~~Transactions don't give any indication of success or failure (i.e. commit or rollback in [`__exit__`](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/gcloud/datastore/transaction.py#L252)).~~ (Filed #496)\n3. ~~`Query` (and other classes) could be more Pythonic by allowing us to pass values to constructor that also have their own setters. For [example](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/regression/datastore.py#L165):~~\n \n ``` python\n query = dataset.query('Character').ancestor(\n ANCESTOR_KEY).limit(10).order('appearances')\n ```\n \n ~~becomes~~\n \n ``` python\n query = dataset.query('Character', ancestor=ANCESTOR_KEY,\n limit=10, order='appearances')\n ```\n \n ~~We don't have to go as extreme as #188 by wiping away the `return self` behavior in the setters, but could use them in conjuction with more Pythonic constructors.~~ (Implemented in #487)\n4. ~~`Query.cursor()` should not raise an error before being used. Using `query.cursor() is None` gives a way to check progress in a query. For example, in paging:~~ (addressed in #432)\n \n ``` python\n query = dataset.query(kind=kind).limit(FETCH_MAX)\n results = []\n more_results = True\n while more_results:\n # Make new query.\n if query._cursor is not None:\n query = query.with_cursor(query._cursor)\n \n curr_results = query.fetch()\n results.extend(curr_results)\n \n more_results = len(curr_results) == FETCH_MAX\n ```\n5. ~~`Query` should give access to `start_cursor` and `end_cursor`. It is currently [only set](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/gcloud/datastore/query.py#L385) on the `pb`.~~ (see #432)\n6. Comparing `Entity` values should be easier. Current [workaround](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/regression/datastore.py#L243) is\n \n ``` python\n arya_dict = dict(arya_entity.items())\n self.assertEqual(arya_dict, {'name': 'Arya', 'family': 'Stark'})\n ```\n7. ~~Paging [with offsets](https://github.com/GoogleCloudPlatform/gcloud-python/blob/2b73c7b4b1bd2f0abd6bc7f3da6a48c135d8f53a/regression/datastore.py#L287) should be a bit more automatic, as it is in `gcloud-node`. Currently we have to~~\n \n ``` python\n query = query.offset(offset).limit(limit)\n entities = page_query.fetch()\n # Offset needs to be reset to 0 since we want to start exactly at `cursor`.\n next_query = query.with_cursor(cursor).offset(0)\n ```\n \n (done in #487, since `offset` always defaults to `0`)\n8. ~~I'm sure there will be plenty more to come after #319~~\n9. ~~(UPDATED): Consider making bulk-adding properties to `Entity` more intuitive. See #389.~~ (`dict.update()` is Pythonic and simple to use / multi-type signature)\n10. ~~(UPDATED): \"Creating a new datastore.entity with a key name is a pain.\" See #82~~\n","author":{"url":"https://github.com/dhermes","@type":"Person","name":"dhermes"},"datePublished":"2014-11-04T07:23:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/336/google-cloud-python/issues/336"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a7b3bae9-96cc-b7ed-2339-7ac6af9b9a9b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5D0:3C2C53:328D00:441ABF:6A4D8D98 |
| html-safe-nonce | 8ab011af0f249b3811109615ad7c67f1e07827d4f216e9634e0e32f5bef4e541 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUQwOjNDMkM1MzozMjhEMDA6NDQxQUJGOjZBNEQ4RDk4IiwidmlzaXRvcl9pZCI6Ijk1ODk0MzY2MzU2MzMxMjUzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c43ff055cb4a2b7debd5bc925e89d0b3552c35c01ed29367b103445f46892aae |
| hovercard-subject-tag | issue:47684962 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/336/issue_layout |
| twitter:image | https://opengraph.githubassets.com/363be64068df6c937fcefd47cd0e9cdfab783c8e5ec742a4ba81ed1b6d2ffa04/googleapis/google-cloud-python/issues/336 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/363be64068df6c937fcefd47cd0e9cdfab783c8e5ec742a4ba81ed1b6d2ffa04/googleapis/google-cloud-python/issues/336 |
| og:image:alt | Current offenders: There is no way to allocate_ids without explicitly using protobufs. I have partially addressed (Implemented in #436). Transactions don't give any indication of success or failure... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dhermes |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 74e2a9c78f1e38588de4f25885878349d721eedf |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width