sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
3.99k stars 205 forks source link

Robyn server hangs while serving rasa model #585

Open sfahad1414 opened 11 months ago

sfahad1414 commented 11 months ago

Bug Description

Sample code

from robyn import Robyn
from rasa.core.agent import Agent
import uuid6

app = Robyn(__file__)
agent = Agent.load("./models/20230818-091151.tar.gz")

@app.get("/")
async def h(request):
    return "Hello, world!"

@app.post("/chat")
async def chat(request):
    print("chat")
    return await agent.handle_text("Hi", sender_id=uuid6.uuid7().hex)

app.start(port=8080)

when i run the above server stuck processing the request even tried via post man as you can see it stuck in the logs as slots values and does not process ---logs-- chat DEBUG:rasa.core.lock_store:Issuing ticket for conversation '018a0a6363af764ba677c15c824fbdb8'. DEBUG:rasa.core.lock_store:Acquiring lock for conversation '018a0a6363af764ba677c15c824fbdb8'. DEBUG:rasa.core.lock_store:Acquired lock for conversation '018a0a6363af764ba677c15c824fbdb8'. DEBUG:rasa.core.tracker_store:Could not find tracker for conversation ID '018a0a6363af764ba677c15c824fbdb8'. DEBUG:rasa.core.processor:Starting a new session for conversation ID '018a0a6363af764ba677c15c824fbdb8'. DEBUG:rasa.core.processor:Policy prediction ended with events '[]'. DEBUG:rasa.core.processor:Action 'action_session_start' ended with events '[<rasa.shared.core.events.SessionStarted object at 0x7ffa23ff6be0>, ActionExecuted(action: action_listen, policy: None, confidence: None)]'. DEBUG:rasa.core.processor:Current slot values: doc_url: None document: None video: None audio: None image: None kairon_action_response: None bot: 64de24d9fad53e0694a04261 session_started_metadata: None

Steps to Reproduce

No response

Your operating system

Linux

Your Python version (python --version)

3.8

Your Robyn version

latest

Additional Info

No response

sansyrox commented 11 months ago

@sfahad1414 , can you please share the model too?

sfahad1414 commented 11 months ago

model is available in the repo https://github.com/sfahad1414/RasaRobyn.git

sansyrox commented 11 months ago

Hey @sfahad1414 👋

The rasa model being used requires a Python version <3.8, which is no longer supported by the Python community.

sansyrox commented 11 months ago

The issue will go away if you will use an updated model. Do let me know if you have any more questions 😄

sfahad1414 commented 11 months ago

even training model on python 3.8.17 now models loads but hang on inference model: https://github.com/sfahad1414/RasaRobyn/blob/main/models/20230820-074946-asphalt-ocean.tar.gz

2023-08-20 21:48:33 [debug ] processor.actions.policy_prediction prediction_events=[] 2023-08-20 21:48:33 [debug ] processor.actions.log action_name=action_session_start rasa_events=[<rasa.shared.core.events.SessionStarted object at 0x7f2f33288d90>, ActionExecuted(action: action_listen, policy: None, confidence: None)] 2023-08-20 21:48:33 [debug ] processor.slots.log slot_values= doc_url: None document: None video: None audio: None image: None kairon_action_response: None bot: 64de24d9fad53e0694a04261 session_started_metadata: None

sfahad1414 commented 11 months ago

Hi @sansyrox 👋, did you tried the new model

sansyrox commented 11 months ago

Hey @sfahad1414 👋

I didn't enough time in the past two days. I will get back to you by Friday 😄

sansyrox commented 11 months ago

Hey @sfahad1414 👋

I tried running you repo but I am getting the following issue

INFO:robyn.logger:SERVER IS RUNNING IN VERBOSE/DEBUG MODE. Set --log-level to WARN to run in production mode.
INFO:rasa.core.processor:Loading model ./models/20230818-091151.tar.gz...
Traceback (most recent call last):
  File "app.py", line 6, in <module>
    agent = Agent.load("./models/20230818-091151.tar.gz")
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/core/agent.py", line 345, in load
    agent.load_model(model_path=model_path, fingerprint=fingerprint)
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/core/agent.py", line 352, in load_model
    self.processor = MessageProcessor(
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 101, in __init__
    self.model_filename, self.model_metadata, self.graph_runner = self._load_model(
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 138, in _load_model
    metadata, runner = loader.load_predict_graph_runner(
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/engine/loader.py", line 26, in load_predict_graph_runner
    model_storage, model_metadata = model_storage_class.from_model_archive(
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/engine/storage/local_model_storage.py", line 86, in from_model_archive
    cls._extract_archive_to_directory(
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/engine/storage/local_model_storage.py", line 128, in _extract_archive_to_directory
    LocalModelStorage._assert_not_rasa2_archive(temporary_directory)
  File "/Users/sanskar/test_dumpster/RasaRobyn/venv/lib/python3.8/site-packages/rasa/engine/storage/local_model_storage.py", line 137, in _assert_not_rasa2_archive
    raise UnsupportedModelVersionError(
rasa.exceptions.UnsupportedModelVersionError: The model version is trained using Rasa Open Source 2.8.15 and is not compatible with your current installation which supports models build with Rasa Open Source 3.5.0 or higher. This means that you either need to retrain your model or revert back to the Rasa version that trained the model to ensure that the versions match up again.

Is your requirements.txt file in sync with the required dependencies?

sfahad1414 commented 11 months ago

@sansyrox use this model https://github.com/sfahad1414/RasaRobyn/blob/main/models/20230820-074946-asphalt-ocean.tar.gz it is train on rasa 3 version on python 3.10 Also requirements.txt is updated

sfahad1414 commented 10 months ago

@sansyrox did you tried the new model and requirements.txt

sansyrox commented 10 months ago

Hey @sfahad1414 👋

I did but I am unable to replicate the bug. Can you please create an isolated environment so that I can reproduce this bug?

sfahad1414 commented 10 months ago

@sansyrox added the Dockerfile https://github.com/sfahad1414/RasaRobyn/blob/main/Dockerfile

sfahad1414 commented 10 months ago

@sansyrox did you tried this

sansyrox commented 10 months ago

Hey @sfahad1414 👋

Your repo still errors out.

Here is the error I get

31   Stored in directory: /root/.cache/pip/wheels/85/52/e7/dfa571c9f9b879e3facaa1584f52be04c4c3d1e14054ef40ab
#9 76.31   Building wheel for python-crfsuite (setup.py): started
#9 76.47   Building wheel for python-crfsuite (setup.py): finished with status 'error'
#9 76.47   error: subprocess-exited-with-error
#9 76.47
#9 76.47   × python setup.py bdist_wheel did not run successfully.
#9 76.47   │ exit code: 1
#9 76.47   ╰─> [24 lines of output]
#9 76.47       running bdist_wheel
#9 76.47       running build
#9 76.47       running build_py
#9 76.47       creating build
#9 76.47       creating build/lib.linux-aarch64-cpython-310
#9 76.47       creating build/lib.linux-aarch64-cpython-310/pycrfsuite
#9 76.47       copying pycrfsuite/_logparser.py -> build/lib.linux-aarch64-cpython-310/pycrfsuite
#9 76.47       copying pycrfsuite/__init__.py -> build/lib.linux-aarch64-cpython-310/pycrfsuite
#9 76.47       copying pycrfsuite/_dumpparser.py -> build/lib.linux-aarch64-cpython-310/pycrfsuite
#9 76.47       running build_ext
#9 76.47       building 'pycrfsuite._pycrfsuite' extension
#9 76.47       creating build/temp.linux-aarch64-cpython-310
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/lib
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/lib/cqdb
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/lib/cqdb/src
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/lib/crf
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/lib/crf/src
#9 76.47       creating build/temp.linux-aarch64-cpython-310/crfsuite/swig
#9 76.47       creating build/temp.linux-aarch64-cpython-310/liblbfgs
#9 76.47       creating build/temp.linux-aarch64-cpython-310/liblbfgs/lib
#9 76.47       creating build/temp.linux-aarch64-cpython-310/pycrfsuite
#9 76.47       gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -I/usr/local/include/python3.10 -c -std=c99 crfsuite/lib/cqdb/src/cqdb.c -o build/temp.linux-aarch64-cpython-310/crfsuite/lib/cqdb/src/cqdb.o
#9 76.47       error: command 'gcc' failed: No such file or directory
#9 76.47       [end of output]
#9 76.47
#9 76.47   note: This error originates from a subprocess, and is likely not a problem with pip.
#9 76.47   ERROR: Failed building wheel for python-crfsuite
#9 76.47   Running setup.py clean for python-crfsuite
#9 76.60   Building wheel for fire (setup.py): started
#9 76.78   Building wheel for fire (setup.py): finished with status 'done'
#9 76.78   Created wheel for fire: filename=fire-0.5.0-py2.py3-none-any.whl size=116934 sha256=71691e5aaffa38fe218a3cd7cf9b9126fbe0a92f85577171a10fb3e34160bf77
#9 76.78   Stored in directory: /root/.cache/pip/wheels/90/d4/f7/9404e5db0116bd4d43e5666eaa3e70ab53723e1e3ea40c9a95
#9 76.78   Building wheel for future (setup.py): started
#9 77.11   Building wheel for future (setup.py): finished with status 'done'
#9 77.12   Created wheel for future: filename=future-0.18.3-py3-none-any.whl size=492024 sha256=caba1310c711b9fc168b5c361a7990cc57ed3f3399545f7325d65a61532ff494
#9 77.12   Stored in directory: /root/.cache/pip/wheels/5e/a9/47/f118e66afd12240e4662752cc22cefae5d97275623aa8ef57d
#9 77.12 Successfully built jieba mattermostwrapper randomname docopt jax fire future
#9 77.12 Failed to build python-crfsuite
#9 77.12 ERROR: Could not build wheels for python-crfsuite, which is required to install pyproject.toml-based projects
------
executor failed running [/bin/sh -c python -m pip install -r requirements.txt]: exit code: 1
sansyrox commented 2 months ago

still open, will work on a single process, but need to fix the multiprocess issue