Error when trying to expand the environment variables in '${RASA_MODEL_SERVER}'

Hi,

I try to run the command rasa run from my server and I get this error:

ValueError: Error when trying to expand the environment variables in '${RASA_MODEL_SERVER}'. Please make sure to also set these environment variables: '['${RASA_MODEL_SERVER}']'.

What can be the reason for that? Thank you, Tiziano

hi @tiziano how have you set up Rasa X?

Following this guide

This variable should be set automatically as part of the docker-compose setup. Can you please share your docker-compose file (+ potential .override.yml)?

Sure, this is my docker-compose.yml file:

version: "3.4"

x-database-credentials: &database-credentials
  DB_HOST: "db"
  DB_PORT: "5432"
  DB_USER: "${DB_USER:-admin}"
  DB_PASSWORD: "${DB_PASSWORD}"
  DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"

x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "user"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-redis-credentials: &redis-credentials
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  REDIS_PASSWORD: ${REDIS_PASSWORD}
  REDIS_DB: "1"

x-duckling-credentials: &duckling-credentials
  RASA_DUCKLING_HTTP_URL: "http://duckling:8000"

x-rasax-credentials: &rasax-credentials
  LOCAL_MODE: "false"
  RASA_X_HOST: "http://rasa-x:5002"
  RASA_X_TOKEN: ${RASA_X_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5055"
  RASA_PRODUCTION_HOST: "http://rasa-production:5005"
  RASA_WORKER_HOST: "http://rasa-worker:5005"
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_WORKER_TOKEN: ${RASA_TOKEN}

x-rasa-credentials: &rasa-credentials
  <<: *rabbitmq-credentials
  <<: *rasax-credentials
  <<: *database-credentials
  <<: *redis-credentials
  <<: *duckling-credentials
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_MODEL_PULL_INTERVAL: 10
  RABBITMQ_QUEUE: "rasa_production_events"

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x
    - rabbit
    - redis

services:
  action_server:
    image: pandasimg:latest
    volumes:
      - ./actions:/app/actions
  rasa-x:
    restart: always
    image: "rasa/rasa-x:${RASA_X_VERSION}"
    expose:
      - "5002"
    volumes:
      - ./models:/app/models
      - ./environments.yml:/app/environments.yml
      - ./credentials.yml:/app/credentials.yml
      - ./endpoints.yml:/app/endpoints.yml
      - ./logs:/logs
      - ./auth:/app/auth
    environment:
      <<: *database-credentials
      <<: *rasa-credentials
      SELF_PORT: "5002"
      DB_DATABASE: "${DB_DATABASE:-rasa}"
      RASA_MODEL_DIR: "/app/models"
      PASSWORD_SALT: ${PASSWORD_SALT}
      RABBITMQ_QUEUE: "rasa_production_events"
      RASA_X_USER_ANALYTICS: "0"
      SANIC_RESPONSE_TIMEOUT: "3600"
      METRICS_CONSENT: "${METRICS_CONSENT:-false}"
      UUID: "${UUID:-''}"
    depends_on:
      - db

  rasa-production:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "production"
      DB_DATABASE: "tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  rasa-worker:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "worker"
      DB_DATABASE: "worker_tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  app:
    restart: always
    image: "rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
    expose:
      - "5055"
    depends_on:
      - rasa-production

  db:
    restart: always
    image: "bitnami/postgresql:11.3.0"
    expose:
      - "5432"
    environment:
      POSTGRESQL_USERNAME: "${DB_USER:-admin}"
      POSTGRESQL_PASSWORD: "${DB_PASSWORD}"
      POSTGRESQL_DATABASE: "${DB_DATABASE:-rasa}"
    volumes:
      - ./db:/bitnami/postgresql

  rabbit:
    restart: always
    image: "bitnami/rabbitmq:3.7.17"
    environment:
      RABBITMQ_HOST: "rabbit"
      RABBITMQ_USERNAME: "user"
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
      RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
    expose:
      - "5672"

  duckling:
    restart: always
    image: "rasa/duckling:latest"
    expose:
      - "8000"
    command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

  nginx:
    restart: always
    image: "rasa/nginx:${RASA_X_VERSION}"
    ports:
      - "80:8080"
      - "443:8443"
    volumes:
      - ./certs:/opt/bitnami/certs
      - ./terms:/opt/bitnami/nginx/conf/bitnami/terms
    depends_on:
      - rasa-x
      - rasa-production
      - app

  redis:
    restart: always
    image: "bitnami/redis:5.0.5"
    ports:
      - "6379:6379"
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD}

  logger:
    restart: always
    image: "rasa/logger:${RASA_X_VERSION}"
    command: ["/bin/sh", "-c", "docker-compose logs --no-color -f > /logs/compose_`date '+%Y-%m-%d_%H:%M:%S'`.log"]
    volumes:
      - ./logs:/logs
      - ./.env/:/etc/rasa/.env
      - ./docker-compose.yml:/etc/rasa/docker-compose.yml
      - /var/run/docker.sock:/var/run/docker.sock
    working_dir: /etc/rasa
    depends_on:
      - nginx
      - duckling

And this is the docker-compose.override.yml:

version: '3.4'
services:
  app:
    image: pandasimg:latest

@tiziano and you’ve started up Rasa X with docker-compose up -d? I noticed you said in your original post you’re trying to do rasa run, so my question is where you’re doing that from? You shouldn’t need to do that once your docker compose setup is up and running

Hi @akelad, thanks for replying. I made sure to run docker-compose down before trying rasa run.

are you running rasa run from a separate directory though? Also, do you have Rasa X deployed with docker on your local machine or on a VM?

What I don’t have clear is how I can use Rasa from the command line on the server if all my conversational data are stored in GitHub? If I just do rasa run from a random directory it obviously tells me that can’t find the requested files.

it’s on my server

Why do you want to use rasa on the command line on your server? That’s something that you would do locally. You can talk to your bot through the UI on Rasa X if you want to test what’s deployed on your server

Because not everything is available to use on Rasa X. For example I may want to have a debug log of the conversation with information on which policy is triggered, what confidence is given to each intent, what are the errors in the custom actions if any, etc.

Makes sense. One option for this is to enable verbose logging on the rasa-production container, by adding the --debug flag to the start command. And errors in custom actions can be found in the app logs.

If you’re developing your bot heavily however, I think using rasa locally on your machine makes more sense. You should be able to sync everything between local mode and your server using Integrated Version Control. Rasa X becomes most useful once you’ve got an initial version of your bot running and want to have users test your bot or when you have your bot in production, and then want to improve your bot based on those conversations. Read more here: Rasa Open Source + Rasa X: Better Together

You’re right, I’ll do it, thank you for that.

Could you please give me some more information on where I should add the --debug flag (which start command?) and where to find the app logs?

@tiziano is there anything we could have done to make that distinction between Rasa and Rasa X clearer in the docs?

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --debug
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"

The --debug flag would go in the rasa service command as shown above ^

Getting the logs of the different containers can be done with docker-compose logs app or docker-compose logs rasa-production

I would have put what you told me before a bit more clear in the docs. That is, the fact that you should first make all the major changes locally and just when you have all functioning good switch to Rasa X on a server. And also that once that you cannot use Rasa from command line if you’re using Rasa X on a server.

Alright, very clear, thank you so much!

P.S. when checked for my app logs I found an error and opened this topic.

P.P.S and when checked for my rasa-production logs I found other errors and opened another topic.