Skip to content Skip to sidebar Skip to footer

Is There A Way To Download Textblob Corpora To Google Cloud Run?

I am using Python with TextBlob for sentiment analysis. I want to deploy my app (build in Plotly Dash) to Google Cloud Run with Google Cloud Build (without using Docker). When usin

Solution 1:

Since Cloud Run creates and destroys containers as needed for your traffic levels you'll want to embed your corpora in the pre-built container to ensure a fast cold start time (instead of downloading it when the container starts)

The easiest way to do this is add another line inside of a docker file that downloads and installs the corpora at build time like so:

RUN python -m textblob.download_corpora 

Here's a full docker file for your reference:

# Python image to use.
FROM python:3.8

# Set the working directory to /app
WORKDIR /app

# copy the requirements file used for dependencies
COPY requirements.txt .

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
RUN python -m textblob.download_corpora

# Copy the rest of the working directory contents into the container at /app
COPY . .

# Run app.py when the container launches
ENTRYPOINT ["python", "app.py"]

Good luck, Josh

Post a Comment for "Is There A Way To Download Textblob Corpora To Google Cloud Run?"