dazzling-elephant-33766
02/06/2023, 4:22 PM➜ 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.handler
--entry-point
value referred to on the gcloud docs)
I’ve tried playing around with different --source
values:
➜ 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
➜ 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 project/google_cloud_function_example.py
-> project/main.py
, but this gives the same error.
Can anyone point me in the right direction? What invocation should I be using to deploy this example?happy-kitchen-89482
02/06/2023, 4:41 PM--source
expects a directory, and you're passing it a zip filehappy-kitchen-89482
02/06/2023, 4:42 PMhappy-kitchen-89482
02/06/2023, 4:43 PMhappy-kitchen-89482
02/06/2023, 4:43 PMhappy-kitchen-89482
02/06/2023, 4:43 PM--source=<gs://my-bucket/my_function_source.zip>
happy-kitchen-89482
02/06/2023, 4:43 PMhappy-kitchen-89482
02/06/2023, 4:46 PM--source
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)dazzling-elephant-33766
02/06/2023, 5:05 PMhappy-kitchen-89482
02/06/2023, 5:12 PMdazzling-elephant-33766
02/06/2023, 5:12 PM--source=gs://..
happy-kitchen-89482
02/06/2023, 6:54 PMhappy-kitchen-89482
02/06/2023, 6:55 PMenough-analyst-54434
02/07/2023, 6:05 AMhappy-kitchen-89482
02/07/2023, 5:29 PM