diff --git a/.github/actions/python/action.yaml b/.github/actions/python/action.yaml index 8795685cbc7..25002185d06 100644 --- a/.github/actions/python/action.yaml +++ b/.github/actions/python/action.yaml @@ -15,7 +15,7 @@ runs: cache: "pip" cache-dependency-path: "requirements*.txt" - name: Install test dependencies - run: python -m pip install -r requirements.txt && python -m pip install -r requirements_dev.txt + run: python -m pip install -r requirements.txt && python -m pip install -r requirements.txt && python -m pip install -r requirements_dev.txt shell: bash - name: Upgrade SQLite run: python bin/windows_upgrade_sqlite.py diff --git a/DEVELOP.md b/DEVELOP.md index c9550e639f4..733f540c4aa 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -13,6 +13,7 @@ and dev requirements: python3 -m venv venv # Only need to do this once source venv/bin/activate # Do this each time you use a new shell for the project pip install -r requirements.txt +pip install -r requirements_optional.txt pip install -r requirements_dev.txt pre-commit install # install the precommit hooks ``` diff --git a/Dockerfile b/Dockerfile index 0cef65cae3d..7865c811d88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,10 @@ RUN apt-get update --fix-missing && apt-get install -y --fix-missing \ WORKDIR /install COPY ./requirements.txt requirements.txt +COPY ./requirements_optional.txt requirements_optional.txt RUN pip install --no-cache-dir --upgrade --prefix="/install" -r requirements.txt +RUN pip install --no-cache-dir --upgrade --prefix="/install" -r requirements_optional.txt RUN if [ "$REBUILD_HNSWLIB" = "true" ]; then pip install --no-binary :all: --force-reinstall --no-cache-dir --prefix="/install" chroma-hnswlib; fi FROM python:3.11-slim-bookworm AS final diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 00000000000..06270915cc4 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,38 @@ +FROM python:3.11-alpine AS builder +ARG REBUILD_HNSWLIB +RUN apk add build-base && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir /install + +WORKDIR /install + +COPY ./requirements.txt requirements.txt +# COPY ./requirements_optional.txt requirements_optional.txt onxxruntime doesn't support alpine T_T + +RUN pip install --no-cache-dir --upgrade --prefix="/install" -r requirements.txt +# RUN pip install --no-cache-dir --upgrade --prefix="/install" -r requirements_optional.txt onxxrutime doesn't support alpoine T_T +RUN if [ "$REBUILD_HNSWLIB" = "true" ]; then pip install --no-binary :all: --force-reinstall --no-cache-dir --prefix="/install" chroma-hnswlib; fi + +FROM python:3.11-alpine AS final + +RUN mkdir /chroma +WORKDIR /chroma + +COPY --from=builder /install /usr/local +COPY ./bin/docker_entrypoint.sh /docker_entrypoint.sh +COPY ./ /chroma + +RUN apk add curl libstdc++ && \ + chmod +x /docker_entrypoint.sh && \ + rm -rf /var/lib/apt/lists/* + +ENV CHROMA_HOST_ADDR "0.0.0.0" +ENV CHROMA_HOST_PORT 8000 +ENV CHROMA_WORKERS 1 +ENV CHROMA_LOG_CONFIG "chromadb/log_config.yml" +ENV CHROMA_TIMEOUT_KEEP_ALIVE 30 + +EXPOSE 8000 + +ENTRYPOINT ["/bin/sh", "/docker_entrypoint.sh"] +CMD [ "--workers ${CHROMA_WORKERS} --host ${CHROMA_HOST_ADDR} --port ${CHROMA_HOST_PORT} --proxy-headers --log-config ${CHROMA_LOG_CONFIG} --timeout-keep-alive ${CHROMA_TIMEOUT_KEEP_ALIVE}"] diff --git a/Dockerfile.windows b/Dockerfile.windows index bc05b76299b..480fc10f870 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -7,8 +7,10 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl WORKDIR C:\\chroma COPY ./requirements.txt requirements.txt +COPY ./requirements_optional.txt requirements_optional.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt +RUN pip install --no-cache-dir --upgrade -r requirements_optional.txt RUN if ($env:REBUILD_HNSWLIB -eq 'true') { pip install --no-binary :all: --force-reinstall --no-cache-dir chroma-hnswlib } COPY ./bin/docker_entrypoint.ps1 C:\\docker_entrypoint.ps1 diff --git a/Tiltfile b/Tiltfile index dad90cf63f1..bbd8bf32fe8 100644 --- a/Tiltfile +++ b/Tiltfile @@ -42,7 +42,7 @@ docker_build( docker_build( 'local:frontend-service', '.', - only=['chromadb/', 'idl/', 'requirements.txt', 'bin/'], + only=['chromadb/', 'idl/', 'requirements.txt', 'requirements_optional.txt' 'bin/'], dockerfile='./Dockerfile', ignore=['**/*.pyc', 'chromadb/test/'], ) diff --git a/chromadb/utils/embedding_functions/__init__.py b/chromadb/utils/embedding_functions/__init__.py index 6f5138eec15..69f2b997905 100644 --- a/chromadb/utils/embedding_functions/__init__.py +++ b/chromadb/utils/embedding_functions/__init__.py @@ -51,6 +51,16 @@ def DefaultEmbeddingFunction() -> Optional[EmbeddingFunction[Documents]]: if is_thin_client: return None else: + # Onxx doesn't support all operation systems. + # For example Onxx doesn't support alpine + has_onnxruntime = False + try: + self.ort = importlib.import_module("onnxruntime") + has_onnxruntime = True + except ImportError: + pass + if not has_onnxruntime: + return None return cast( EmbeddingFunction[Documents], # This is implicitly imported above diff --git a/pyproject.toml b/pyproject.toml index 21c1898b873..2788d2597f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ dependencies = [ 'numpy >= 1.22.5, < 2.0.0', 'posthog >= 2.4.0', 'typing_extensions >= 4.5.0', - 'onnxruntime >= 1.14.1', 'opentelemetry-api>=1.2.0', 'opentelemetry-exporter-otlp-proto-grpc>=1.2.0', 'opentelemetry-instrumentation-fastapi>=0.41b0', @@ -46,6 +45,9 @@ dependencies = [ 'rich>=10.11.0', ] +[project.optional-dependencies] +onnx = ["onnxruntime >= 1.14.1"] + [tool.black] line-length = 88 required-version = "23.3.0" # Black will refuse to run if it's not this version. diff --git a/requirements.txt b/requirements.txt index dfd08dccd8d..fda89f2949f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ importlib-resources kubernetes>=28.1.0 mmh3>=4.0.1 numpy>=1.22.5, <2.0.0 -onnxruntime>=1.14.1 opentelemetry-api>=1.2.0 opentelemetry-exporter-otlp-proto-grpc>=1.24.0 opentelemetry-instrumentation-fastapi>=0.41b0 diff --git a/requirements_optional.txt b/requirements_optional.txt new file mode 100644 index 00000000000..91bac3f40e0 --- /dev/null +++ b/requirements_optional.txt @@ -0,0 +1 @@ +onnxruntime>=1.14.1