1{
2 lib,
3 stdenv,
4 a2wsgi,
5 aiohttp,
6 aiosqlite,
7 attrs,
8 buildPythonPackage,
9 cattrs,
10 circus,
11 click-option-group,
12 click,
13 cloudpickle,
14 deepmerge,
15 fetchFromGitHub,
16 fs-s3fs,
17 fs,
18 fsspec,
19 grpcio-channelz,
20 grpcio-health-checking,
21 grpcio-reflection,
22 grpcio,
23 hatch-vcs,
24 hatchling,
25 httpx-ws,
26 httpx,
27 inflection,
28 inquirerpy,
29 jinja2,
30 kantoku,
31 numpy,
32 nvidia-ml-py,
33 opentelemetry-api,
34 opentelemetry-exporter-otlp-proto-http,
35 opentelemetry-exporter-otlp,
36 opentelemetry-instrumentation-aiohttp-client,
37 opentelemetry-instrumentation-asgi,
38 opentelemetry-instrumentation-grpc,
39 opentelemetry-instrumentation,
40 opentelemetry-sdk,
41 opentelemetry-semantic-conventions,
42 opentelemetry-util-http,
43 packaging,
44 pandas,
45 pathspec,
46 pillow,
47 pip-requirements-parser,
48 prometheus-client,
49 protobuf,
50 psutil,
51 pyarrow,
52 pydantic,
53 python-dateutil,
54 python-json-logger,
55 python-multipart,
56 pythonOlder,
57 pyyaml,
58 questionary,
59 rich,
60 rich-toolkit,
61 schema,
62 simple-di,
63 starlette,
64 tomli-w,
65 tomli,
66 tritonclient,
67 uv,
68 uvicorn,
69 watchfiles,
70 # native check inputs
71 pytestCheckHook,
72 pytest-xdist,
73 google-api-python-client,
74 scikit-learn,
75 lxml,
76 orjson,
77 pytest-asyncio,
78 fastapi,
79 writableTmpDirAsHomeHook,
80}:
81
82let
83 version = "1.4.25";
84 aws = [ fs-s3fs ];
85 grpc = [
86 grpcio
87 grpcio-health-checking
88 opentelemetry-instrumentation-grpc
89 protobuf
90 ];
91 io-image = [ pillow ];
92 io-pandas = [
93 pandas
94 pyarrow
95 ];
96 grpc-reflection = grpc ++ [ grpcio-reflection ];
97 grpc-channelz = grpc ++ [ grpcio-channelz ];
98 monitor-otlp = [
99 opentelemetry-exporter-otlp-proto-http
100 opentelemetry-instrumentation-grpc
101 ];
102 # tracing-jaeger = [ opentelemetry-exporter-jaeger ];
103 tracing-otlp = [ opentelemetry-exporter-otlp ];
104 # tracing-zipkin = [ opentelemetry-exporter-zipkin ];
105 io = io-image ++ io-pandas;
106 tracing = tracing-otlp; # ++ tracing-zipkin ++ tracing-jaeger
107 optional-dependencies = {
108 all = aws ++ io ++ grpc ++ grpc-reflection ++ grpc-channelz ++ tracing ++ monitor-otlp;
109 inherit
110 aws
111 grpc
112 io-image
113 io-pandas
114 io
115 grpc-reflection
116 grpc-channelz
117 monitor-otlp
118 tracing-otlp
119 tracing
120 ;
121 triton = [
122 tritonclient
123 ]
124 ++ lib.optionals stdenv.hostPlatform.isLinux (
125 tritonclient.optional-dependencies.http ++ tritonclient.optional-dependencies.grpc
126 );
127 };
128
129 src = fetchFromGitHub {
130 owner = "bentoml";
131 repo = "BentoML";
132 tag = "v${version}";
133 hash = "sha256-07LR0Q2inKRKn6NHHldv8kSFtCBcZvGd+VfEEhxc2Ac=";
134 };
135in
136buildPythonPackage {
137 pname = "bentoml";
138 inherit version src;
139 pyproject = true;
140
141 pythonRelaxDeps = [
142 "cattrs"
143 "fsspec"
144 "nvidia-ml-py"
145 "opentelemetry-api"
146 "opentelemetry-instrumentation-aiohttp-client"
147 "opentelemetry-instrumentation-asgi"
148 "opentelemetry-instrumentation"
149 "opentelemetry-sdk"
150 "opentelemetry-semantic-conventions"
151 "opentelemetry-util-http"
152 "rich-toolkit"
153 ];
154
155 build-system = [
156 hatchling
157 hatch-vcs
158 ];
159
160 dependencies = [
161 a2wsgi
162 aiohttp
163 aiosqlite
164 attrs
165 cattrs
166 circus
167 click
168 click-option-group
169 cloudpickle
170 deepmerge
171 fs
172 fsspec
173 httpx
174 httpx-ws
175 inflection
176 inquirerpy
177 jinja2
178 kantoku
179 numpy
180 nvidia-ml-py
181 opentelemetry-api
182 opentelemetry-instrumentation
183 opentelemetry-instrumentation-aiohttp-client
184 opentelemetry-instrumentation-asgi
185 opentelemetry-sdk
186 opentelemetry-semantic-conventions
187 opentelemetry-util-http
188 packaging
189 pathspec
190 pip-requirements-parser
191 prometheus-client
192 psutil
193 pydantic
194 python-dateutil
195 python-json-logger
196 python-multipart
197 pyyaml
198 questionary
199 rich
200 rich-toolkit
201 schema
202 simple-di
203 starlette
204 tomli-w
205 uv
206 uvicorn
207 watchfiles
208 ]
209 ++ lib.optionals (pythonOlder "3.11") [ tomli ];
210
211 inherit optional-dependencies;
212
213 pythonImportsCheck = [ "bentoml" ];
214
215 preCheck = ''
216 # required for CI testing
217 # https://github.com/bentoml/BentoML/pull/4056/commits/66302b502a3f4df4e8e6643d2afefefca974073e
218 export GITHUB_ACTIONS=1
219 '';
220
221 disabledTestPaths = [
222 "tests/e2e"
223 "tests/integration"
224 "tests/unit/grpc"
225 "tests/unit/_internal/"
226 ];
227
228 disabledTests = [
229 # flaky test
230 "test_store"
231 #
232 "test_log_collection"
233 ];
234
235 nativeCheckInputs = [
236 fastapi
237 google-api-python-client
238 lxml
239 orjson
240 pandas
241 pillow
242 pytest-asyncio
243 pytest-xdist
244 pytestCheckHook
245 scikit-learn
246 writableTmpDirAsHomeHook
247 ]
248 ++ optional-dependencies.grpc;
249
250 meta = with lib; {
251 description = "Build Production-Grade AI Applications";
252 homepage = "https://github.com/bentoml/BentoML";
253 changelog = "https://github.com/bentoml/BentoML/releases/tag/${src.tag}";
254 license = licenses.asl20;
255 maintainers = with maintainers; [
256 happysalada
257 natsukium
258 ];
259 };
260}