gpt4 book ai didi

python - 无法在 Cloud Run 应用中读取 pickle 文件。类型错误 : __cinit__() takes at least 2 positional arguments

转载 作者:行者123 更新时间:2023-12-04 10:11:09 24 4
gpt4 key购买 nike

我有一个部署到 GCP Cloud Run 的 Fast API 应用程序。直到昨天它一直工作正常,我真的不知道出了什么问题。当我读入 .pkl 文件时,问题似乎从这一行开始model = pickle.load(open(os.path.join('models', 'appartementen.pkl'), 'rb'))回溯:

    File "pandas/_libs/internals.pyx", line 572, in pandas._libs.internals.BlockManager.__cinit__: TypeError: __cinit__() takes at least 2 positional arguments (0 given) at <module> (/app/src/api/util.py:25)
at <module> (/app/src/api/main.py:8) at
_call_with_frames_removed (<frozen importlib._bootstrap>:219) at exec_module (<frozen importlib._bootstrap_external>:728)
at _load_unlocked (<frozen importlib._bootstrap>:677)
at _find_and_load_unlocked (<frozen importlib._bootstrap>:967)
at _find_and_load (<frozen importlib._bootstrap>:983)
at _gcd_import (<frozen importlib._bootstrap>:1006)
at import_module (/usr/local/lib/python3.7/importlib/__init__.py:127)
at import_app (/usr/local/lib/python3.7/site-packages/gunicorn/util.py:358) at load_wsgiapp (/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:39)
at load (/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:49)
at wsgi (/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py:67)
at load_wsgi (/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py:144)
at init_process (/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py:119)
at spawn_worker (/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py:583)
请注意,当我在本地部署此应用程序时,一切正常。
我的 Dockerfile:
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
WORKDIR /app
COPY . ./
COPY src ./src/
COPY models ./models/
RUN pip install -r requirements.txt
COPY setup.py ./
CMD exec gunicorn src.api.main:app
我如何部署到 Cloud Run:
gcloud builds submit --tag gcr.io/project-id/api --timeout=3600

gcloud run deploy api --image gcr.io/project-id/api --platform managed --project=project-id --region=europe-west4
requirements.txt :
fastapi==0.63.0
google-cloud-bigquery[bqstorage,pandas]==1.24.0
sentry_sdk==1.0.0
xgboost==1.3.3
scikit-learn==0.23.1
shap==0.39.0
matplotlib==3.4.1
我尝试根据 this suggestion 使用相同版本的 scikit-learn 但问题仍然存在。

最佳答案

这是一个 bug使用 Pandas 1.3.0,并且是 fixedpandas 1.3.1 .
作为解决方法,请替换 pickle.load pandas.read_pickle .

关于python - 无法在 Cloud Run 应用中读取 pickle 文件。类型错误 : __cinit__() takes at least 2 positional arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68281924/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com