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

Problem handling local structured property kind without keys #627

Closed
twumdjin opened this issue Feb 13, 2015 · 9 comments
Closed

Problem handling local structured property kind without keys #627

twumdjin opened this issue Feb 13, 2015 · 9 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@twumdjin
Copy link

According to: https://cloud.google.com/appengine/docs/python/ndb/properties#structured
Local structured properties do not require keys and AppEngine appears to be fine with this.
Unfortunately, the gcloud-python library expects keys for every entity, even if they're local structured ones.
My work around is to update my entities in AppEngine to provide dummy keys, however, it would be nice if the library supported it natively.

gcloud/datastore/helpers.pyc in entity_from_protobuf(pb)
     46     :returns: The entity derived from the protobuf.
     47     """
---> 48     key = key_from_protobuf(pb.key)
     49     entity_props = {}
     50     exclude_from_indexes = []

gcloud/datastore/helpers.pyc in key_from_protobuf(pb)
    103         namespace = pb.partition_id.namespace
    104 
--> 105     return Key(*path_args, namespace=namespace, dataset_id=dataset_id)

gcloud/datastore/key.pyc in __init__(self, *path_args, **kwargs)
     74         # _flat_path, _parent, _namespace and _dataset_id must be set before
     75         # _combine_args() is called.
---> 76         self._path = self._combine_args()

gcloud/datastore/key.pyc in _combine_args(self)
     131         :raises: :class:`ValueError` if the parent key is not complete.
     132         """
--> 133         child_path = self._parse_path(self._flat_path)

gcloud/datastore/key.pyc in _parse_path(path_args)
      92         """
      93         if len(path_args) == 0:
---> 94             raise ValueError('Key path must not be empty.')

ValueError: Key path must not be empty.
@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Feb 13, 2015
@dhermes dhermes modified the milestones: Core Stable, Datastore Stable Feb 13, 2015
@dhermes
Copy link
Contributor

dhermes commented Feb 13, 2015

@twumdjin Thanks for filing! It was actually filed a few days ago as #616 and fixed in #617. You can use the newest version via

pip install git+https://github.com/GoogleCloudPlatform/gcloud-python

or wait for the next release.

I am considering cutting a 0.4.1 release tomorrow.

@dhermes dhermes closed this as completed Feb 13, 2015
@dhermes
Copy link
Contributor

dhermes commented Feb 13, 2015

Also @twumdjin thanks for using the library and caring enough to give feedback!

@twumdjin
Copy link
Author

Thanks for the really quick response Danny!
I was very glad I found this library, I was in the process of porting GAE's ndb library to provide a a cleaner ORM layer to Google datastore when I stumbled upon your project on an SO response. I seriously wish I'd found it sooner, keep up the great work!

I'll be looking forward to the next release.

@dhermes
Copy link
Contributor

dhermes commented Feb 13, 2015

Thanks @twumdjin

I'd also recommend following #557. We plan on porting ndb wholesale at some point.

As an aside, what sort of posting or announcement could we have made to

  1. Make it clear this library exists (even though it's not an ORM like ndb)
  2. Make it clear we intend to support ndb at some point

@twumdjin
Copy link
Author

Would be great if that port happens. While the async functionality on ndb is great and I use it extensively, I wouldn't even mind having a version that didn't support async initially. Simply having some OO interface to entity definitions would be a big win.

Unfortunately, discovering this library is a bit of an SEO challenge.
I see that it comes up first on a query for "gcloud datastore", however, I get the impression 'Google datastore' and 'Google cloud datastore' would be a more popular search term for the service and the Google docs on the service itself dominate search results for for anything with those combinations (understandably).

I wonder if you can get this linked from the official Google Datastore documents. Some of the other Google services have client libraries promoted that way.

I can't imagine anyone using Google datastore outside of GAE who wouldn't be hunting for a solution like this

@dhermes
Copy link
Contributor

dhermes commented Feb 13, 2015

Thanks for the detailed feedback @twumdjin. It's really useful!

/cc @jgeewax

@jgeewax
Copy link
Contributor

jgeewax commented Feb 13, 2015

Thanks for the feedback @twumdjin (and for the CC @dhermes) !

Once we get to a 1.0 release, we'll update the official Google Cloud Platform Python snippets, examples, and documentation to use gcloud-python code (and obviously link to it from the homepage of how to get started in Python by running pip install gcloud).

If you're interested in the "1.0" timeline, we're aiming for the Datastore, Storage, and Core "Stable" milestones to be closed out (see https://github.com/GoogleCloudPlatform/gcloud-python/milestones?direction=desc&sort=completeness&state=open).

@twumdjin
Copy link
Author

Thanks for the 0.4.1 update with the fix @dhermes!

@dhermes
Copy link
Contributor

dhermes commented Feb 14, 2015

Glad it helps!

vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
* feat: added support for custom content types
docs: clarified wording around quota usage

PiperOrigin-RevId: 513681148

Source-Link: googleapis/googleapis@3b8869b

Source-Link: googleapis/googleapis-gen@c1c7570
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzFjNzU3MGIzMTVmZjJjYzk2NWMxN2EzYzlhODM0YjJhZjE4YWUwYyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: added support for custom content types
docs: clarified wording around quota usage

PiperOrigin-RevId: 513764591

Source-Link: googleapis/googleapis@79acb42

Source-Link: googleapis/googleapis-gen@f6fabc9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjZmYWJjOTI1MTIzNWQzNWVhNjQyODk2ZjJjMzBiNWVlM2QzYjgyYyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

3 participants