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 ++ lib.optionals stdenv.hostPlatform.isLinux (
118 tritonclient.optional-dependencies.http ++ tritonclient.optional-dependencies.grpc
119 );
120 };
121
122 src = fetchFromGitHub {
123 owner = "bentoml";
124 repo = "BentoML";
125 tag = "v${version}";
126 hash = "sha256-zc/JvnEEoV21EbBHhLBWvilidXHx1pxYsBYISFg16Us=";
127 };
128in
129buildPythonPackage {
130 pname = "bentoml";
131 inherit version src;
132 pyproject = true;
133
134 pythonRelaxDeps = [
135 "cattrs"
136 "nvidia-ml-py"
137 "opentelemetry-api"
138 "opentelemetry-instrumentation-aiohttp-client"
139 "opentelemetry-instrumentation-asgi"
140 "opentelemetry-instrumentation"
141 "opentelemetry-sdk"
142 "opentelemetry-semantic-conventions"
143 "opentelemetry-util-http"
144 ];
145
146 build-system = [
147 hatchling
148 hatch-vcs
149 ];
150
151 dependencies = [
152 aiohttp
153 aiosqlite
154 attrs
155 cattrs
156 circus
157 click
158 click-option-group
159 cloudpickle
160 deepmerge
161 fs
162 httpx
163 httpx-ws
164 inflection
165 inquirerpy
166 jinja2
167 numpy
168 nvidia-ml-py
169 opentelemetry-api
170 opentelemetry-instrumentation
171 opentelemetry-instrumentation-aiohttp-client
172 opentelemetry-instrumentation-asgi
173 opentelemetry-sdk
174 opentelemetry-semantic-conventions
175 opentelemetry-util-http
176 packaging
177 pathspec
178 pip-requirements-parser
179 prometheus-client
180 psutil
181 pydantic
182 python-dateutil
183 python-json-logger
184 python-multipart
185 pyyaml
186 rich
187 schema
188 simple-di
189 starlette
190 tomli-w
191 uv
192 uvicorn
193 watchfiles
194 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ];
195
196 inherit optional-dependencies;
197
198 pythonImportsCheck = [ "bentoml" ];
199
200 preCheck = ''
201 # required for CI testing
202 # https://github.com/bentoml/BentoML/pull/4056/commits/66302b502a3f4df4e8e6643d2afefefca974073e
203 export GITHUB_ACTIONS=1
204 '';
205
206 disabledTestPaths = [
207 "tests/e2e"
208 "tests/integration"
209 ];
210
211 disabledTests = [
212 # flaky test
213 "test_store"
214 ];
215
216 nativeCheckInputs = [
217 fastapi
218 google-api-python-client
219 lxml
220 orjson
221 pandas
222 pillow
223 pytest-asyncio
224 pytest-xdist
225 pytestCheckHook
226 scikit-learn
227 ] ++ optional-dependencies.grpc;
228
229 meta = with lib; {
230 description = "Build Production-Grade AI Applications";
231 homepage = "https://github.com/bentoml/BentoML";
232 changelog = "https://github.com/bentoml/BentoML/releases/tag/${src.tag}";
233 license = licenses.asl20;
234 maintainers = with maintainers; [
235 happysalada
236 natsukium
237 ];
238 # AttributeError: 'dict' object has no attribute 'schemas'
239 # https://github.com/bentoml/BentoML/issues/4290
240 broken = versionAtLeast cattrs.version "23.2";
241 };
242}