Spaces:
Sleeping
Sleeping
File size: 1,417 Bytes
775b8b4 a5fed35 2a30eb1 775b8b4 2a30eb1 a5fed35 b2a5e86 775b8b4 03eec87 a5fed35 ca2592c b2a5e86 ca2592c a5fed35 775b8b4 03eec87 a3e3b16 03eec87 775b8b4 2a30eb1 4a35568 2a30eb1 775b8b4 1114dde |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
FROM python:3.10-slim as base
# Set up the user for huggingface hub, avoids permission issues
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/comma-fixer
ENV PYTHONUNBUFFERED=1
RUN python -m venv venv
ENV PATH="$HOME/comma-fixer/venv/bin:$PATH"
# TODO use requirements after all, since for setup.py to work properly we need the whole source code which breaks cache
COPY --chown=user . .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade .
# This pre-downloads models and tokenizers
# TODO should we give user an option to provide local models so that they don't donwload each time?
RUN python commafixer/src/baseline.py
RUN python commafixer/src/fixer.py
FROM base as test
RUN pip install .[test]
# TODO don't run all at once because of memory errors?
RUN python -m pytest tests
FROM python:3.10-slim as deploy
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/comma-fixer
COPY --chown=user --from=base $HOME/comma-fixer $HOME/comma-fixer
COPY --chown=user --from=base $HOME/comma-fixer/venv $HOME/comma-fixer/venv
ENV PATH="$HOME/comma-fixer/venv/bin:$PATH"
# Copy pre-downloaded models and make sure we are using the env
COPY --chown=user --from=base $HOME/.cache/huggingface $HOME/.cache/huggingface
EXPOSE 8000
CMD uvicorn "app:app" --port 8000 --host "0.0.0.0" |