canonical / seldonio-rocks

ROCKs for Seldon Core
Apache License 2.0
0 stars 1 forks source link

`mlserver-*` fail to start with "'FastAPI' object has no attribute 'debug'" #80

Closed orfeas-k closed 9 months ago

orfeas-k commented 9 months ago

(this issue doesn't apply to mlserver-huggingface.) While updating the mlserver-* ROCKs to MLServer version 1.3.5 (for Seldon 1.17.1), the ROCKs started failing with error 'FastAPI' object has no attribute 'debug'. Note that FastApi package is pinned in MLServer images.

Debugging

Full error logs

Full error logs ```bash ╰─$ docker run mlserver-sklearn:1.3.5 130 ↵ 2024-01-09T13:58:01.674Z [pebble] Started daemon. 2024-01-09T13:58:01.679Z [pebble] POST /v1/services 3.752579ms 202 2024-01-09T13:58:01.679Z [pebble] Started default services with change 1. 2024-01-09T13:58:01.682Z [pebble] Service "mlserver-sklearn" starting: bash -c 'cd /opt/mlserver && export PATH=/opt/conda/bin/:/opt/mlserver/.local/bin:${PATH}:/usr/bin && export PYTHONPATH=/opt/mlserver/.local/lib/python3.8/site-packages/:${PYTHONPATH} && eval $(/opt/conda/bin/conda shell.bash hook 2> /dev/null) && mlserver start ${MLSERVER_MODELS_DIR}' 2024-01-09T13:58:02.637Z [mlserver-sklearn] Traceback (most recent call last): 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/bin/mlserver", line 8, in 2024-01-09T13:58:02.637Z [mlserver-sklearn] sys.exit(main()) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/cli/main.py", line 263, in main 2024-01-09T13:58:02.637Z [mlserver-sklearn] root() 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/click/core.py", line 1157, in __call__ 2024-01-09T13:58:02.637Z [mlserver-sklearn] return self.main(*args, **kwargs) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/click/core.py", line 1078, in main 2024-01-09T13:58:02.637Z [mlserver-sklearn] rv = self.invoke(ctx) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/click/core.py", line 1688, in invoke 2024-01-09T13:58:02.637Z [mlserver-sklearn] return _process_result(sub_ctx.command.invoke(sub_ctx)) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/click/core.py", line 1434, in invoke 2024-01-09T13:58:02.637Z [mlserver-sklearn] return ctx.invoke(self.callback, **ctx.params) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/click/core.py", line 783, in invoke 2024-01-09T13:58:02.637Z [mlserver-sklearn] return __callback(*args, **kwargs) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/cli/main.py", line 23, in wrapper 2024-01-09T13:58:02.637Z [mlserver-sklearn] return asyncio.run(f(*args, **kwargs)) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/conda/lib/python3.8/asyncio/runners.py", line 44, in run 2024-01-09T13:58:02.637Z [mlserver-sklearn] return loop.run_until_complete(main) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/cli/main.py", line 46, in start 2024-01-09T13:58:02.637Z [mlserver-sklearn] server = MLServer(settings) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/server.py", line 32, in __init__ 2024-01-09T13:58:02.637Z [mlserver-sklearn] self._metrics_server = MetricsServer(self._settings) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/metrics/server.py", line 25, in __init__ 2024-01-09T13:58:02.637Z [mlserver-sklearn] self._app = self._get_app() 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/mlserver/metrics/server.py", line 28, in _get_app 2024-01-09T13:58:02.637Z [mlserver-sklearn] app = FastAPI(debug=self._settings.debug) 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/fastapi/applications.py", line 146, in __init__ 2024-01-09T13:58:02.637Z [mlserver-sklearn] self.middleware_stack: ASGIApp = self.build_middleware_stack() 2024-01-09T13:58:02.637Z [mlserver-sklearn] File "/opt/mlserver/.local/lib/python3.8/site-packages/fastapi/applications.py", line 152, in build_middleware_stack 2024-01-09T13:58:02.637Z [mlserver-sklearn] debug = self.debug 2024-01-09T13:58:02.637Z [mlserver-sklearn] AttributeError: 'FastAPI' object has no attribute 'debug' 2024-01-09T13:58:02.732Z [pebble] Service "mlserver-sklearn" stopped unexpectedly with code 1 2024-01-09T13:58:02.732Z [pebble] Service "mlserver-sklearn" on-failure action is "restart", waiting ~500ms before restart (backoff 1) ```
orfeas-k commented 9 months ago

After all, starlette package was indeed causing the issue. I managed to pin starlette by adding it to the requirements/docker.txt file before running pip install with it. This resolved the issue.

Regarding

Somehow, I have a .rock file that is working as expected. I 'm not sure from where exactly this was built although it uses mlserver package 1.3.5.

it turns out that rockcraft clean && rockcraft pack didn't install the same dependencies each time. This can be verified by those two CI runs that are built from the same commit (one from PR and one from merging the PR to main) and they have different packages installed (starlette and fsspec). One image works (as expected) and the other one doesn't. Here's diff between their pip freeze output

- fsspec==2023.10.0
+ fsspec==2023.12.2
- starlette==0.22.0
+ starlette==0.34.0
orfeas-k commented 9 months ago

Closed in #73, #69, #72 and #81