Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache model in docker image #64

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ WORKDIR /app
# Install library
RUN pip install -e .


# Download models so app can used cached versions instead of pulling from huggingface
RUN python scripts/cache_default_models.py

# This is just a check to make sure it works, we've had problems with this in the past
RUN python -c "import torchvision"


RUN if [ "$TESTING" = 1 ]; then pip install pytest pytest-cov coverage; fi

CMD ["python", "-u","pvnet_app/app.py"]
6 changes: 4 additions & 2 deletions scripts/cache_default_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""

import typer
# This is needed other we get an error. # TODO find out why
import pvnet_app.app # noqa: F401

from pvnet.models.base_model import BaseModel as PVNetBaseModel
from pvnet_summation.models.base_model import BaseModel as SummationBaseModel
Expand All @@ -16,13 +18,13 @@ def main():
"""Download model from Huggingface and save it to cache."""
# Model will be downloaded and saved to cache on disk
PVNetBaseModel.from_pretrained(
models_dict["pvnet_v2"]["pvnet"]["name"],
model_id=models_dict["pvnet_v2"]["pvnet"]["name"],
revision=models_dict["pvnet_v2"]["pvnet"]["version"],
)

# Model will be downloaded and saved to cache on disk
SummationBaseModel.from_pretrained(
models_dict["pvnet_v2"]["summation"]["name"],
model_id=models_dict["pvnet_v2"]["summation"]["name"],
revision=models_dict["pvnet_v2"]["summation"]["version"],
)

Expand Down
Loading