app-engine-ndb

Does the NDB membership query (“IN” operation) performance degrade with lots of possible values?

邮差的信 提交于 2019-12-07 06:12:06
问题 The documentation for the IN query operation states that those queries are implemented as a big OR'ed equality query: qry = Article.query(Article.tags.IN(['python', 'ruby', 'php'])) is equivalent to: qry = Article.query(ndb.OR(Article.tags == 'python', Article.tags == 'ruby', Article.tags == 'php')) I am currently modelling some entities for a GAE project and plan on using these membership queries with a lot of possible values: qry = Player.query(Player.facebook_id.IN(list_of_facebook_ids))

When does an ndb Model's _post_put_hook have a future different from self?

╄→尐↘猪︶ㄣ 提交于 2019-12-07 04:17:13
问题 Google App Engine's ndb provides a _post_put_hook(self, future), documented as follows: Hook that runs after put() To understand this hook better, I am wondering when self will differ from the result of the future argument. The Model Hooks documentation provides: If you use post-hooks with asynchronous APIs, the hooks are triggered by calling check_result(), get_result() or yielding (inside a tasklet) an async method's future. Post hooks do not check whether the RPC was successful; the hook

How to fetch image and save to blobstore?

我是研究僧i 提交于 2019-12-06 16:40:48
I would like to fetch images (~250Kb) from another site and save them to blobstore . I would like to use Blobstore due to its quota (5Gb free) vs datastore (1Gb free). How can I do it? GAE docs say that I should create upload form to use blobstore, which I don't need. I think this code will work: from __future__ import with_statement # first line of your code .... from google.appengine.api import urlfetch import mimetypes from google.appengine.api import files ..... image_name = 'your_image.png' response = urlfetch.fetch('http://....../' + image_name) # response.status_code == 200 (mimetype, _

dowload app engine ndb entities via bulk exporter / bulk uploader

拥有回忆 提交于 2019-12-06 16:25:27
问题 Context: My model classes inherit from a base class: class BaseModel(ndb.model): # commom fields and methods class SpecificModel(BaseModel): # specific fields and methods Problem: I want to export the SpecificModel entities using the appengine bulkuploader service. I have the defined the config file (data_loader.py): import sys sys.path.append('.') ## this is to ensure that it finds the file 'models.py' from google.appengine.ext import ndb from google.appengine.tools import bulkloader from

GAE Python NDB query fetch response time >55 seconds when only ~50 entities are present

一笑奈何 提交于 2019-12-06 15:37:46
问题 We have a travel search website. To search for a bus, we execute a query on the bus operator entities. We use GAE Python NDB. The query fetch response time >55 seconds(on deployed version and not development server) when only ~50 entities are present. Presently my query contains five items. If I increase to more than five, the response slows further considerably. Please suggest ways to bring down the query time to ~1 or 2 seconds or as less as possible. Please find the relevant details below

ndb Models are not saved in memcache when using MapReduce

蓝咒 提交于 2019-12-06 12:39:14
I've created two MapReduce Pipelines for uploading CSVs files to create Categories and Products in bulk. Each product is gets tied to a Category through a KeyProperty. The Category and Product models are built on ndb.Model, so based on the documentation, I would think they'd be automatically cached in Memcache when retrieved from the Datastore. I've run these scripts on the server to upload 30 categories and, afterward, 3000 products. All the data appears in the Datastore as expected. However, it doesn't seem like the Product upload is using Memcache to get the Categories. When I check the

Custom properties not saved correctly for Expando models in repeated StructuredProperty

余生长醉 提交于 2019-12-06 12:20:22
问题 I am trying to use an Expando model as a repeated StructuredProperty in another model. Namely, I would like to add an indefinite number of Accounts to my User model. As Accounts can have different properties depending on their types ( Accounts are references to social network accounts, and for example Twitter requires more information than Facebook for its OAuth process), I have designed my Account model as an Expando . I've added all basic information in the model definition, but I plan to

NDB querying a GenericProperty in repeated Expando StructuredProperty

社会主义新天地 提交于 2019-12-06 12:01:18
Hey guys im trying to figure out how to structure my query for the following case First i have a model defined class Variant(ndb.Expando): test = ndb.StringProperty() class Item(ndb.Model): test2 = ndb.StringProperty() variants = ndb.StructuredProperty(Variant, repeated=True) variant = Variant(test="test", dynamic="a") item = Item(test2="test", variants=[variant, ]) item.put() and then for the query stuff.. So far i've tried dynamic = "dynamic" Item.query(ndb.GenericProperty("variants.%s" % dynamic) == "a") Item.query(Item._properties["variants.%s" % dynamic] == "a") Item.query(getattr(Item

How to fetch the latest data in GAE Python NDB

余生长醉 提交于 2019-12-06 11:38:43
问题 I am using GAE Python. I have two root entities: class X(ndb.Model): subject = ndb.StringProperty() grade = ndb.StringProperty() class Y(ndb.Model): identifier = ndb.StringProperty() name = ndb.StringProperty() school = ndb.StringProperty() year = ndb.StringProperty() result = ndb.StructuredProperty(X, repeated=True) Since google stores our data across several data centers, we might not get the most recent data when we do a query as shown below(in case some changes have been "put"): def post

App Engine instance memory constantly increasing

左心房为你撑大大i 提交于 2019-12-06 11:09:26
问题 I'd expect the memory usage of my app engine instances (Python) to be relatively flat after an initial startup period. Each request to my app is short lived, and it seems all memory usage of single request should be released shortly afterwards. This is not the case in practice however. Below is a snapshot of instance memory usage provided by the console. My app has relatively low traffic so I generally have only one instance running. Over the two-day period in the graph, the memory usage