|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + buildPythonPackage, |
| 5 | + fetchFromGitHub, |
| 6 | + |
| 7 | + # build-system |
| 8 | + setuptools-scm, |
| 9 | + setuptools, |
| 10 | + |
| 11 | + # build inputs |
| 12 | + cargo, |
| 13 | + pkg-config, |
| 14 | + protobuf, |
| 15 | + rustc, |
| 16 | + rustPlatform, |
| 17 | + openssl, |
| 18 | + |
| 19 | + # dependencies |
| 20 | + bcrypt, |
| 21 | + build, |
| 22 | + fastapi, |
| 23 | + grpcio, |
| 24 | + httpx, |
| 25 | + importlib-resources, |
| 26 | + kubernetes, |
| 27 | + mmh3, |
| 28 | + numpy, |
| 29 | + onnxruntime, |
| 30 | + opentelemetry-api, |
| 31 | + opentelemetry-exporter-otlp-proto-grpc, |
| 32 | + opentelemetry-instrumentation-fastapi, |
| 33 | + opentelemetry-sdk, |
| 34 | + orjson, |
| 35 | + overrides, |
| 36 | + posthog, |
| 37 | + pulsar-client, |
| 38 | + pydantic, |
| 39 | + pypika, |
| 40 | + pyyaml, |
| 41 | + requests, |
| 42 | + tenacity, |
| 43 | + tokenizers, |
| 44 | + tqdm, |
| 45 | + typer, |
| 46 | + typing-extensions, |
| 47 | + uvicorn, |
| 48 | + zstd, |
| 49 | + |
| 50 | + # optional dependencies |
| 51 | + chroma-hnswlib, |
| 52 | + |
| 53 | + # tests |
| 54 | + hypothesis, |
| 55 | + psutil, |
| 56 | + pytest-asyncio, |
| 57 | + pytestCheckHook, |
| 58 | + |
| 59 | + # passthru |
| 60 | + nixosTests, |
| 61 | + nix-update-script, |
| 62 | +}: |
| 63 | + |
| 64 | +buildPythonPackage rec { |
| 65 | + pname = "chromadb_0"; |
| 66 | + version = "0.6.3"; |
| 67 | + pyproject = true; |
| 68 | + |
| 69 | + src = fetchFromGitHub { |
| 70 | + owner = "chroma-core"; |
| 71 | + repo = "chroma"; |
| 72 | + tag = version; |
| 73 | + hash = "sha256-yvAX8buETsdPvMQmRK5+WFz4fVaGIdNlfhSadtHwU5U="; |
| 74 | + }; |
| 75 | + |
| 76 | + cargoDeps = rustPlatform.fetchCargoVendor { |
| 77 | + inherit src; |
| 78 | + name = "${pname}-${version}"; |
| 79 | + hash = "sha256-lHRBXJa/OFNf4x7afEJw9XcuDveTBIy3XpQ3+19JXn4="; |
| 80 | + }; |
| 81 | + |
| 82 | + pythonRelaxDeps = [ |
| 83 | + "chroma-hnswlib" |
| 84 | + "orjson" |
| 85 | + "tokenizers" |
| 86 | + ]; |
| 87 | + |
| 88 | + build-system = [ |
| 89 | + setuptools |
| 90 | + setuptools-scm |
| 91 | + ]; |
| 92 | + |
| 93 | + nativeBuildInputs = [ |
| 94 | + cargo |
| 95 | + pkg-config |
| 96 | + protobuf |
| 97 | + rustc |
| 98 | + rustPlatform.cargoSetupHook |
| 99 | + ]; |
| 100 | + |
| 101 | + buildInputs = [ |
| 102 | + openssl |
| 103 | + zstd |
| 104 | + ]; |
| 105 | + |
| 106 | + dependencies = [ |
| 107 | + bcrypt |
| 108 | + build |
| 109 | + chroma-hnswlib |
| 110 | + fastapi |
| 111 | + grpcio |
| 112 | + httpx |
| 113 | + importlib-resources |
| 114 | + kubernetes |
| 115 | + mmh3 |
| 116 | + numpy |
| 117 | + onnxruntime |
| 118 | + opentelemetry-api |
| 119 | + opentelemetry-exporter-otlp-proto-grpc |
| 120 | + opentelemetry-instrumentation-fastapi |
| 121 | + opentelemetry-sdk |
| 122 | + orjson |
| 123 | + overrides |
| 124 | + posthog |
| 125 | + pulsar-client |
| 126 | + pydantic |
| 127 | + pypika |
| 128 | + pyyaml |
| 129 | + requests |
| 130 | + tenacity |
| 131 | + tokenizers |
| 132 | + tqdm |
| 133 | + typer |
| 134 | + typing-extensions |
| 135 | + uvicorn |
| 136 | + ]; |
| 137 | + |
| 138 | + nativeCheckInputs = [ |
| 139 | + hypothesis |
| 140 | + psutil |
| 141 | + pytest-asyncio |
| 142 | + pytestCheckHook |
| 143 | + ]; |
| 144 | + |
| 145 | + # Disable on aarch64-linux due to broken onnxruntime |
| 146 | + # https://github.com/microsoft/onnxruntime/issues/10038 |
| 147 | + pythonImportsCheck = lib.optionals (stdenv.hostPlatform.system != "aarch64-linux") [ "chromadb" ]; |
| 148 | + |
| 149 | + # Test collection breaks on aarch64-linux |
| 150 | + doCheck = stdenv.hostPlatform.system != "aarch64-linux"; |
| 151 | + |
| 152 | + env = { |
| 153 | + ZSTD_SYS_USE_PKG_CONFIG = true; |
| 154 | + }; |
| 155 | + |
| 156 | + pytestFlagsArray = [ |
| 157 | + "-x" # these are slow tests, so stop on the first failure |
| 158 | + "-v" |
| 159 | + ]; |
| 160 | + |
| 161 | + preCheck = '' |
| 162 | + (($(ulimit -n) < 1024)) && ulimit -n 1024 |
| 163 | + export HOME=$(mktemp -d) |
| 164 | + ''; |
| 165 | + |
| 166 | + disabledTests = [ |
| 167 | + # Tests are flaky / timing sensitive |
| 168 | + "test_fastapi_server_token_authn_allows_when_it_should_allow" |
| 169 | + "test_fastapi_server_token_authn_rejects_when_it_should_reject" |
| 170 | + |
| 171 | + # Issue with event loop |
| 172 | + "test_http_client_bw_compatibility" |
| 173 | + |
| 174 | + # httpx ReadError |
| 175 | + "test_not_existing_collection_delete" |
| 176 | + ]; |
| 177 | + |
| 178 | + disabledTestPaths = [ |
| 179 | + # Tests require network access |
| 180 | + "chromadb/test/auth/test_simple_rbac_authz.py" |
| 181 | + "chromadb/test/db/test_system.py" |
| 182 | + "chromadb/test/ef/test_default_ef.py" |
| 183 | + "chromadb/test/property/" |
| 184 | + "chromadb/test/property/test_cross_version_persist.py" |
| 185 | + "chromadb/test/stress/" |
| 186 | + "chromadb/test/test_api.py" |
| 187 | + |
| 188 | + # httpx failures |
| 189 | + "chromadb/test/api/test_delete_database.py" |
| 190 | + |
| 191 | + # Cannot be loaded by pytest without path hacks (fixed in 1.0.0) |
| 192 | + "chromadb/test/test_logservice.py" |
| 193 | + "chromadb/test/proto/test_utils.py" |
| 194 | + "chromadb/test/segment/distributed/test_protobuf_translation.py" |
| 195 | + |
| 196 | + # Hypothesis FailedHealthCheck due to nested @given tests |
| 197 | + "chromadb/test/cache/test_cache.py" |
| 198 | + ]; |
| 199 | + |
| 200 | + __darwinAllowLocalNetworking = true; |
| 201 | + |
| 202 | + passthru.tests = { |
| 203 | + inherit (nixosTests) chromadb; |
| 204 | + }; |
| 205 | + |
| 206 | + # nixpkgs-update: no auto update |
| 207 | + # 0.6.3 is the last of the 0.x series |
| 208 | + |
| 209 | + meta = { |
| 210 | + description = "AI-native open-source embedding database"; |
| 211 | + homepage = "https://github.com/chroma-core/chroma"; |
| 212 | + changelog = "https://github.com/chroma-core/chroma/releases/tag/${version}"; |
| 213 | + license = lib.licenses.asl20; |
| 214 | + maintainers = with lib.maintainers; [ |
| 215 | + fab |
| 216 | + sarahec |
| 217 | + ]; |
| 218 | + mainProgram = "chroma"; |
| 219 | + }; |
| 220 | +} |
0 commit comments