Hi all. I’m trying to get Google cloud functions ...
# general
Hi all. I’m trying to get Google cloud functions working following this guide here: https://www.pantsbuild.org/docs/google-cloud-function-python#step-2-define-a-python_google_cloud_function--target I’m running into issues when I attempt to deploy this example cloud function I can build the function
Copy code
➜  example git:(main) ✗ ./pants package project/google_cloud_function_example.py
16:09:25.56 [INFO] Wrote dist/project/cloud_function.zip
    Runtime: python39
    Handler: handler
The pants docs claim:
You can use any of the various Google Cloud methods to upload your zip file, such as the Google Cloud console or the Google Cloud CLI.
You must specify the handler as
(Presumably this means the
value referred to on the gcloud docs) I’ve tried playing around with different
Copy code
➜  example git:(main) ✗ gcloud functions deploy example --region=europe-west2 --runtime=python38 --source=dist/project/cloud_function.zip --entry-point=handler
ERROR: (gcloud.functions.deploy) argument `--source`: Provided path does not point to a directory
Copy code
➜  example git:(main) gcloud functions deploy example --region=europe-west2 --runtime=python38 --source=dist/project --entry-point=handler
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function; Error ID: 5c04ec9c
And I’ve tried renaming
, but this gives the same error. Can anyone point me in the right direction? What invocation should I be using to deploy this example?
Hmm, things may have changed on the gcloud side since @enough-analyst-54434 implemented this. It looks like `gcloud functions`'s
expects a directory, and you're passing it a zip file
Which is what gcloud functions used to expect
Well, it still does expect a .zip file if you deploy from cloud storage
so maybe that was how this was expected to work all along
so try uploading that .zip file to cloud storage and then pointing to it as
So we know if that works
Then the other thing to try would be to unzip the .zip file and point
to that directory, and see if that works (we don't bundle third-party deps the way gcloud expects, but use pex machinery instead, so it's not clear to me whether this will work, but worth a try)
yep confirming that works as expected, just got a little confused by the documentation.
Which one worked?
uploading it to google cloud + deploying with
Ah, great!
Weird that they won't let you deploy the identical .zip file from a local file
FWIW I'm almost positive I didn't write this. IIRC it was a community contribution. I know I've debugged it a few times though.
You're right, sorry, I misremembered. It was by @worried-salesclerk-37834!