I've been reading between the lines and trying to interface dev_appserver.py with the new 'non-legacy' google cloud datastore emulator.
My main motivation is to integrate my appengine projects with my google cloud dataflow pipeline while I am developing on my local machine.
This is the procedure to setup the integration, as far as I understand:
- Install the
googledatastore
library with pip (you may need to force an upgrade ofsix
with easy_install particularly if you are using system python El Capitan) Using the google cloud sdk tools run the google cloud datastore emulator:
gcloud beta emulators datastore start --no-legacy
In the terminal where dev_appserver will run the following command to set datastore environment variables:
$(gcloud beta emulators datastore env-init --no-legacy)
If the project id in app.yaml does not match the currently select project id in the gcloud tools set the following environment variable in the same shell:
export DATASTORE_USE_PROJECT_ID_AS_APP_ID=true
- Run dev_appserver.py and navigate to http://localhost:8000/datastore which should let you navigate the emulator's datastore data.
However this does not work so smoothly when I navigate to the url I get:
BadArgumentError: Could not import googledatastore.
This library must be installed with version >= 4.0.0.b1 to use the Cloud Datastore
API.
This is strange because if I open a python shell and run import googledatastore
no error occurs.
If I dig a bit deeper and instrument the import code in dev_appserver and log the error here I get the following traceback:
Traceback (most recent call last):
File "/usr/local/google-cloud-sdk/platform/google_appengine/google/appengine/datastore/datastore_pbs.py", line 52, in <module>
import googledatastore
File "/Library/Python/2.7/site-packages/googledatastore/__init__.py", line 21, in <module>
from . import helper
File "/Library/Python/2.7/site-packages/googledatastore/helper.py", line 25, in <module>
from google.datastore.v1beta3 import entity_pb2
ImportError: No module named datastore.v1beta3
I also have no issue importing google.datastore.v1beta3
in a regular python shell.
Even stranger if I run PYTHONINSPECT=x dev_appserver.py app.yaml
and drop out into the shell executing these imports runs without error. Perhaps there is something odd going on with the python path while dev_appserver.py is starting?
Can anybody tell me how to get this feature working?
UPDATE: I reproduced this problem on ubuntu 14.04 (system python 2.7.6, pip 8.1.2 via easy_install, gcloud-sdk 118.0.0, app-engine-python 1.9.38) as well as OS X (gcloud sdk 114.0.0, app-engine-python 1.9.38, system python 2.7.10).