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