1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 deprecation,
9 poetry-core,
10
11 # dependencies
12 cloudevents,
13 fastapi,
14 grpc-interceptor,
15 grpcio,
16 httpx,
17 kubernetes,
18 numpy,
19 orjson,
20 pandas,
21 uvicorn,
22
23 # optional-dependencies
24 azure-identity,
25 azure-storage-blob,
26 azure-storage-file-share,
27 boto3,
28 google-cloud-storage,
29 huggingface-hub,
30 asgi-logger,
31 ray,
32 vllm,
33
34 prometheus-client,
35 protobuf,
36 requests,
37 psutil,
38 pydantic,
39 python-dateutil,
40 pyyaml,
41 six,
42 tabulate,
43 timing-asgi,
44
45 # tests
46 avro,
47 grpcio-testing,
48 pytest-asyncio,
49 pytest-xdist,
50 pytestCheckHook,
51 tomlkit,
52}:
53
54buildPythonPackage rec {
55 pname = "kserve";
56 version = "0.15.0";
57 pyproject = true;
58
59 src = fetchFromGitHub {
60 owner = "kserve";
61 repo = "kserve";
62 tag = "v${version}";
63 hash = "sha256-J2VFMHwhHpvtsywv3ixuVzpuDwq8y9w4heedYYWVBmM=";
64 };
65
66 sourceRoot = "${src.name}/python/kserve";
67
68 pythonRelaxDeps = [
69 "fastapi"
70 "httpx"
71 "numpy"
72 "prometheus-client"
73 "protobuf"
74 "uvicorn"
75 "psutil"
76 ];
77
78 build-system = [
79 deprecation
80 poetry-core
81 ];
82
83 dependencies = [
84 cloudevents
85 fastapi
86 grpc-interceptor
87 grpcio
88 httpx
89 kubernetes
90 numpy
91 orjson
92 pandas
93 prometheus-client
94 protobuf
95 psutil
96 pydantic
97 python-dateutil
98 pyyaml
99 six
100 tabulate
101 timing-asgi
102 uvicorn
103 ];
104
105 optional-dependencies = {
106 storage = [
107 azure-identity
108 azure-storage-blob
109 azure-storage-file-share
110 boto3
111 huggingface-hub
112 google-cloud-storage
113 requests
114 ] ++ huggingface-hub.optional-dependencies.hf_transfer;
115 logging = [ asgi-logger ];
116 ray = [ ray ];
117 llm = [
118 # vllm (broken)
119 ];
120 };
121
122 nativeCheckInputs = [
123 avro
124 grpcio-testing
125 pytest-asyncio
126 pytest-xdist
127 pytestCheckHook
128 tomlkit
129 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
130
131 pythonImportsCheck = [ "kserve" ];
132
133 pytestFlagsArray =
134 [
135 # AssertionError
136 "--deselect=test/test_server.py::TestTFHttpServerLoadAndUnLoad::test_unload"
137 ]
138 ++ lib.optionals stdenv.hostPlatform.isDarwin [
139 # RuntimeError: Failed to start GCS
140 "--deselect=test/test_dataplane.py::TestDataPlane::test_explain"
141 "--deselect=test/test_dataplane.py::TestDataPlane::test_infer"
142 "--deselect=test/test_dataplane.py::TestDataPlane::test_model_metadata"
143 "--deselect=test/test_dataplane.py::TestDataPlane::test_server_readiness"
144 "--deselect=test/test_server.py::TestRayServer::test_explain"
145 "--deselect=test/test_server.py::TestRayServer::test_health_handler"
146 "--deselect=test/test_server.py::TestRayServer::test_infer"
147 "--deselect=test/test_server.py::TestRayServer::test_list_handler"
148 "--deselect=test/test_server.py::TestRayServer::test_liveness_handler"
149 "--deselect=test/test_server.py::TestRayServer::test_predict"
150 ];
151
152 disabledTestPaths = [
153 # Looks for a config file at the root of the repository
154 "test/test_inference_service_client.py"
155
156 # Require broken vllm
157 "test/test_dataplane.py"
158 "test/test_model_repository.py"
159 "test/test_openai_completion.py"
160 "test/test_openai_embedding.py"
161 ];
162
163 disabledTests =
164 [
165 # Require network access
166 "test_infer_graph_endpoint"
167 "test_infer_path_based_routing"
168
169 # Tries to access `/tmp` (hardcoded)
170 "test_local_path_with_out_dir_exist"
171 ]
172 ++ lib.optionals stdenv.hostPlatform.isDarwin [
173 "test_local_path_with_out_dir_not_exist"
174 ];
175
176 __darwinAllowLocalNetworking = true;
177
178 meta = {
179 description = "Standardized Serverless ML Inference Platform on Kubernetes";
180 homepage = "https://github.com/kserve/kserve/tree/master/python/kserve";
181 changelog = "https://github.com/kserve/kserve/releases/tag/v${version}";
182 license = lib.licenses.asl20;
183 maintainers = with lib.maintainers; [ GaetanLepage ];
184 };
185}