FROM pure/python:3.7-cuda10.0-base

WORKDIR /app

# Download utils
RUN apt update && apt install -y wget git

# Install python3.7
#RUN apt install -y python3.7

# Download the code
RUN git clone https://github.com/neulab/BARTScore && \
    cd BARTScore && \
    git checkout a93654e9f28f6997dc2cc5106a41f7a3ad0db91a

# Download the pretrained Parabank model
RUN pip install --no-cache-dir gdown && \
    gdown https://drive.google.com/uc?id=1_7JfF7KOInb7ZrxKHIigTMR4ChVET01m -O BARTScore/bart.pth

## Install the dependencies. We manually install them because there
## is an unknown package in the requirements.txt: https://github.com/neulab/BARTScore/issues/1
RUN pip install --no-cache-dir \
    absl-py==0.12.0 \
    antlr4-python3-runtime==4.8 \
    astunparse==1.6.3 \
    bert-score==0.3.9 \
    boto3==1.17.78 \
    botocore==1.20.78 \
    cached-property==1.5.2 \
    cachetools==4.2.2 \
    certifi==2020.12.5 \
    cffi==1.14.5 \
    chardet==4.0.0 \
    click==8.0.1 \
    cmake==3.20.2 \
    cycler==0.10.0 \
    Cython==0.29.23 \
    dataclasses==0.6 \
    docopt==0.6.2 \
    fairseq==0.9.0 \
    filelock==3.0.12 \
    flatbuffers==1.12 \
    fsspec==0.8.7 \
    future==0.18.2 \
    gast==0.3.3 \
    google-auth==1.30.0 \
    google-auth-oauthlib==0.4.4 \
    google-pasta==0.2.0 \
    grpcio==1.32.0 \
    h5py==2.10.0 \
    huggingface-hub==0.0.8 \
    hydra-core==1.0.6 \
    idna==2.10 \
    importlib-metadata==4.0.1 \
    importlib-resources==5.1.4 \
    jmespath==0.10.0 \
    joblib==1.0.1 \
    jsonlines==2.0.0 \
    keras-nightly==2.5.0.dev2021032900 \
    Keras-Preprocessing==1.1.2 \
    kiwisolver==1.3.1 \
    Markdown==3.3.4 \
    matplotlib==3.4.2 \
    mosestokenizer==1.1.0 \
    nltk==3.6.2 \
    numpy==1.18.5 \
    oauthlib==3.1.0 \
    omegaconf==2.0.6 \
    openfile==0.0.7 \
    opt-einsum==3.3.0 \
    packaging==20.9 \
    pandas==1.2.4 \
    Pillow==8.2.0 \
    portalocker==2.0.0 \
    protobuf==3.17.0 \
    pyasn1==0.4.8 \
    pyasn1-modules==0.2.8 \
    pycparser==2.20 \
    pyDeprecate==0.3.0 \
    pyemd==0.5.1 \
    pyparsing==2.4.7 \
    python-dateutil==2.8.1 \
    pytorch-lightning==1.3.0 \
    pytorch-nlp==0.5.0 \
    pytorch-pretrained-bert==0.6.2 \
    pytz==2021.1 \
    PyYAML==5.3.1 \
    regex==2021.4.4 \
    requests==2.25.1 \
    requests-oauthlib==1.3.0 \
    rsa==4.7.2 \
    s3transfer==0.4.2 \
    sacrebleu==1.5.1 \
    sacremoses==0.0.45 \
    scikit-learn==0.24.0 \
    scipy==1.4.1 \
    sentencepiece==0.1.91 \
    six==1.15.0 \
    tabulate==0.8.9 \
    tensorboard==2.5.0 \
    tensorboard-data-server==0.6.1 \
    tensorboard-plugin-wit==1.8.0 \
    tensorflow==2.3.0 \
    tensorflow-estimator==2.3.0 \
    termcolor==1.1.0 \
    tf-slim==1.1.0 \
    threadpoolctl==2.1.0 \
    tokenizers==0.10.2 \
    toolwrapper==2.1.0 \
    torch==1.6.0 \
    torchmetrics==0.3.2 \
    tqdm==4.60.0 \
    transformers==4.6.1 \
    typing-extensions==3.7.4.3 \
    uctools==1.3.0 \
    unbabel-comet==0.1.0 \
    urllib3==1.26.4 \
    Werkzeug==2.0.1 \
    wrapt==1.12.1 \
    zipp==3.4.1

# Copy over the scoring code
COPY src/score.py BARTScore/score.py

# Run warmup code
COPY scripts/warmup.sh warmup.sh
RUN sh warmup.sh