How do I import rasa model from bucket s3 correctly?

I have my dockerfile that configure AWS Credentials, I do not have problem with this.

RUN aws configure set AWS_ACCESS_KEY_ID $AWS_ACCESS_KEY_ID \
&& aws configure set AWS_SECRET_ACCESS_KEY $AWS_SECRET_ACCESS_KEY \
&& aws configure set AWS_REGION $AWS_REGION

ARG AWS_ENDPOINT_URL=https://s3.us-east-1.amazonaws.com
ENV AWS_ENDPOINT_URL=${AWS_ENDPOINT_URL}
ARG BUCKET_NAME=pagnotr
ENV BUCKET_NAME=${BUCKET_NAME}

Example:

  • BUCKET_NAME: s3://pagnotr
  • SPECIFIC_PATH_MODEL: s3://pagnotr/0.0.0/model.tar.gz

When I run the command below

rasa run -m nlu-20220309-154118.tar.gz --remote-storage aws --enable-api --log-file ./rasa_api.log --verbose --port MYPORT

I obtain this error:

2022-03-22 14:52:27 INFO     root  - Starting Rasa server on http://localhost:PORT
2022-03-22 14:52:29 INFO     botocore.credentials  - Found credentials in environment variables.
2022-03-22 14:52:29 ERROR    rasa.core.agent  - Could not load model due to Parameter validation failed:
Invalid type for parameter CreateBucketConfiguration.LocationConstraint, value: None, type: <class 'NoneType'>, valid types: <class 'str'>.
/opt/venv/lib/python3.8/site-packages/rasa/shared/utils/io.py:96: UserWarning: The model at 'mymodel.tar.gz' could not be loaded. Error: <class 'botocore.exceptions.ParamValidationError'>: Parameter validation failed:
Invalid type for parameter CreateBucketConfiguration.LocationConstraint, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
/opt/venv/lib/python3.8/site-packages/rasa/shared/utils/io.py:96: UserWarning: Agent could not be loaded with the provided configuration. Load default agent without any model.
2022-03-22 14:52:29 INFO     root  - Rasa server is up and running.

I was missing to set environment variable AWS_DEFAULT_REGION, but after this I run and other error occurred:

rasa run -m nlu-20220309-154118.tar.gz --remote-storage aws --enable-api --log-file ./rasa_api.log --verbose --port MYPORT
2022-03-22 15:20:59 INFO     root  - Starting Rasa server on http://localhost:PORT
2022-03-22 15:21:01 INFO     botocore.credentials  - Found credentials in environment variables.
2022-03-22 15:21:02 ERROR    rasa.core.agent  - Could not load model due to An error occurred (404) when calling the HeadObject operation: Not Found.
/opt/venv/lib/python3.8/site-packages/rasa/shared/utils/io.py:96: UserWarning: The model at 'nlu-20220309-154118.tar.gz' could not be loaded. Error: <class 'botocore.exceptions.ClientError'>: An error occurred (404) when calling the HeadObject operation: Not Found
/opt/venv/lib/python3.8/site-packages/rasa/shared/utils/io.py:96: UserWarning: Agent could not be loaded with the provided configuration. Load default agent without any model.
2022-03-22 15:21:02 INFO     root  - Rasa server is up and running.

I solved this by passing the exact path of the model file without the bucket name in the start string

rasa run -m path/model --remote-storage aws --enable-api --log-file ./rasa_api.log --verbose --port MYPORT
rasa run -m 0.0.0/nlu-20220309-154118.tar.gz --remote-storage aws --enable-api --log-file ./rasa_api.log --verbose --port MYPORT
1 Like