RASA Docker custom channel

Hi Rasa team.

I have created custom channel in local environment its working fine(ubuntu, apache).

but in production mode(docker, nginx) my custom channel is not working, getting module not found error

  • my project installation path is /etc/rasa
  • custom connector file is located in: /etc/rasa/MyIo.py
  • I set pythonenv for custom connecter in Dockerfile

MyIo.py (4.9 KB) credentials.yml (55 Bytes) Dockerfile (766 Bytes)

Please, can anyone help me to fix this issue?

Hi @siva_g,

is the custom connector placed in your ./actions folder? Or are you mounting a volume to /etc/rasa? I’m asking cause your file MyIO.py has to be reachable from inside the container. Furthermore, you have to override the used Docker images to you use your custom one (ideally in the docker-compose.override.yml)

Hi @Tobias_Wochinger,

Tnx for you reply.

  • custom connetor is located in /etc/rasa (/etc/rasa/MyIo.py)

  • and i copied MyIo.py in Dockerfile.

  • then i build the Dockerfile using below comment. docker build . -t sivanandh:action_v1_160620201049

  • then i mentioned the build name in docker-compose.override.yml.

then i started my docker-compose up -d

Doubt: Can i use my custom channel inside my ./actions folder??

please check my updated Dockerfile.Dockerfile (749 Bytes)

@Tobias_Wochinger, Please help me to fix

Hi @siva_g. I am trying to find hangouts.py file in docker image file. Could you please tell me where can I find it?

Thanks, Akhil.

Doubt: Can i use my custom channel inside my ./actions folder??

Yes. The .actions folder shouldn’t be read by anything to be honest.

please check my updated Dockerfile.Dockerfile (749 Bytes)

I think the reason might be that the custom channel is not in the PYTHONPATH and hence not found. Can you try setting it? It’s the same procedure as it’s described here for custom NLU components.

What exactly is the log message when you run it and it tries to find the channel?

Hello @Tobias_Wochinger,

i updated my Dockerfile like below:

Dockerfile:

    # Extend the official Rasa SDK image
    FROM rasa/rasa-sdk:1.10.0

    # Use subdirectory as working directory
    WORKDIR /app

    # Change back to root user to install dependencies
    USER root

    # Install extra requirements for actions code
    RUN pip3 install --upgrade pip && \
    pip3 install --no-cache-dir boto3 fuzzywuzzy matplotlib && \
    pip3 install --no-cache-dir mysql-connector pandas requests

    # actions folder to working directory
    COPY ./actions /app/actions
    COPY ./pdf_report /app/pdf_report
    COPY ./MyIo.py /app/MyIo.py

    ENV PYTHONPATH=$PYTHONPATH:/app

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

credentials.yml

    rasa:
      url: ${RASA_X_HOST}/api
   
   rest:
   
   MyIo.RestInput:

Getting Error:

    ModuleNotFoundError: No module named 'MyIo'

    Exception: Failed to find input channel class for 'MyIo.RestInput'. Unknown input channel.

Can you please try moving the ENV line after USER 1001? Maybe it doesn’t apply when the user was switched :thinking: Can you please also share the docker-compose.override.yml?

@Tobias_Wochinger,

as you suggested i moved ENV line at the last of the Dockerfile , still i am facing

    ModuleNotFoundError: No module named 'MyIo'

    Exception: Failed to find input channel class for 'MyIo.RestInput'. Unknown input channel.

is there anything need to try??? custom connector path is not set in docer container.

How does your docker-compose.override.yml look like? In your custom Docker image, what’s the output of python -c "import MyIo.RestInput" ?

Hi, i run python3 -c "import MyIo.RestInput" in docker container shell, and getting below error:

`ModuleNotFoundError: No module named 'MyIo.RestInput'; 'MyIo' is not a package``

docker-compose.override.yml:

 version: '3.4'
 services:
  app:
    image: action_v1:210620200944

i am not that much familiar with docker. please help me to fix this issue.

Hi, i run python3 -c "import MyIo.RestInput" in docker container shell, and getting below error:

mhm, but that means that the package is not in PYTHONPATH. What’s the output of echo $PYTHONPATH ?

when I try cat $PYTHONPATH in container shell I am getting below output:

root@3ed3d3e9875b:/app# cat $PYTHONPATH

cat: /app: Is a directory

when I try env

root@3ed3d3e9875b:/app# env

PYTHONPATH=/app PATH=/opt/venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

@siva_g I just tried it myself and it works just fine :exploding_head:

A few other ideas / questions:

  • Why are you root in your terminal? Should be 1001, shouldn’t it?
  • maybe try to add a __init__.py to the /app folder
  • Why are you mounting a custom channel in the action image? Should rather be the Rasa Open Source image, shouldn’t it?
  • Why are you root in your terminal? Should be 1001 , shouldn’t it?

    yes i did some changes in Dockerfile, now i reverted for 1001

  • maybe try to add a __init__.py to the /app folder

    I have no name!@da74e77c3218:/app$ ls -al
    -rw-r--r-- 1 root root     0 Jun 17 16:44 __init__.py
    drwxrwxrwx 1 root root  4096 Jul  1 03:24 actions
    -rwxrwxrwx 1 root root   160 Jun 27 16:46 docker-compose.override.yml
    -rwxrwxrwx 1 root root  4206 Jun 17 16:30 docker-compose.yml
    .......(all files)
    
  • Why are you mounting a custom channel in the action image? Should rather be the Rasa Open Source image, shouldn’t it?

    sorry @Tobias_Wochinger, as per : mine I am building the custom image for the action server only, I am not building a custom image for the custom channel. please suggest me some solution if anything wrong :neutral_face:

can you please suggest me how can I add a custom channel in Rasa open source image. :roll_eyes:

can you please suggest me how can I add a custom channel in Rasa open source image. :roll_eyes:

In this case you have to extend the image rasa/rasa:1.10.4-full (or one of its variants). The process is very much the same as for the action server.

In the docker-compose.override.yml you wouldn’t override the app service but, rasa-production and rasa-worker:

 version: '3.4'
 services:
  rasa-production:
    image: your_extended_rasa_open_source_image
  rasa-worker:
    image: your_extended_rasa_open_source_image

Maybe this picture of the architecture also helps.

I have spent two days to firgure it out, and I have done.

The problem was missing packages… which was supposed to be installed when docker image is being made…

When it comes to a custom connector, rasa does not show the proper error message If necessary packages are missing(mysqlclient in my case) It could be another reason that causes the error, but I am pretty sure the problem is neither about PYTHONPATH nor module paths

My suggestion is that you have to check what packages are missing…

I hope you figure it out soon