Я пытаюсь настроить простое приложение Google AppEngine, которое получало бы данные JSON через запрос POST и применяло бы классификатор Catboost.
Я использую Python 3.6 и включил catboost==0.8
в мой requirements.txt
файл.
Однако развертывание завершается неудачно:
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2018-04-24 16:42:04 +0000] [1] [INFO] Starting gunicorn 19.7.1
[2018-04-24 16:42:04 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2018-04-24 16:42:04 +0000] [1] [INFO] Using worker: sync
[2018-04-24 16:42:04 +0000] [9] [INFO] Booting worker with pid: 9
[2018-04-24 16:42:05 +0000] [9] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/env/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
File "/home/vmagent/app/main.py", line 8, in <module>
from catboost import CatBoostClassifier, Pool
File "/env/lib/python3.6/site-packages/catboost/__init__.py", line 1, in <module>
from .core import Pool, CatBoost, CatBoostClassifier, CatBoostRegressor, CatboostError, cv, train # noqa
File "/env/lib/python3.6/site-packages/catboost/core.py", line 50, in <module>
_catboost = get_catboost_bin_module()
File "/env/lib/python3.6/site-packages/catboost/core.py", line 46, in get_catboost_bin_module
import _catboost
ModuleNotFoundError: No module named '_catboost'
Мой базовый Dockerfile следующий:
FROM gcr.io/google-appengine/python
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
RUN virtualenv /env -p python3
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
RUN apt-get update; \
apt-get install -y \
build-essential \
python-dev \
python-setuptools \
python-matplotlib \
libatlas-dev \
curl \
ssh \
libatlas3gf-base && \
apt-get clean
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
Я подозреваю, что проблема связана с sys.modules
, который не регистрируется _catboost
при импорте catboost
.
В гибкой среде Google AppEngine, есть ли способ использовать сторонние приложения, использующие библиотеки C, такие как Catboost?