Rasa X Docker error while training with Spacy language model

Hello, I’m using Rasa X with docker and I keep getting an error when training with Spacy’sfrench model.

Here’s the error I have when training:

## Training failed
An unexpected error occurred during training. Error: Please confirm that fr_core_news_md is an available spaCy model. You need to download one upfront. For example:
python -m spacy download en_core_web_md
More informaton can be found on https://rasa.com/docs/rasa/components#spacynlp

Here’s my Dockerfile:

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

# 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

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

# Download Spacy models
RUN python3 -m spacy download fr_core_news_md
RUN python3 -m spacy link fr_core_news_md fr

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

And finaly here’s my config.yml:

language: fr
pipeline:
  - name: SpacyNLP
    model: fr_core_news_md
  - name: SpacyTokenizer
  - name: SpacyFeaturizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100

I don’t have a ton of experience with Docker, but it proved to be the easiest method to install Rasa X on my machine. Do I need to rebuild the docker image after adding the download instruction or a simple docker-compose down and docker-compose up is enough? Also, do I extend the right image? I followed the Youtube tutorial to add a custom action server (which works fine) and just added the Spacy’s model instruciton in the Dockerfile, but I wonder if its part of rasa/rasa-sdk or some other image.

Thank you for pointing me in the right direction.

I guess you followed rasa-x customized docker-compose installation. If you changed the Dockerfile, run “docker-compose up --build” to rebuild the images before running containers. You can include changes in /etc/rasa/docker-compose.override.yml services definition file.

Yes, I followed the Docker Compose section along with these instruction to build the image and followed this live coding session that basically reproduced the same step as the documentation.

I did try “docker-compose up --build” without success, but it was a nice reminder of you, it pointed me in the right direction I think. I did rebuild the image with

docker build . -t <account_username>/<repository_name>:<custom_image_tag>

and pushed it with

docker login --username <account_username> --password <account_password>
docker push <account_username>/<repository_name>:<custom_image_tag>

Finaly, I changed the value of the image in the docker-compose.override.yml as such.

version: '3.4'
services:
  app:
    image: <account_username>/<repository_name>:<new_custom_image_tag>

I’m still getting the same error, but I have seen the spacy model download while rebuilding the Docker. Now I’m pretty sure I might simply not be extending the right image.

I’ll keep digging into it.

Ok, so now I did change my Docker file for the following

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

# 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

# Copy actions folder to working directory
COPY ./actions /app/actions
# By best practices, don't run the code with root user
USER 1001

# Extend the official Rasa image
FROM rasa/rasa:main-full
WORKDIR /app
# Change back to root user to install dependencies
USER root

# Download Spacy models
RUN python -m spacy download fr_core_news_md

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

I can see in the logs while building the image that it download and install the languague package.

Successfully installed fr-core-news-md-3.2.0
✔ Download and installation successful
You can now load the package via spacy.load('fr_core_news_md')

I’m still getting the same error, what am I doing wrong? Is there a way to inspect the running app to see if the package is properly installed?

Ok, so now I realized I was extending two images in the same Docker repo which is probably why it didn’t work. I’m now extending both image independently and create a repository for each of them which actually makes sense.

I now have two Dockerfiles…

“Dockerfile.action” which is the following:

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

# 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

# Copy actions folder to working directory
COPY ./actions /app/actions
# By best practices, don't run the code with root user
USER 1001

and “Dockerfile.language” which is the following

# Extend the official Rasa image
FROM rasa/rasa:main-full
WORKDIR /app
# Change back to root user to install dependencies
USER root

# Download Spacy models
RUN python -m spacy download fr_core_news_md

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

I built and push both on my Docker Hub, great.

Now I’m having some issues about what I should overide in the “docker-compose.override.yml”

I’ve tried those without success:

Finaly, I changed the value of the image in the docker-compose.override.yml as such.

version: '3.4'
services:
  rasa:
    image:<account_username>/<language-repository_name>:<custom_image_tag>
  app:
    image: <account_username>/<action-repository_name>:<custom_image_tag>

and

version: '3.4'

x-rasa-services:
    image:<account_username>/<language-repository_name>:<custom_image_tag>

services:
  app:
    image: <account_username>/<action-repository_name>:<custom_image_tag>

Anyone has a pointer on this?

Ok so I made it work by changing the rasa image in the docker-compose.yml directly but I’m pretty sure it’s not the ideal way to do it.

What’s the properway to override the x-rasa-services image in the dockerfile?

@mrsaboteur can you confirm on which ports these images are running docker ps -a ?