Rasa socket.io vs Rasa 2.6 + Action server

I’m stuck!

I made chatbot with Rasa 2.6 and action server 2.6. It works in shell mode and then I moved to test with webchat client. Rasa failed to socket.io error, which have been issue since version 2.2. So I downgraded Action server to 2.2 but then Action server failed with error

ModuleNotFoundError: No module named ‘typing_extensions’

So I’m stuck between version 2.6 and 2.2

Rasa Open Source #actionserver #socketio #rasaopensource

@InnoOmnia

Install

pip install typing_extensions

Thanks, but no success, here are my files, first is Dockerfile

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:2.2.0
#COPY * /app/

# Use subdirectory as working directory
WORKDIR /app

# Copy any additional custom requirements, if necessary (uncomment next line)
# COPY actions/requirements-actions.txt ./

# Change back to root user to install dependencies
USER root

# Install extra requirements for actions code, if necessary (uncomment next line)
# RUN pip install -r requirements-actions.txt
# RUN pip install typing_extensions


# Copy actions folder to working directory
COPY ./actions /app/actions
RUN python -m pip install --upgrade pip
RUN pip install typing_extensions

# By best practices, don't run the code with root user
USER 1003

Build command

docker build . -t rasa-sdk:2.2.0

and result is OK

Sending build context to Docker daemon  307.1MB
Step 1/7 : FROM rasa/rasa-sdk:2.2.0
2.2.0: Pulling from rasa/rasa-sdk
6ec7b7d162b2: Already exists
80ff6536d04b: Already exists
6c51d3836e95: Already exists
6ce84404158b: Already exists
d1817f658433: Pull complete
301122597d6c: Pull complete
4ec2479de91d: Pull complete
53cac69fa762: Pull complete
Digest: sha256:92bea9ac4f04357bff9a5e154fbf30689206026922260162944c33ebbe694ee8
Status: Downloaded newer image for rasa/rasa-sdk:2.2.0
 ---> a1c9443b5df6
Step 2/7 : WORKDIR /app
 ---> Running in 4dbcb48199d3
Removing intermediate container 4dbcb48199d3
 ---> edb4342640b1
Step 3/7 : USER root
 ---> Running in 7d681f68e54c
Removing intermediate container 7d681f68e54c
 ---> fc526d08277c
Step 4/7 : COPY ./actions /app/actions
 ---> 629548f08adc
Step 5/7 : RUN python -m pip install --upgrade pip
 ---> Running in 2a76b670937a
Requirement already satisfied: pip in /opt/venv/lib/python3.7/site-packages (20.3.1)
Collecting pip
  Downloading pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.3.1
    Uninstalling pip-20.3.1:
      Successfully uninstalled pip-20.3.1
Successfully installed pip-21.1.2
Removing intermediate container 2a76b670937a
 ---> 188501b97be6
Step 6/7 : RUN pip install typing_extensions
 ---> Running in c3b9f090c59e
Collecting typing_extensions
  Downloading typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)
Installing collected packages: typing-extensions
Successfully installed typing-extensions-3.10.0.0
Removing intermediate container c3b9f090c59e
 ---> a7fa7f5c56fc
Step 7/7 : USER 1003
 ---> Running in a3a20672353d
Removing intermediate container a3a20672353d
 ---> c06511f24867
Successfully built c06511f24867
Successfully tagged rasa-sdk:2.2.0

So Successfully installed typing-extensions-3.10.0.0

Then container creation command

docker run -v $(pwd)/actions:/app/actions --net action-link --name action-server-prod rasa/rasa-sdk:2.2.0

And fail

2021-06-15 07:06:40 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2021-06-15 07:06:40 ERROR    rasa_sdk.executor  - Failed to register package 'actions'.
Traceback (most recent call last):
  File "/app/rasa_sdk/executor.py", line 254, in register_package
    self._import_submodules(package)
  File "/app/rasa_sdk/executor.py", line 217, in _import_submodules
    self._import_module(full_name)
  File "/app/rasa_sdk/executor.py", line 231, in _import_module
    module = importlib.import_module(name)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/actions/actions.py", line 5, in <module>
    from rasa_sdk.types import DomainDict
  File "/app/rasa_sdk/types.py", line 3, in <module>
    from typing_extensions import TypedDict
ModuleNotFoundError: No module named 'typing_extensions'

What to try next?

@InnoOmnia Check both the container rasa2.6 and rasa action server container’s, that they have the typing_extensions or not and even check the action.py that you have import the typing?

Try executing the code without docker files or docker-compose on the local machine.

I got it working, fault and solution

First Docker file, small changes, but no solution

# Extend the official Rasa SDK image
FROM rasa/rasa-sdk:2.2.0
#COPY * /app/

# Use subdirectory as working directory
WORKDIR /app

# Copy any additional custom requirements, if necessary (uncomment next line)


# Change back to root user to install dependencies
USER root

# Install extra requirements for actions code, if necessary (uncomment next line)


# Copy actions folder to working directory
COPY ./actions /app/actions

# Install extra requirements for actions code, if necessary (uncomment next line)
RUN python -m pip install --upgrade pip
RUN pip install --no-cache-dir typing_extensions

# By best practices, don't run the code with root user
USER 1003

after that this command

docker build . -t rasa-sdk:2.2.1

It created these two images

[paulii@vetbot-v4 /pilleribot TUOTANTO]$ docker images
REPOSITORY      TAG          IMAGE ID       CREATED          SIZE
rasa-sdk        2.2.1        99378085f6d5   57 minutes ago   165MB
rasa/rasa-sdk   2.2.0        a1c9443b5df6   6 months ago     151MB

and then this command

docker run -v $(pwd)/actions:/app/actions --net action-link --name action-server-prod rasa/rasa-sdk:2.2.0

and that was the fault. Docker build two images, original (rasa/rasa-sdk 2.2.0) and modified one (rasa-sdk 2.2.1). In the command I run, I used rasa/rasa-sdk:2.2.0, which pointed to original sdk image, which, of course don’t have typing_extensions installed.

SOLUTION
Run command

docker run -v $(pwd)/actions:/app/actions --net action-link --name action-server-prod rasa-sdk:2.2.1

which points to modified (and right) docker image (rasa-sdk:2.2.1 )

1 Like