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