-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support Cloud Client Libraries on Google App Engine standard #1893
Comments
Hello @gpopovic! @dhermes has a good skeleton project that might help you. It looks like there is some extra work in supporting gcloud-python as a dependency. |
thanks @daspecster , but isn't this too much hack for something that should be simple? |
@dhermes or @tseaver could probably shed more light on this. Here is @dhermes post on stackoverflow talking about some of the issues. Do you have a stacktrace from "DistributionNotFound"? |
|
Can someone explain the rationale behind the error here? The darth vendor path does work, but it's way more code that I'd expect just to get a hello world with gcloud-python.... |
Because App Engine standard doesn't truly support third-party packages. We work around this with vendoring. It's semi-officially supported by darth being included as See here. The rest of the hacks are just get this package and its dependencies to play nicely with GAE standard. |
Just a thought, what if we put these kind of issues in an FAQ or something? I guess we could just leave here but I think it might be useful to have these issues summarized in one spot. |
@jonparrott is the authority on installing packages for GAE |
Assign this to me, I'll add GAE Standard installation instructions to the documentation. @dhermes how can I help you remove the two hacks (metadata server check, pkg_resources)? |
Which hacks are you referring to (link?)? |
metadata: dhermes/test-gcloud-on-gae@365d512 pkg_resources: dhermes/test-gcloud-on-gae@4457b2f |
@jonparrott The metadata hack was just to avoid the HTTP hit (slowdown). The |
I feel like Sometimes I wonder if my pursuit of packaging sanity in App Engine will make me lose my own sanity. |
I hope not, I wish robots would fix packaging instead of beating humans in Go. |
Update: pytz will be available in 1.9.40. The pwd module is also going to be enabled in an upcoming release, possibly 1.9.41. |
Closing this issue as I can confirm that gcloud-python works via vendoring on GAE standard. pytz, pwd, etc. should make things "better", but are not strictly needed. |
I take that back, there's a deployment issue. Ugh. |
Any updated information that could be provided on this would be helpful. Are there any short term workarounds? Or, do I need to migrate off of appengine standard sooner rather than later? This was actually working for me briefly, but the issue I am running into currently is:
|
natb1: supporting standard is a priority. You might be able to get around this by just deleting grpc from lib/ |
no dice. thanks though
I also tried removing google from lib/
|
locking down
|
@jonparrott Yes, I do. The |
@jonparrott @natb1 @dhermes The latest release of |
We have limited resources on both the Client Libraries team and the App Engine team. We are working to make this happen, but there are other things that are often higher in our list of priorities. We understand this is a important case for users, and lots of work is happening in the App Engine runtime to support these libraries (notably, we recently added gRPC to App Engine runtime). We've close, but there's still work to be done.
Can you expand on this? |
Might something like this be a stop-gap "solution"?
Seems
|
@jonparrott Thanks for pointing here but I am still not sure about #5012's relation to this issue as in my case package |
I am trying to use google cloud vision v1p1pbeta1 in the GAE standard environment. This is the error that i get when i try to import First time after deploying the application, I get this error: (/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/app.py", line 4, in <module>
from submitReview import SubmitReview
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/submitReview.py", line 8, in <module>
from google.cloud import vision_v1p2beta1 as vision
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/lib/google/cloud/vision_v1p2beta1/__init__.py", line 22, in <module>
from google.cloud.vision_v1p2beta1.gapic import image_annotator_client as iac
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/lib/google/cloud/vision_v1p2beta1/gapic/image_annotator_client.py", line 18, in <module>
import google.api_core.gapic_v1.client_info
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/lib/google/api_core/gapic_v1/__init__.py", line 16, in <module>
from google.api_core.gapic_v1 import config
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/lib/google/api_core/gapic_v1/config.py", line 23, in <module>
import grpc
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t181713.410189522651190980/lib/grpc/__init__.py", line 22, in <module>
from grpc._cython import cygrpc as _cygrpc
ImportError: dynamic module does not define init function (initcygrpc) Subsequently, from the second time onwards, I get this error: (/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t172858.410188745370110763/app.py", line 4, in <module>
from submitReview import SubmitReview
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t172858.410188745370110763/submitReview.py", line 9, in <module>
from google.cloud import vision_v1p1beta1 as vision
File "/base/data/home/apps/s~cs410c-vasaikar/20180603t172858.410188745370110763/lib/google/cloud/vision_v1p1beta1/__init__.py", line 20, in <module>
from google.cloud.vision_v1p1beta1 import types
ImportError: cannot import name types |
To import Google Cloud Storage on App Engine standard I use the following monkey patching:
But guys, we NEED a proper support for Google App Engine Standard. As with the old libraries it isn't even possible to generate download urls!! |
It doesn't seem like using Google APIs with App Engine is possible. I've followed the above instructions and receive the following when using
requirements.txt
main.py
appengine_config.py
app.yaml
I downloaded all packages above into a lib folder with: I'm shocked at how difficult it is to use Google Language API with GAE. Any reason they wouldn't be compatible? What am I missing here? |
@iethan Judging from your Your In Then in import googleapiclient.discovery
service = googleapiclient.discovery.build('language', 'v1')
request = service.documents().analyzeEntities(body={
"document": {
"type": 'PLAIN_TEXT',
"gcsContentUri": "gs://[BUCKET_NAME]/[FILE_NAME]}"
},
"encodingType": 'UTF8'
})
response = request.execute() |
@anguillanneuf Thanks for the comment. I'm getting the following error:
I did a search on Google Cloud for the library you mentioned and am not seeing it. Am I missing something from the documentation? |
An update for y'all: App Engine has launched its Python 3.7 runtime for Standard based on gVisor sandboxing technology. This means that these libraries (along with a significant amount of other libraries) are now supported on App Engine standard with that runtime. You should be able to simply add these to your At this time we have no plans to support these libraries on the Python 2.7 runtime on App Engine Standard. |
@theacodes wow, this is the first time I've heard about gVisor and App Engine, it's pretty darn cool. For better or worse, Python 2.7 will be around for quite a while, so let me please give a +1 for porting this to the 2.7 environment. |
We can use Google Big Query on Google Appengine standard environment? |
@linhui718611 : App Engine Standard announced a Python 3.7 runtime in August (see https://cloud.google.com/blog/products/gcp/introducing-app-engine-second-generation-runtimes-and-python-3-7). You should be able to use these libraries to talk to BigQuery from App Engine Standard when running on the Python 3.7 runtime. If you have more questions on the functionality supported by various runtimes, it's probably better to ask on Stack Overflow than here (this issue is specifically about making sure these client libraries run on the 2.7 runtime, which currently isn't on the planned road map AFIAK). |
How we can migrate Python 2.7 runtime to Python 3.7? |
@linhui718611 : It'd probably be best to head over to www.stackoverflow.com and ask this same question there. This GitHub issue tracker isn't really the right spot to help you! |
It would be great to have these libraries supported in standard 2.7. The new 3.7 standard still lacks things like NDB and other APIs. |
@Thalius with the Python 2 EOL just a little over a year out, there is pretty much zero chance that we will be backporting support to GAE Standard 2.7 at this date. |
@tseaver It makes sense, 2.7 is on it's way out. Luckily it won't be a problem for my current applications. I just hope we can get something like NDB and Taskqueue for the 3.7 standard environment. |
@theacodes First off, thank you to both the Client Libraries and App Engine teams for their respective hard work. Reviving something quite old here that I just read further up:
I don't know if this is what @erlichmen meant, but fom my perspective, a lot of frustration stems from the fact that https://cloud.google.com/apis/docs/client-libraries-explained even needs to exist. Add to that "special snowflake" client libs like this one: https://github.com/GoogleCloudPlatform/appengine-gcs-client.git I have been developing App Engine apps for many years now, and I can honestly say that this has been one of the most confusing aspects all along (which @&#! client library to use and which particular set of instructions/docs to follow). It used to be that the various services/APIs were baked in (NDB, task queue, [blob]storage etc.) which made life really easy. I do appreciate the need to separate concerns here and have the different products and teams be able to move independently as far as possible. The restructuring of the platform and work that has gone into the new libs makes sense to me, it's just that in the wake of all this the developer experience has suffered. The different libs don't have the same features and sometimes it's not clear at all which should be used where and why. For example, at my company we didn't even realise that It's not like we're living under a rock either. I'm subscribed to the Google Cloud newsletter and Cloud SDK update notifications. Often I feel like I'm wading through conflicting information from different doc pages or READMEs. Case in point: The top-level README for this repo states that these libs are not supported on the 2.7 runtime environment at all, but drill into one of the sub-components, for example storage, and now it sounds like the 2.7 runtime environment is supported at least until Jan 2020. Huh? Anyway, a lot of good work is happening, keep it up and I'm sure things will get better. This may be the wrong place for this kind of feedback, but I thought seeing as you asked for expansion... I have also left feedback on this before in other ways. Please will you see that it reaches the relevant people? *side note: we are still successfully using |
@maltem-za thank you for your respectful, thoughtful feedback. We do really appreciate it. I definitely agree things are more confusing today that before, and it really has a lot to do with the scale. When Google Cloud started (before it was Google Cloud, even), we had one real product (App Engine) that supported three languages. Within that product, we had a handful of services. This is a much easier developer experience problem to tackle than the one we face today: we have to support ~50 cloud products across ~8 languages on many platforms. As far as I know, we're the only people attempting to do something at this scale, a despite being Google we are limited on resources, so we're going to have some missteps.
I think we can clarify that a bit, @crwilcox. The intent here is that:
I'm glad it works for you. There's several workarounds that let people use them, but we determined that these workarounds aren't suitable for us to tell all of our users to adopt and the performance and reliability after applying these workarounds isn't something we feel comfortable supporting. If it works for you, great! just know that we can't really support it. (Coincidentally, Storage is indeed easier to hack to work in App Engine standard. The gRPC-based clients are much much harder) |
Thank you so much @xcash I've finally found the solution after struggling for 2 days tracing & bugging the error. I faced the problem of DistributionNotFound: The 'google-api-core' distribution was not found and is required by the application Then I come up with @xcash solution by changing this file & line
into
Then I faced the error about Then I come up with @iethan solution to set the env: Thank you guys again! |
It's 2020, and (during quarantine) I went to dig out my old App Engine Python 2 apps to move them to the latest Cloud libraries and encountered both these problems (
|
…s#1893) * Update sample output * Update snippets.py * Update snippets.py
I'm able to deploy it but I keep getting this error:
"DistributionNotFound: The 'gcloud' distribution was not found and is required by the application"
The text was updated successfully, but these errors were encountered: