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