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-httpx,
50 pytest-xdist,
51 pytestCheckHook,
52 tomlkit,
53}:
54
55buildPythonPackage rec {
56 pname = "kserve";
57 version = "0.15.2";
58 pyproject = true;
59
60 src = fetchFromGitHub {
61 owner = "kserve";
62 repo = "kserve";
63 tag = "v${version}";
64 hash = "sha256-NklR2Aoa5UdWkqNOfX+xl3R158JDSQtStXv9DkklOwM=";
65 };
66
67 sourceRoot = "${src.name}/python/kserve";
68
69 pythonRelaxDeps = [
70 "fastapi"
71 "httpx"
72 "numpy"
73 "prometheus-client"
74 "protobuf"
75 "uvicorn"
76 "psutil"
77 ];
78
79 build-system = [
80 deprecation
81 poetry-core
82 ];
83
84 dependencies = [
85 cloudevents
86 fastapi
87 grpc-interceptor
88 grpcio
89 httpx
90 kubernetes
91 numpy
92 orjson
93 pandas
94 prometheus-client
95 protobuf
96 psutil
97 pydantic
98 python-dateutil
99 pyyaml
100 six
101 tabulate
102 timing-asgi
103 uvicorn
104 ];
105
106 optional-dependencies = {
107 storage = [
108 azure-identity
109 azure-storage-blob
110 azure-storage-file-share
111 boto3
112 huggingface-hub
113 google-cloud-storage
114 requests
115 ]
116 ++ huggingface-hub.optional-dependencies.hf_transfer;
117 logging = [ asgi-logger ];
118 ray = [ ray ];
119 llm = [
120 vllm
121 ];
122 };
123
124 nativeCheckInputs = [
125 avro
126 grpcio-testing
127 pytest-asyncio
128 pytest-httpx
129 pytest-xdist
130 pytestCheckHook
131 tomlkit
132 ]
133 ++ lib.flatten (builtins.attrValues optional-dependencies);
134
135 pythonImportsCheck = [ "kserve" ];
136
137 disabledTestPaths = [
138 # Looks for a config file at the root of the repository
139 "test/test_inference_service_client.py"
140
141 # AssertionError
142 "test/test_server.py::TestTFHttpServerLoadAndUnLoad::test_unload"
143 ]
144 ++ lib.optionals stdenv.hostPlatform.isDarwin [
145 # RuntimeError: Failed to start GCS
146 "test/test_dataplane.py::TestDataPlane::test_explain"
147 "test/test_dataplane.py::TestDataPlane::test_infer"
148 "test/test_dataplane.py::TestDataPlane::test_model_metadata"
149 "test/test_dataplane.py::TestDataPlane::test_server_readiness"
150 "test/test_server.py::TestRayServer::test_explain"
151 "test/test_server.py::TestRayServer::test_health_handler"
152 "test/test_server.py::TestRayServer::test_infer"
153 "test/test_server.py::TestRayServer::test_list_handler"
154 "test/test_server.py::TestRayServer::test_liveness_handler"
155 "test/test_server.py::TestRayServer::test_predict"
156 # Permission Error
157 "test/test_server.py::TestMutiProcessServer::test_rest_server_multiprocess"
158 ];
159
160 disabledTests = [
161 # AssertionError: assert CompletionReq...lm_xargs=None) == CompletionReq...lm_xargs=None)
162 "test_convert_params"
163
164 # Flaky: ray.exceptions.ActorDiedError: The actor died unexpectedly before finishing this task.
165 "test_explain"
166 "test_infer"
167 "test_predict"
168
169 # Require network access
170 "test_infer_graph_endpoint"
171 "test_infer_path_based_routing"
172
173 # Tries to access `/tmp` (hardcoded)
174 "test_local_path_with_out_dir_exist"
175 ]
176 ++ lib.optionals stdenv.hostPlatform.isDarwin [
177 "test_local_path_with_out_dir_not_exist"
178 ];
179
180 __darwinAllowLocalNetworking = true;
181
182 meta = {
183 description = "Standardized Serverless ML Inference Platform on Kubernetes";
184 homepage = "https://github.com/kserve/kserve/tree/master/python/kserve";
185 changelog = "https://github.com/kserve/kserve/releases/tag/${src.tag}";
186 license = lib.licenses.asl20;
187 maintainers = with lib.maintainers; [ GaetanLepage ];
188 };
189}