-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EAGLE-5448]: upload improvements (#498)
* don't use shell for hf token validation * update dep in dockerfile * change version
- Loading branch information
Showing
11 changed files
with
153 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "11.0.6" | ||
__version__ = "11.0.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from clarifai.cli.base import main | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,82 @@ | ||
FROM --platform=$TARGETPLATFORM ${BASE_IMAGE} as build | ||
# syntax=docker/dockerfile:1 | ||
############################# | ||
# User specific requirements installed in the pip_packages | ||
############################# | ||
FROM --platform=$TARGETPLATFORM ${BUILDER_IMAGE} as pip_packages | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
COPY --link requirements.txt /home/nonroot/requirements.txt | ||
|
||
# Update clarifai package so we always have latest protocol to the API. Everything should land in /venv | ||
RUN pip install --no-cache-dir -r /home/nonroot/requirements.txt && \ | ||
(pip install --upgrade --upgrade-strategy only-if-needed --no-deps --no-cache-dir clarifai clarifai-grpc clarifai-protocol || true) | ||
############################# | ||
|
||
############################# | ||
# User specific requirements | ||
# Downloader dependencies image | ||
############################# | ||
COPY requirements.txt . | ||
FROM --platform=$TARGETPLATFORM ${DOWNLOADER_IMAGE} as downloader | ||
|
||
# Install requirements and clarifai package and cleanup before leaving this line. | ||
# Note(zeiler): this could be in a future template as {{model_python_deps}} | ||
RUN pip install --no-cache-dir -r requirements.txt && \ | ||
pip install --no-cache-dir clarifai | ||
# make sure we have the latest clarifai package. | ||
RUN (pip install --upgrade --upgrade-strategy only-if-needed --no-cache-dir clarifai clarifai-grpc clarifai-protocol || true) | ||
##### | ||
|
||
# These will be set by the templaing system. | ||
ENV CLARIFAI_PAT=${CLARIFAI_PAT} | ||
ENV CLARIFAI_USER_ID=${CLARIFAI_USER_ID} | ||
ENV CLARIFAI_RUNNER_ID=${CLARIFAI_RUNNER_ID} | ||
ENV CLARIFAI_NODEPOOL_ID=${CLARIFAI_NODEPOOL_ID} | ||
ENV CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID} | ||
ENV CLARIFAI_API_BASE=${CLARIFAI_API_BASE} | ||
|
||
############################# | ||
# Final runtime image | ||
############################# | ||
FROM --platform=$TARGETPLATFORM ${RUNTIME_IMAGE} as final | ||
|
||
# Set the NUMBA cache dir to /tmp | ||
ENV NUMBA_CACHE_DIR=/tmp/numba_cache | ||
# Set the TORCHINDUCTOR cache dir to /tmp | ||
ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache | ||
ENV HOME=/tmp | ||
# The CLARIFAI* will be set by the templaing system. | ||
ENV NUMBA_CACHE_DIR=/tmp/numba_cache \ | ||
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache \ | ||
HOME=/tmp \ | ||
DEBIAN_FRONTEND=noninteractive | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
##### | ||
# Copy the python requirements needed to download checkpoints | ||
##### | ||
COPY --link=true --from=downloader /venv /venv | ||
##### | ||
|
||
# Copy the current folder into /app/model_dir that the SDK will expect. | ||
# Note(zeiler): would be nice to exclude checkpoints in case they were pre-downloaded. | ||
COPY . /app/model_dir/${name} | ||
##### | ||
# Copy the files needed to download | ||
##### | ||
# This creates the directory that HF downloader will populate and with nonroot:nonroot permissions up. | ||
COPY --chown=nonroot:nonroot downloader/unused.yaml /home/nonroot/main/1/checkpoints/.cache/unused.yaml | ||
|
||
# Add the model directory to the python path. | ||
ENV PYTHONPATH=${PYTHONPATH}:/app/model_dir/${name} | ||
##### | ||
# Download checkpoints | ||
COPY --link=true config.yaml /home/nonroot/main/ | ||
RUN ["python", "-m", "clarifai.cli", "model", "download-checkpoints", "--model_path", "/home/nonroot/main", "--out_path", "/home/nonroot/main"] | ||
##### | ||
|
||
ENTRYPOINT ["python", "-m", "clarifai.runners.server"] | ||
|
||
##### | ||
# Copy the python packages from the previous stage. | ||
COPY --link=true --from=pip_packages /venv /venv | ||
##### | ||
|
||
# Copy in the actual files like config.yaml, requirements.txt, and most importantly 1/model.py | ||
# for the actual model. | ||
# If checkpoints aren't downloaded since a checkpoints: block is not provided, then they will | ||
# be in the build context and copied here as well. | ||
COPY --link=true 1/model.py /home/nonroot/main/1/model.py | ||
# At this point we only need these for validation in the SDK. | ||
COPY --link=true requirements.txt config.yaml /home/nonroot/main/ | ||
|
||
# Add the model directory to the python path. | ||
ENV PYTHONPATH=${PYTHONPATH}:/home/nonroot/main \ | ||
CLARIFAI_PAT=${CLARIFAI_PAT} \ | ||
CLARIFAI_USER_ID=${CLARIFAI_USER_ID} \ | ||
CLARIFAI_RUNNER_ID=${CLARIFAI_RUNNER_ID} \ | ||
CLARIFAI_NODEPOOL_ID=${CLARIFAI_NODEPOOL_ID} \ | ||
CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID} \ | ||
CLARIFAI_API_BASE=${CLARIFAI_API_BASE} | ||
|
||
# Finally run the clarifai entrypoint to start the runner loop and local dev server. | ||
# Note(zeiler): we may want to make this a clarifai CLI call. | ||
CMD ["--model_path", "/app/model_dir/main"] | ||
ENTRYPOINT ["python", "-m", "clarifai.runners.server"] | ||
CMD ["--model_path", "/home/nonroot/main"] | ||
############################# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters