Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine Python: Error in yaml config file when deploying

I'm using Google App Engine, Python37 environment. I got an error message when trying to deploy a microservice today:
I run the command:

gcloud app deploy app.yaml

Got the error:

...
File upload done.
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: script field for handler '/.*' 
must be set to 'auto' for runtime python37.
PS C:\path_to_app> gcloud app deploy app.yaml
...

My app.yaml is:

service: service_name
runtime: python37

handlers:
- url: /.*
script: main.py

It looks exactly the same from other microservices that I have deployed recently, just the service name is different.
I tried to re-deploy a services that is already running and got same error message.
So I double check app.yaml reference document: https://cloud.google.com/appengine/docs/standard/python3/config/appref
But I couldn't find out what is wrong neither why the same yaml file that had worked before doesn't work anymore.

Does anyone know what can be wrong or maybe what can be changed on Google App Engine in the last days?

Thanks in advance.

like image 889
MarlosB Avatar asked Nov 02 '18 11:11

MarlosB


People also ask

How use config yaml file in Python?

Reading a key from YAML config file We can read the data using yaml. load() method which takes file pointer and Loader as parameters. FullLoader handles the conversion from YAML scalar values to the Python dictionary. The index [0] is used to select the tag we want to read.

What should be included in app yaml?

This file specifies how URL paths correspond to request handlers and static files. The app. yaml file also contains information about your app's code, such as the runtime and the latest version identifier. Each service in your app has its own app.


1 Answers

I got this error when deploying a flask app with a blueprint structure. The solution is to have main.py file in the same directory as app.yaml file. In the main.py file, import the app object e.g from app import app (here the first 'app' is the folder containing an init file where the flask app instance is created). After doing this, setting script to auto should work fine.

like image 65
Patrick Mutuku Avatar answered Oct 12 '22 09:10

Patrick Mutuku