Build failed: Build error details not available when deploying a Python Google Cloud Function with a local package

Viewed 1093

I have a Google Cloud Function that processes messages from a queue. When I put all the modules in the root of the function (where main.py and requirements.txt live) everything works fine. If I move the modules into a local package as shown here in the docs., then when I deploy the function by uploading the Zip file using the cloud console I get an error saying Build failed: Build error details not available with no other info.

.
├── main.py
├── module_one.py
├── module_two.py
└── requirements.txt

at the root of the archive I upload works just fine.

.
├── main.py
├── requirements.txt
├── local_package_one/
│   ├── __init__.py
│   └── module_one.py
└── local_package_two/
    ├── __init__.py
    └── module_two.py

earns me Build failed: Build error details not available. In the second configuration, I update all the affected import statements. I initially suspected the requirements.txt file since it isn't shown in the example, but here they state that it should work just fine. The example there also shows a top-level folder named after the function, so I tried putting that at the root of the archive with everything inside of it and got the same results.

I changed the imports from

from module_one import MyClass

to

from local_package_one.module_one import MyClass
1 Answers

This could be a number of issues, but without more details it's hard to say.

This general pattern works though, e.g.:

$ tree
.
├── local_package_one
│   ├── __init__.py
│   └── module_one.py
├── local_package_two
│   ├── __init__.py
│   └── module_two.py
├── main.py
└── requirements.txt

$ cat main.py
from local_package_one.module_one import hello
from local_package_two.module_two import world

def test(request):
    return hello + ' ' + world

$ cat local_package_one/module_one.py
hello = "hello"

$ cat local_package_two/module_two.py
world = "world"

$ gcloud functions deploy test --runtime python37 --trigger-http --allow-unauthenticated
Deploying function (may take a while - up to 2 minutes)...done.

$ curl https://<my-function>.cloudfunctions.net/test
hello world%
Related