Skip to content
Open
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
7 changes: 4 additions & 3 deletions clarifai/runners/models/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
from clarifai.versions import get_latest_version_from_pypi

CLARIFAI_LATEST_VERSION = get_latest_version_from_pypi()
CLARIFAI_PROTOCOL_LATEST_VERSION = get_latest_version_from_pypi('clarifai-protocol')

# Additional package installation if the model will be used w/ a streaming video runner:
# Dockerfile: Install ffmpeg and av
# Dockerfile: Install ffmpeg and clarifai-protocol[auto-annotation].
#
# Our base images are distroless, so we do not have apt-get or other package managers
# available; however, we will also not be able to use those package repositories on-prem.
Expand All @@ -58,11 +59,11 @@
#
# TODO: before we make this public, we need to figure out how to distribute the src;
# line to copy in src commented out because it's 500MB
STREAMING_VIDEO_ADDITIONAL_PACKAGE_INSTALLATION = """
STREAMING_VIDEO_ADDITIONAL_PACKAGE_INSTALLATION = f"""
COPY --from=public.ecr.aws/clarifai-models/static-streaming:5.1.8 /ffmpeg /usr/local/bin/
COPY --from=public.ecr.aws/clarifai-models/static-streaming:5.1.8 /ffprobe /usr/local/bin/
# COPY --from=public.ecr.aws/clarifai-models/static-streaming:5.1.8 /src /usr/local/src/
RUN uv pip install --no-cache-dir av
RUN uv pip install 'clarifai-protocol[auto-annotation]=={CLARIFAI_PROTOCOL_LATEST_VERSION}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, the Dockerfile template; after the ${ADDITIONAL_PACKAGES} insertion -- which includes this test -- we subsequently install the requirements file:

RUN ["uv", "pip", "install", "--no-cache-dir", "-r", "/home/nonroot/requirements.txt"]

Concern: if a user defines a different version of clarify protocol in their local requirements.txt, the subsequent installation of their version could override the initial install, causing the add-ons to be lost.

Could you please test:

  • whether those two extra packages actually remain after the installation from requirements.txt?
  • If there any way to install only the add-ons and not the main package itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point! I tested this and it is not a problem,: the additional packages remain installed after installing a different version of the clarifai-protocol package.

Test details follow.

  1. install clarifai-protocol with auto-annotation extra:
    uv pip install 'clarifai-protocol[auto-annotation]==0.0.60'
  2. check additional packages installed
    uv pip list | grep -E "shapely|av"
    av                                       16.1.0
    shapely                                  2.1.2
  3. install different clarifai-protocol version without auto-annotation extra:
    uv pip install 'clarifai-protocol==0.0.59'
  4. check additional packages installed
    uv pip list | grep -E "shapely|av"
    av                                       16.1.0
    shapely                                  2.1.2

"""


Expand Down
4 changes: 2 additions & 2 deletions clarifai/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)


def get_latest_version_from_pypi():
def get_latest_version_from_pypi(package: str = 'clarifai'):
"""
Fetch the latest version of the clarifai package from PyPI.

Expand All @@ -24,7 +24,7 @@ def get_latest_version_from_pypi():
try:
import requests

response = requests.get("https://pypi.org/pypi/clarifai/json", timeout=5)
response = requests.get(f"https://pypi.org/pypi/{package}/json", timeout=5)
if response.status_code == 200:
return response.json().get("info", {}).get("version")
return None
Expand Down
Loading