![](/img/trans.png)
[英]Deployment Error: Function deployment failed due to a health check failure on Google Cloud Function with Tweepy
[英]Google Cloud Function: FunctionsError: OperationError: code=13, message=Function deployment failed due to a health check failure
使用以下 bash 命令進行部署時:
gcloud functions deploy my_gcf --runtime python37 --trigger-http --memory=512MB --region europe-west1 --service-account=my-service-account@my-project.iam.gserviceaccount.com --allow-unauthenticated --verbosity debug
我不斷得到:
FunctionsError: 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.
不幸的是,在檢查日志時,除了:
Error: function terminated. Recommended action: inspect logs for termination reason. Function cannot be initialized.
正如你所看到的,我指定了 --verbosity 標志,但它似乎沒有幫助。 所有的包都已安裝,我已經按照這里的文檔來構建 repo:在我的代碼中,我有一個 requirements.txt 文件和我編碼的自定義包,但我想我會得到另一種錯誤以上。
我的要求.txt:
beautifulsoup4==4.8.0
boto==2.49.0
boto3==1.13.25
botocore==1.16.25
cachetools==4.1.0
cloudpickle==0.8.1
flask==1.0.2
flask-restplus==0.12.1
functions-framework==2.0.0
gensim==3.8.3
google-api-core==1.17.0
google-api-python-client==1.7.8
google-auth==1.15.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
google-cloud==0.34.0
google-cloud-core==0.29.1
google-cloud-pubsub==0.45.0
google-cloud-storage==1.14.0
google-cloud-vision==1.0.0
grpc-google-iam-v1==0.12.3
grpcio==1.29.0
gunicorn==19.9.0
jinja2==2.10
jsonschema==3.2.0
more-itertools==8.3.0
nltk==3.4.4
numpy==1.18.4
pandas==1.0.3
protobuf==3.12.1
requests==2.23.0
requests-oauthlib==1.3.0
scikit-learn==0.23.1
scikit-plot==0.3.7
scipy==1.4.1
setuptools==46.4.0
temp
urllib3==1.25.9
werkzeug==0.14.1
yarl==1.4.2
我的主要.py:
from flask import abort, escape, jsonify
from werkzeug.exceptions import BadRequest
from src.split.pagetypemodel import MetaModel, PageTypeModel
from src.split.utils import predict_pipeline_split, check_google_json, extract_data_from_json, \
map_predictions_to_expected_output
import time
import logging
import datetime
import google.cloud.storage as gcs
import tempfile
from os import path
import sys
sys.path.insert(0, path.join(path.dirname(path.realpath(__file__)), 'lib'))
import logging
from google.oauth2 import service_account
import os
MODEL_VERSION = 'v0'
model_split = PageTypeModel()
bucket = gcs.Client().get_bucket('my-bucket')
model_split.load(source = tempfile.gettempdir(), filename = "pagetypemodel_prod",
bucket = bucket, storage = "GTEL_SX/split")
def my_gcf(request):
# set logger
today = time.gmtime()
logger = logging.getLogger(__name__)
logger.info('>>> Received post request at time: {}'.format(today))
logger.info('1. Checking input json')
# check if there is any data
if request.get_json() is None:
logger.info('Data is not a valid json')
raise BadRequest('The body of the request does not contain a valid json, please contact AA team')
if isinstance(request.get_json(), list):
logger.info('Input json is a list! Correct!!')
input_body = {
'responses': request.json
}
else:
# bad format input json
logger.warning('Json type is not list!!')
raise BadRequest('Json type is not list')
logger.info('N pages: {}'.format(len(input_body['responses'])))
# check if there is data inside input
if len(input_body['responses']) == 0:
logger.warning('Received empty list')
raise BadRequest('Received empty list')
# check format page
for i in range(len(input_body['responses'])):
logger.info('Checking page number {}'.format(i))
check_google_json(input_body['responses'][i], logger)
logger.info('2. Extract info from json')
list_txt, list_labels_ocr = extract_data_from_json(input_body['responses'], logger)
logger.info('3. Predict')
predictions = predict_pipeline_split(list_txt, list_labels_ocr, model_split)
predictions = map_predictions_to_expected_output(predictions) # format predictions to expected output
logger.info('4. Return output')
response = {
"splitPages": predictions,
"datetimePrediction": datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"),
"version": MODEL_VERSION
}
return jsonify(response), 200
先感謝您
即使當前日志不提供任何附加信息,在刪除時:
werkzeug==0.14.1
並將其替換為:
werkzeug
我能夠部署 Google Cloud Function。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.