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.1";
58 pyproject = true;
59
60 src = fetchFromGitHub {
61 owner = "kserve";
62 repo = "kserve";
63 tag = "v${version}";
64 hash = "sha256-k+uyOhsxWPpiA82wCCEn53W2VQgSHGgSABFipEPErRk=";
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 ] ++ huggingface-hub.optional-dependencies.hf_transfer;
116 logging = [ asgi-logger ];
117 ray = [ ray ];
118 llm = [
119 vllm
120 ];
121 };
122
123 nativeCheckInputs = [
124 avro
125 grpcio-testing
126 pytest-asyncio
127 pytest-httpx
128 pytest-xdist
129 pytestCheckHook
130 tomlkit
131 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
132
133 pythonImportsCheck = [ "kserve" ];
134
135 pytestFlagsArray =
136 [
137 # AssertionError
138 "--deselect=test/test_server.py::TestTFHttpServerLoadAndUnLoad::test_unload"
139 ]
140 ++ lib.optionals stdenv.hostPlatform.isDarwin [
141 # RuntimeError: Failed to start GCS
142 "--deselect=test/test_dataplane.py::TestDataPlane::test_explain"
143 "--deselect=test/test_dataplane.py::TestDataPlane::test_infer"
144 "--deselect=test/test_dataplane.py::TestDataPlane::test_model_metadata"
145 "--deselect=test/test_dataplane.py::TestDataPlane::test_server_readiness"
146 "--deselect=test/test_server.py::TestRayServer::test_explain"
147 "--deselect=test/test_server.py::TestRayServer::test_health_handler"
148 "--deselect=test/test_server.py::TestRayServer::test_infer"
149 "--deselect=test/test_server.py::TestRayServer::test_list_handler"
150 "--deselect=test/test_server.py::TestRayServer::test_liveness_handler"
151 "--deselect=test/test_server.py::TestRayServer::test_predict"
152 # Permission Error
153 "--deselect=test/test_server.py::TestMutiProcessServer::test_rest_server_multiprocess"
154 ];
155
156 disabledTestPaths = [
157 # Looks for a config file at the root of the repository
158 "test/test_inference_service_client.py"
159 ];
160
161 disabledTests =
162 [
163 # Require network access
164 "test_infer_graph_endpoint"
165 "test_infer_path_based_routing"
166
167 # Tries to access `/tmp` (hardcoded)
168 "test_local_path_with_out_dir_exist"
169 ]
170 ++ lib.optionals stdenv.hostPlatform.isDarwin [
171 "test_local_path_with_out_dir_not_exist"
172 ];
173
174 __darwinAllowLocalNetworking = true;
175
176 meta = {
177 description = "Standardized Serverless ML Inference Platform on Kubernetes";
178 homepage = "https://github.com/kserve/kserve/tree/master/python/kserve";
179 changelog = "https://github.com/kserve/kserve/releases/tag/v${version}";
180 license = lib.licenses.asl20;
181 maintainers = with lib.maintainers; [ GaetanLepage ];
182 };
183}