I tried deploying with gcloud from the terminal, and I tried via the UI, I get the same error during deployment (build works) in the deployment logs:
Error: function terminated. Recommended action: inspect logs for termination reason. Function cannot be initialized.
And gcloud tells me the following:
ERROR: (gcloud.functions.deploy) OperationError: code=13, message=Function deployment failed due to a health check failure. This usually indicates that your code was built successfully but failed during a test execution. Examine the logs to determine the cause. Try deploying again in a few minutes if it appears to be transient.
So, I go to the logs and nothing, nada, nisba. Not a line. Tried upping RAM to 2GB, tried packaging .py files that reside at the same level of main.py out of the root, no luck. Clearly, if locally I call the handler function in main.py from a test script, running it in a virtualenv (py37) with packages from requirements.txt, it works. Running it locally with the functions-framework? It works.
This following is how I'm calling gcloud to deploy so far:
gcloud functions deploy load_to_bigquery \
--project=project-platform-dev \
--region europe-west1 \
--runtime python37 \
--memory 1024MB \
--entry-point handler \
--env-vars-file .env.dev.yaml \
--trigger-resource the-source-bucket \
--trigger-event google.storage.object.finalize