truss 0.10.0rc1__py3-none-any.whl → 0.60.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of truss might be problematic. Click here for more details.

Files changed (362) hide show
  1. truss/__init__.py +10 -3
  2. truss/api/__init__.py +123 -0
  3. truss/api/definitions.py +51 -0
  4. truss/base/constants.py +116 -0
  5. truss/base/custom_types.py +29 -0
  6. truss/{errors.py → base/errors.py} +4 -0
  7. truss/base/trt_llm_config.py +310 -0
  8. truss/{truss_config.py → base/truss_config.py} +344 -31
  9. truss/{truss_spec.py → base/truss_spec.py} +20 -6
  10. truss/{validation.py → base/validation.py} +60 -11
  11. truss/cli/cli.py +841 -88
  12. truss/{remote → cli}/remote_cli.py +2 -7
  13. truss/contexts/docker_build_setup.py +67 -0
  14. truss/contexts/image_builder/cache_warmer.py +2 -8
  15. truss/contexts/image_builder/image_builder.py +1 -1
  16. truss/contexts/image_builder/serving_image_builder.py +292 -46
  17. truss/contexts/image_builder/util.py +1 -3
  18. truss/contexts/local_loader/docker_build_emulator.py +58 -0
  19. truss/contexts/local_loader/load_model_local.py +2 -2
  20. truss/contexts/local_loader/truss_module_loader.py +1 -1
  21. truss/contexts/local_loader/utils.py +1 -1
  22. truss/local/local_config.py +2 -6
  23. truss/local/local_config_handler.py +20 -5
  24. truss/patch/__init__.py +1 -0
  25. truss/patch/hash.py +4 -70
  26. truss/patch/signature.py +4 -16
  27. truss/patch/truss_dir_patch_applier.py +3 -78
  28. truss/remote/baseten/api.py +308 -23
  29. truss/remote/baseten/auth.py +3 -3
  30. truss/remote/baseten/core.py +257 -50
  31. truss/remote/baseten/custom_types.py +44 -0
  32. truss/remote/baseten/error.py +4 -0
  33. truss/remote/baseten/remote.py +369 -118
  34. truss/remote/baseten/service.py +118 -11
  35. truss/remote/baseten/utils/status.py +29 -0
  36. truss/remote/baseten/utils/tar.py +34 -22
  37. truss/remote/baseten/utils/transfer.py +36 -23
  38. truss/remote/remote_factory.py +14 -5
  39. truss/remote/truss_remote.py +72 -45
  40. truss/templates/base.Dockerfile.jinja +18 -16
  41. truss/templates/cache.Dockerfile.jinja +3 -3
  42. truss/{server → templates/control}/control/application.py +14 -35
  43. truss/{server → templates/control}/control/endpoints.py +39 -9
  44. truss/{server/control/patch/types.py → templates/control/control/helpers/custom_types.py} +13 -52
  45. truss/{server → templates/control}/control/helpers/inference_server_controller.py +4 -8
  46. truss/{server → templates/control}/control/helpers/inference_server_process_controller.py +2 -4
  47. truss/{server → templates/control}/control/helpers/inference_server_starter.py +5 -10
  48. truss/{server/control → templates/control/control/helpers}/truss_patch/model_code_patch_applier.py +8 -6
  49. truss/{server/control/patch → templates/control/control/helpers/truss_patch}/model_container_patch_applier.py +18 -26
  50. truss/templates/control/control/helpers/truss_patch/requirement_name_identifier.py +66 -0
  51. truss/{server → templates/control}/control/server.py +11 -6
  52. truss/templates/control/requirements.txt +9 -0
  53. truss/templates/custom_python_dx/my_model.py +28 -0
  54. truss/templates/docker_server/proxy.conf.jinja +42 -0
  55. truss/templates/docker_server/supervisord.conf.jinja +27 -0
  56. truss/templates/docker_server_requirements.txt +1 -0
  57. truss/templates/server/common/errors.py +231 -0
  58. truss/{server → templates/server}/common/patches/whisper/patch.py +1 -0
  59. truss/{server/common/patches/__init__.py → templates/server/common/patches.py} +1 -3
  60. truss/{server → templates/server}/common/retry.py +1 -0
  61. truss/{server → templates/server}/common/schema.py +11 -9
  62. truss/templates/server/common/tracing.py +157 -0
  63. truss/templates/server/main.py +9 -0
  64. truss/templates/server/model_wrapper.py +961 -0
  65. truss/templates/server/requirements.txt +21 -0
  66. truss/templates/server/truss_server.py +447 -0
  67. truss/templates/server.Dockerfile.jinja +62 -14
  68. truss/templates/shared/dynamic_config_resolver.py +28 -0
  69. truss/templates/shared/lazy_data_resolver.py +164 -0
  70. truss/templates/shared/log_config.py +125 -0
  71. truss/{server → templates}/shared/secrets_resolver.py +1 -2
  72. truss/{server → templates}/shared/serialization.py +31 -9
  73. truss/{server → templates}/shared/util.py +3 -13
  74. truss/templates/trtllm-audio/model/model.py +49 -0
  75. truss/templates/trtllm-audio/packages/sigint_patch.py +14 -0
  76. truss/templates/trtllm-audio/packages/whisper_trt/__init__.py +215 -0
  77. truss/templates/trtllm-audio/packages/whisper_trt/assets.py +25 -0
  78. truss/templates/trtllm-audio/packages/whisper_trt/batching.py +52 -0
  79. truss/templates/trtllm-audio/packages/whisper_trt/custom_types.py +26 -0
  80. truss/templates/trtllm-audio/packages/whisper_trt/modeling.py +184 -0
  81. truss/templates/trtllm-audio/packages/whisper_trt/tokenizer.py +185 -0
  82. truss/templates/trtllm-audio/packages/whisper_trt/utils.py +245 -0
  83. truss/templates/trtllm-briton/src/extension.py +64 -0
  84. truss/tests/conftest.py +302 -94
  85. truss/tests/contexts/image_builder/test_serving_image_builder.py +74 -31
  86. truss/tests/contexts/local_loader/test_load_local.py +2 -2
  87. truss/tests/contexts/local_loader/test_truss_module_finder.py +1 -1
  88. truss/tests/patch/test_calc_patch.py +439 -127
  89. truss/tests/patch/test_dir_signature.py +3 -12
  90. truss/tests/patch/test_hash.py +1 -1
  91. truss/tests/patch/test_signature.py +1 -1
  92. truss/tests/patch/test_truss_dir_patch_applier.py +23 -11
  93. truss/tests/patch/test_types.py +2 -2
  94. truss/tests/remote/baseten/test_api.py +153 -58
  95. truss/tests/remote/baseten/test_auth.py +2 -1
  96. truss/tests/remote/baseten/test_core.py +160 -12
  97. truss/tests/remote/baseten/test_remote.py +489 -77
  98. truss/tests/remote/baseten/test_service.py +55 -0
  99. truss/tests/remote/test_remote_factory.py +16 -18
  100. truss/tests/remote/test_truss_remote.py +26 -17
  101. truss/tests/templates/control/control/helpers/test_context_managers.py +11 -0
  102. truss/tests/templates/control/control/helpers/test_model_container_patch_applier.py +184 -0
  103. truss/tests/templates/control/control/helpers/test_requirement_name_identifier.py +89 -0
  104. truss/tests/{server → templates/control}/control/test_server.py +79 -24
  105. truss/tests/{server → templates/control}/control/test_server_integration.py +24 -16
  106. truss/tests/templates/core/server/test_dynamic_config_resolver.py +108 -0
  107. truss/tests/templates/core/server/test_lazy_data_resolver.py +329 -0
  108. truss/tests/templates/core/server/test_lazy_data_resolver_v2.py +79 -0
  109. truss/tests/{server → templates}/core/server/test_secrets_resolver.py +1 -1
  110. truss/tests/{server → templates/server}/common/test_retry.py +3 -3
  111. truss/tests/templates/server/test_model_wrapper.py +248 -0
  112. truss/tests/{server → templates/server}/test_schema.py +3 -5
  113. truss/tests/{server/core/server/common → templates/server}/test_truss_server.py +8 -5
  114. truss/tests/test_build.py +9 -52
  115. truss/tests/test_config.py +336 -77
  116. truss/tests/test_context_builder_image.py +3 -11
  117. truss/tests/test_control_truss_patching.py +7 -12
  118. truss/tests/test_custom_server.py +38 -0
  119. truss/tests/test_data/context_builder_image_test/test.py +3 -0
  120. truss/tests/test_data/happy.ipynb +56 -0
  121. truss/tests/test_data/model_load_failure_test/config.yaml +2 -0
  122. truss/tests/test_data/model_load_failure_test/model/__init__.py +0 -0
  123. truss/tests/test_data/patch_ping_test_server/__init__.py +0 -0
  124. truss/{test_data → tests/test_data}/patch_ping_test_server/app.py +3 -9
  125. truss/{test_data → tests/test_data}/server.Dockerfile +20 -21
  126. truss/tests/test_data/server_conformance_test_truss/__init__.py +0 -0
  127. truss/tests/test_data/server_conformance_test_truss/model/__init__.py +0 -0
  128. truss/{test_data → tests/test_data}/server_conformance_test_truss/model/model.py +1 -3
  129. truss/tests/test_data/test_async_truss/__init__.py +0 -0
  130. truss/tests/test_data/test_async_truss/model/__init__.py +0 -0
  131. truss/tests/test_data/test_basic_truss/__init__.py +0 -0
  132. truss/tests/test_data/test_basic_truss/config.yaml +16 -0
  133. truss/tests/test_data/test_basic_truss/model/__init__.py +0 -0
  134. truss/tests/test_data/test_build_commands/__init__.py +0 -0
  135. truss/tests/test_data/test_build_commands/config.yaml +13 -0
  136. truss/tests/test_data/test_build_commands/model/__init__.py +0 -0
  137. truss/{test_data/test_streaming_async_generator_truss → tests/test_data/test_build_commands}/model/model.py +2 -3
  138. truss/tests/test_data/test_build_commands_failure/__init__.py +0 -0
  139. truss/tests/test_data/test_build_commands_failure/config.yaml +14 -0
  140. truss/tests/test_data/test_build_commands_failure/model/__init__.py +0 -0
  141. truss/tests/test_data/test_build_commands_failure/model/model.py +17 -0
  142. truss/tests/test_data/test_concurrency_truss/__init__.py +0 -0
  143. truss/tests/test_data/test_concurrency_truss/config.yaml +4 -0
  144. truss/tests/test_data/test_concurrency_truss/model/__init__.py +0 -0
  145. truss/tests/test_data/test_custom_server_truss/__init__.py +0 -0
  146. truss/tests/test_data/test_custom_server_truss/config.yaml +20 -0
  147. truss/tests/test_data/test_custom_server_truss/test_docker_image/Dockerfile +17 -0
  148. truss/tests/test_data/test_custom_server_truss/test_docker_image/README.md +10 -0
  149. truss/tests/test_data/test_custom_server_truss/test_docker_image/VERSION +1 -0
  150. truss/tests/test_data/test_custom_server_truss/test_docker_image/__init__.py +0 -0
  151. truss/tests/test_data/test_custom_server_truss/test_docker_image/app.py +19 -0
  152. truss/tests/test_data/test_custom_server_truss/test_docker_image/build_upload_new_image.sh +6 -0
  153. truss/tests/test_data/test_openai/__init__.py +0 -0
  154. truss/{test_data/test_basic_truss → tests/test_data/test_openai}/config.yaml +1 -2
  155. truss/tests/test_data/test_openai/model/__init__.py +0 -0
  156. truss/tests/test_data/test_openai/model/model.py +15 -0
  157. truss/tests/test_data/test_pyantic_v1/__init__.py +0 -0
  158. truss/tests/test_data/test_pyantic_v1/model/__init__.py +0 -0
  159. truss/tests/test_data/test_pyantic_v1/model/model.py +28 -0
  160. truss/tests/test_data/test_pyantic_v1/requirements.txt +1 -0
  161. truss/tests/test_data/test_pyantic_v2/__init__.py +0 -0
  162. truss/tests/test_data/test_pyantic_v2/config.yaml +13 -0
  163. truss/tests/test_data/test_pyantic_v2/model/__init__.py +0 -0
  164. truss/tests/test_data/test_pyantic_v2/model/model.py +30 -0
  165. truss/tests/test_data/test_pyantic_v2/requirements.txt +1 -0
  166. truss/tests/test_data/test_requirements_file_truss/__init__.py +0 -0
  167. truss/tests/test_data/test_requirements_file_truss/config.yaml +13 -0
  168. truss/tests/test_data/test_requirements_file_truss/model/__init__.py +0 -0
  169. truss/{test_data → tests/test_data}/test_requirements_file_truss/model/model.py +1 -0
  170. truss/tests/test_data/test_streaming_async_generator_truss/__init__.py +0 -0
  171. truss/tests/test_data/test_streaming_async_generator_truss/config.yaml +4 -0
  172. truss/tests/test_data/test_streaming_async_generator_truss/model/__init__.py +0 -0
  173. truss/tests/test_data/test_streaming_async_generator_truss/model/model.py +7 -0
  174. truss/tests/test_data/test_streaming_read_timeout/__init__.py +0 -0
  175. truss/tests/test_data/test_streaming_read_timeout/model/__init__.py +0 -0
  176. truss/tests/test_data/test_streaming_truss/__init__.py +0 -0
  177. truss/tests/test_data/test_streaming_truss/config.yaml +4 -0
  178. truss/tests/test_data/test_streaming_truss/model/__init__.py +0 -0
  179. truss/tests/test_data/test_streaming_truss_with_error/__init__.py +0 -0
  180. truss/tests/test_data/test_streaming_truss_with_error/model/__init__.py +0 -0
  181. truss/{test_data → tests/test_data}/test_streaming_truss_with_error/model/model.py +3 -11
  182. truss/tests/test_data/test_streaming_truss_with_error/packages/__init__.py +0 -0
  183. truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_1.py +5 -0
  184. truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_2.py +2 -0
  185. truss/tests/test_data/test_streaming_truss_with_tracing/__init__.py +0 -0
  186. truss/tests/test_data/test_streaming_truss_with_tracing/config.yaml +43 -0
  187. truss/tests/test_data/test_streaming_truss_with_tracing/model/__init__.py +0 -0
  188. truss/tests/test_data/test_streaming_truss_with_tracing/model/model.py +65 -0
  189. truss/tests/test_data/test_trt_llm_truss/__init__.py +0 -0
  190. truss/tests/test_data/test_trt_llm_truss/config.yaml +15 -0
  191. truss/tests/test_data/test_trt_llm_truss/model/__init__.py +0 -0
  192. truss/tests/test_data/test_trt_llm_truss/model/model.py +15 -0
  193. truss/tests/test_data/test_truss/__init__.py +0 -0
  194. truss/tests/test_data/test_truss/config.yaml +4 -0
  195. truss/tests/test_data/test_truss/model/__init__.py +0 -0
  196. truss/tests/test_data/test_truss/model/dummy +0 -0
  197. truss/tests/test_data/test_truss/packages/__init__.py +0 -0
  198. truss/tests/test_data/test_truss/packages/test_package/__init__.py +0 -0
  199. truss/tests/test_data/test_truss_server_caching_truss/__init__.py +0 -0
  200. truss/tests/test_data/test_truss_server_caching_truss/model/__init__.py +0 -0
  201. truss/tests/test_data/test_truss_with_error/__init__.py +0 -0
  202. truss/tests/test_data/test_truss_with_error/config.yaml +4 -0
  203. truss/tests/test_data/test_truss_with_error/model/__init__.py +0 -0
  204. truss/tests/test_data/test_truss_with_error/model/model.py +8 -0
  205. truss/tests/test_data/test_truss_with_error/packages/__init__.py +0 -0
  206. truss/tests/test_data/test_truss_with_error/packages/helpers_1.py +5 -0
  207. truss/tests/test_data/test_truss_with_error/packages/helpers_2.py +2 -0
  208. truss/tests/test_docker.py +2 -1
  209. truss/tests/test_model_inference.py +1340 -292
  210. truss/tests/test_model_schema.py +33 -26
  211. truss/tests/test_testing_utilities_for_other_tests.py +50 -5
  212. truss/tests/test_truss_gatherer.py +3 -5
  213. truss/tests/test_truss_handle.py +62 -59
  214. truss/tests/test_util.py +2 -1
  215. truss/tests/test_validation.py +15 -13
  216. truss/tests/trt_llm/test_trt_llm_config.py +41 -0
  217. truss/tests/trt_llm/test_validation.py +91 -0
  218. truss/tests/util/test_config_checks.py +40 -0
  219. truss/tests/util/test_env_vars.py +14 -0
  220. truss/tests/util/test_path.py +10 -23
  221. truss/trt_llm/config_checks.py +43 -0
  222. truss/trt_llm/validation.py +42 -0
  223. truss/truss_handle/__init__.py +0 -0
  224. truss/truss_handle/build.py +122 -0
  225. truss/{decorators.py → truss_handle/decorators.py} +1 -1
  226. truss/truss_handle/patch/__init__.py +0 -0
  227. truss/{patch → truss_handle/patch}/calc_patch.py +146 -92
  228. truss/{types.py → truss_handle/patch/custom_types.py} +35 -27
  229. truss/{patch → truss_handle/patch}/dir_signature.py +1 -1
  230. truss/truss_handle/patch/hash.py +71 -0
  231. truss/{patch → truss_handle/patch}/local_truss_patch_applier.py +6 -4
  232. truss/truss_handle/patch/signature.py +22 -0
  233. truss/truss_handle/patch/truss_dir_patch_applier.py +87 -0
  234. truss/{readme_generator.py → truss_handle/readme_generator.py} +3 -2
  235. truss/{truss_gatherer.py → truss_handle/truss_gatherer.py} +3 -2
  236. truss/{truss_handle.py → truss_handle/truss_handle.py} +174 -78
  237. truss/util/.truss_ignore +3 -0
  238. truss/{docker.py → util/docker.py} +6 -2
  239. truss/util/download.py +6 -15
  240. truss/util/env_vars.py +41 -0
  241. truss/util/log_utils.py +52 -0
  242. truss/util/path.py +20 -20
  243. truss/util/requirements.py +11 -0
  244. {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/METADATA +18 -16
  245. truss-0.60.0.dist-info/RECORD +324 -0
  246. {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/WHEEL +1 -1
  247. truss-0.60.0.dist-info/entry_points.txt +4 -0
  248. truss_chains/__init__.py +71 -0
  249. truss_chains/definitions.py +756 -0
  250. truss_chains/deployment/__init__.py +0 -0
  251. truss_chains/deployment/code_gen.py +816 -0
  252. truss_chains/deployment/deployment_client.py +871 -0
  253. truss_chains/framework.py +1480 -0
  254. truss_chains/public_api.py +231 -0
  255. truss_chains/py.typed +0 -0
  256. truss_chains/pydantic_numpy.py +131 -0
  257. truss_chains/reference_code/reference_chainlet.py +34 -0
  258. truss_chains/reference_code/reference_model.py +10 -0
  259. truss_chains/remote_chainlet/__init__.py +0 -0
  260. truss_chains/remote_chainlet/model_skeleton.py +60 -0
  261. truss_chains/remote_chainlet/stub.py +380 -0
  262. truss_chains/remote_chainlet/utils.py +332 -0
  263. truss_chains/streaming.py +378 -0
  264. truss_chains/utils.py +178 -0
  265. CODE_OF_CONDUCT.md +0 -131
  266. CONTRIBUTING.md +0 -48
  267. README.md +0 -137
  268. context_builder.Dockerfile +0 -24
  269. truss/blob/blob_backend.py +0 -10
  270. truss/blob/blob_backend_registry.py +0 -23
  271. truss/blob/http_public_blob_backend.py +0 -23
  272. truss/build/__init__.py +0 -2
  273. truss/build/build.py +0 -143
  274. truss/build/configure.py +0 -63
  275. truss/cli/__init__.py +0 -2
  276. truss/cli/console.py +0 -5
  277. truss/cli/create.py +0 -5
  278. truss/config/trt_llm.py +0 -81
  279. truss/constants.py +0 -61
  280. truss/model_inference.py +0 -123
  281. truss/patch/types.py +0 -30
  282. truss/pytest.ini +0 -7
  283. truss/server/common/errors.py +0 -100
  284. truss/server/common/termination_handler_middleware.py +0 -64
  285. truss/server/common/truss_server.py +0 -389
  286. truss/server/control/patch/model_code_patch_applier.py +0 -46
  287. truss/server/control/patch/requirement_name_identifier.py +0 -17
  288. truss/server/inference_server.py +0 -29
  289. truss/server/model_wrapper.py +0 -434
  290. truss/server/shared/logging.py +0 -81
  291. truss/templates/trtllm/model/model.py +0 -97
  292. truss/templates/trtllm/packages/build_engine_utils.py +0 -34
  293. truss/templates/trtllm/packages/constants.py +0 -11
  294. truss/templates/trtllm/packages/schema.py +0 -216
  295. truss/templates/trtllm/packages/tensorrt_llm_model_repository/ensemble/config.pbtxt +0 -246
  296. truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/1/model.py +0 -181
  297. truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/config.pbtxt +0 -64
  298. truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/1/model.py +0 -260
  299. truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/config.pbtxt +0 -99
  300. truss/templates/trtllm/packages/tensorrt_llm_model_repository/tensorrt_llm/config.pbtxt +0 -208
  301. truss/templates/trtllm/packages/triton_client.py +0 -150
  302. truss/templates/trtllm/packages/utils.py +0 -43
  303. truss/test_data/context_builder_image_test/test.py +0 -4
  304. truss/test_data/happy.ipynb +0 -54
  305. truss/test_data/model_load_failure_test/config.yaml +0 -2
  306. truss/test_data/test_concurrency_truss/config.yaml +0 -2
  307. truss/test_data/test_streaming_async_generator_truss/config.yaml +0 -2
  308. truss/test_data/test_streaming_truss/config.yaml +0 -3
  309. truss/test_data/test_truss/config.yaml +0 -2
  310. truss/tests/server/common/test_termination_handler_middleware.py +0 -93
  311. truss/tests/server/control/test_model_container_patch_applier.py +0 -203
  312. truss/tests/server/core/server/common/test_util.py +0 -19
  313. truss/tests/server/test_model_wrapper.py +0 -87
  314. truss/util/data_structures.py +0 -16
  315. truss-0.10.0rc1.dist-info/RECORD +0 -216
  316. truss-0.10.0rc1.dist-info/entry_points.txt +0 -3
  317. truss/{server/shared → base}/__init__.py +0 -0
  318. truss/{server → templates/control}/control/helpers/context_managers.py +0 -0
  319. truss/{server/control → templates/control/control/helpers}/errors.py +0 -0
  320. truss/{server/control/patch → templates/control/control/helpers/truss_patch}/__init__.py +0 -0
  321. truss/{server/control/patch → templates/control/control/helpers/truss_patch}/system_packages.py +0 -0
  322. truss/{test_data/annotated_types_truss/model → templates/server}/__init__.py +0 -0
  323. truss/{server → templates/server}/common/__init__.py +0 -0
  324. truss/{test_data/gcs_fix/model → templates/shared}/__init__.py +0 -0
  325. truss/templates/{trtllm → trtllm-briton}/README.md +0 -0
  326. truss/{test_data/server_conformance_test_truss/model → tests/test_data}/__init__.py +0 -0
  327. truss/{test_data/test_basic_truss/model → tests/test_data/annotated_types_truss}/__init__.py +0 -0
  328. truss/{test_data → tests/test_data}/annotated_types_truss/config.yaml +0 -0
  329. truss/{test_data/test_requirements_file_truss → tests/test_data/annotated_types_truss}/model/__init__.py +0 -0
  330. truss/{test_data → tests/test_data}/annotated_types_truss/model/model.py +0 -0
  331. truss/{test_data → tests/test_data}/auto-mpg.data +0 -0
  332. truss/{test_data → tests/test_data}/context_builder_image_test/Dockerfile +0 -0
  333. truss/{test_data/test_truss/model → tests/test_data/context_builder_image_test}/__init__.py +0 -0
  334. truss/{test_data/test_truss_server_caching_truss/model → tests/test_data/gcs_fix}/__init__.py +0 -0
  335. truss/{test_data → tests/test_data}/gcs_fix/config.yaml +0 -0
  336. truss/tests/{local → test_data/gcs_fix/model}/__init__.py +0 -0
  337. truss/{test_data → tests/test_data}/gcs_fix/model/model.py +0 -0
  338. truss/{test_data/test_truss/model/dummy → tests/test_data/model_load_failure_test/__init__.py} +0 -0
  339. truss/{test_data → tests/test_data}/model_load_failure_test/model/model.py +0 -0
  340. truss/{test_data → tests/test_data}/pima-indians-diabetes.csv +0 -0
  341. truss/{test_data → tests/test_data}/readme_int_example.md +0 -0
  342. truss/{test_data → tests/test_data}/readme_no_example.md +0 -0
  343. truss/{test_data → tests/test_data}/readme_str_example.md +0 -0
  344. truss/{test_data → tests/test_data}/server_conformance_test_truss/config.yaml +0 -0
  345. truss/{test_data → tests/test_data}/test_async_truss/config.yaml +0 -0
  346. truss/{test_data → tests/test_data}/test_async_truss/model/model.py +3 -3
  347. /truss/{test_data → tests/test_data}/test_basic_truss/model/model.py +0 -0
  348. /truss/{test_data → tests/test_data}/test_concurrency_truss/model/model.py +0 -0
  349. /truss/{test_data/test_requirements_file_truss → tests/test_data/test_pyantic_v1}/config.yaml +0 -0
  350. /truss/{test_data → tests/test_data}/test_requirements_file_truss/requirements.txt +0 -0
  351. /truss/{test_data → tests/test_data}/test_streaming_read_timeout/config.yaml +0 -0
  352. /truss/{test_data → tests/test_data}/test_streaming_read_timeout/model/model.py +0 -0
  353. /truss/{test_data → tests/test_data}/test_streaming_truss/model/model.py +0 -0
  354. /truss/{test_data → tests/test_data}/test_streaming_truss_with_error/config.yaml +0 -0
  355. /truss/{test_data → tests/test_data}/test_truss/examples.yaml +0 -0
  356. /truss/{test_data → tests/test_data}/test_truss/model/model.py +0 -0
  357. /truss/{test_data → tests/test_data}/test_truss/packages/test_package/test.py +0 -0
  358. /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/config.yaml +0 -0
  359. /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/model/model.py +0 -0
  360. /truss/{patch → truss_handle/patch}/constants.py +0 -0
  361. /truss/{notebook.py → util/notebook.py} +0 -0
  362. {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/LICENSE +0 -0
@@ -1,21 +1,28 @@
1
+ import copy
1
2
  import tempfile
3
+ from contextlib import nullcontext as does_not_raise
2
4
  from pathlib import Path
3
5
 
4
6
  import pytest
5
7
  import yaml
6
- from truss.truss_config import (
8
+
9
+ from truss.base.custom_types import ModelFrameworkType
10
+ from truss.base.trt_llm_config import TrussTRTLLMQuantizationType
11
+ from truss.base.truss_config import (
7
12
  DEFAULT_CPU,
8
13
  DEFAULT_MEMORY,
9
14
  DEFAULT_USE_GPU,
10
15
  Accelerator,
11
16
  AcceleratorSpec,
12
17
  BaseImage,
18
+ DockerAuthSettings,
19
+ DockerAuthType,
13
20
  ModelCache,
14
21
  ModelRepo,
15
22
  Resources,
16
23
  TrussConfig,
17
24
  )
18
- from truss.types import ModelFrameworkType
25
+ from truss.truss_handle.truss_handle import TrussHandle
19
26
 
20
27
 
21
28
  @pytest.mark.parametrize(
@@ -71,6 +78,17 @@ from truss.types import ModelFrameworkType
71
78
  "accelerator": "A10G:4",
72
79
  },
73
80
  ),
81
+ (
82
+ {"node_count": 2},
83
+ Resources(node_count=2),
84
+ {
85
+ "cpu": DEFAULT_CPU,
86
+ "memory": DEFAULT_MEMORY,
87
+ "use_gpu": False,
88
+ "accelerator": None,
89
+ "node_count": 2,
90
+ },
91
+ ),
74
92
  ],
75
93
  )
76
94
  def test_parse_resources(input_dict, expect_resources, output_dict):
@@ -87,6 +105,8 @@ def test_parse_resources(input_dict, expect_resources, output_dict):
87
105
  ("A10G:4", AcceleratorSpec(Accelerator.A10G, 4)),
88
106
  ("A100:8", AcceleratorSpec(Accelerator.A100, 8)),
89
107
  ("H100", AcceleratorSpec(Accelerator.H100, 1)),
108
+ ("H200", AcceleratorSpec(Accelerator.H200, 1)),
109
+ ("H100_40GB", AcceleratorSpec(Accelerator.H100_40GB, 1)),
90
110
  ],
91
111
  )
92
112
  def test_acc_spec_from_str(input_str, expected_acc):
@@ -99,10 +119,7 @@ def test_acc_spec_from_str(input_str, expected_acc):
99
119
  (
100
120
  {},
101
121
  BaseImage(),
102
- {
103
- "image": "",
104
- "python_executable_path": "",
105
- },
122
+ {"image": "", "python_executable_path": "", "docker_auth": None},
106
123
  ),
107
124
  (
108
125
  {"image": "custom_base_image", "python_executable_path": "/path/python"},
@@ -110,6 +127,36 @@ def test_acc_spec_from_str(input_str, expected_acc):
110
127
  {
111
128
  "image": "custom_base_image",
112
129
  "python_executable_path": "/path/python",
130
+ "docker_auth": None,
131
+ },
132
+ ),
133
+ (
134
+ {
135
+ "image": "custom_base_image",
136
+ "python_executable_path": "/path/python",
137
+ "docker_auth": {
138
+ "auth_method": "GCP_SERVICE_ACCOUNT_JSON",
139
+ "secret_name": "some-secret-name",
140
+ "registry": "some-docker-registry",
141
+ },
142
+ },
143
+ BaseImage(
144
+ image="custom_base_image",
145
+ python_executable_path="/path/python",
146
+ docker_auth=DockerAuthSettings(
147
+ auth_method=DockerAuthType.GCP_SERVICE_ACCOUNT_JSON,
148
+ secret_name="some-secret-name",
149
+ registry="some-docker-registry",
150
+ ),
151
+ ),
152
+ {
153
+ "image": "custom_base_image",
154
+ "python_executable_path": "/path/python",
155
+ "docker_auth": {
156
+ "auth_method": "GCP_SERVICE_ACCOUNT_JSON",
157
+ "secret_name": "some-secret-name",
158
+ "registry": "some-docker-registry",
159
+ },
113
160
  },
114
161
  ),
115
162
  ],
@@ -120,33 +167,11 @@ def test_parse_base_image(input_dict, expect_base_image, output_dict):
120
167
  assert parsed_result.to_dict() == output_dict
121
168
 
122
169
 
123
- def generate_default_config():
124
- config = {
125
- "environment_variables": {},
126
- "external_package_dirs": [],
127
- "model_metadata": {},
128
- "model_name": None,
129
- "python_version": "py39",
130
- "requirements": [],
131
- "resources": {
132
- "accelerator": None,
133
- "cpu": "1",
134
- "memory": "2Gi",
135
- "use_gpu": False,
136
- },
137
- "secrets": {},
138
- "system_packages": [],
139
- }
140
- return config
141
-
142
-
143
170
  def test_default_config_not_crowded_end_to_end():
144
- config = TrussConfig(
145
- python_version="py39",
146
- requirements=[],
147
- )
171
+ config = TrussConfig(python_version="py39", requirements=[])
148
172
 
149
- config_yaml = """environment_variables: {}
173
+ config_yaml = """build_commands: []
174
+ environment_variables: {}
150
175
  external_package_dirs: []
151
176
  model_metadata: {}
152
177
  model_name: null
@@ -168,14 +193,12 @@ system_packages: []
168
193
  "model_framework",
169
194
  [ModelFrameworkType.CUSTOM, ModelFrameworkType.SKLEARN, ModelFrameworkType.PYTORCH],
170
195
  )
171
- def test_model_framework(model_framework):
196
+ def test_model_framework(model_framework, default_config):
172
197
  config = TrussConfig(
173
- python_version="py39",
174
- requirements=[],
175
- model_framework=model_framework,
198
+ python_version="py39", requirements=[], model_framework=model_framework
176
199
  )
177
200
 
178
- new_config = generate_default_config()
201
+ new_config = default_config
179
202
  if model_framework == ModelFrameworkType.CUSTOM:
180
203
  assert new_config == config.to_dict(verbose=False)
181
204
  else:
@@ -199,19 +222,15 @@ def test_null_hf_cache_key():
199
222
  assert config.model_cache == ModelCache.from_list([])
200
223
 
201
224
 
202
- def test_huggingface_cache_single_model_default_revision():
225
+ def test_huggingface_cache_single_model_default_revision(default_config):
203
226
  config = TrussConfig(
204
227
  python_version="py39",
205
228
  requirements=[],
206
229
  model_cache=ModelCache(models=[ModelRepo("test/model")]),
207
230
  )
208
231
 
209
- new_config = generate_default_config()
210
- new_config["model_cache"] = [
211
- {
212
- "repo_id": "test/model",
213
- }
214
- ]
232
+ new_config = default_config
233
+ new_config["model_cache"] = [{"repo_id": "test/model"}]
215
234
 
216
235
  assert new_config == config.to_dict(verbose=False)
217
236
  assert config.to_dict(verbose=True)["model_cache"][0].get("revision") is None
@@ -227,24 +246,19 @@ def test_huggingface_cache_single_model_non_default_revision():
227
246
  assert config.to_dict(verbose=False)["model_cache"][0].get("revision") == "not-main"
228
247
 
229
248
 
230
- def test_huggingface_cache_multiple_models_default_revision():
249
+ def test_huggingface_cache_multiple_models_default_revision(default_config):
231
250
  config = TrussConfig(
232
251
  python_version="py39",
233
252
  requirements=[],
234
253
  model_cache=ModelCache(
235
- models=[
236
- ModelRepo("test/model1", "main"),
237
- ModelRepo("test/model2"),
238
- ]
254
+ models=[ModelRepo("test/model1", "main"), ModelRepo("test/model2")]
239
255
  ),
240
256
  )
241
257
 
242
- new_config = generate_default_config()
258
+ new_config = default_config
243
259
  new_config["model_cache"] = [
244
260
  {"repo_id": "test/model1", "revision": "main"},
245
- {
246
- "repo_id": "test/model2",
247
- },
261
+ {"repo_id": "test/model2"},
248
262
  ]
249
263
 
250
264
  assert new_config == config.to_dict(verbose=False)
@@ -252,23 +266,18 @@ def test_huggingface_cache_multiple_models_default_revision():
252
266
  assert config.to_dict(verbose=True)["model_cache"][1].get("revision") is None
253
267
 
254
268
 
255
- def test_huggingface_cache_multiple_models_mixed_revision():
269
+ def test_huggingface_cache_multiple_models_mixed_revision(default_config):
256
270
  config = TrussConfig(
257
271
  python_version="py39",
258
272
  requirements=[],
259
273
  model_cache=ModelCache(
260
- models=[
261
- ModelRepo("test/model1"),
262
- ModelRepo("test/model2", "not-main2"),
263
- ]
274
+ models=[ModelRepo("test/model1"), ModelRepo("test/model2", "not-main2")]
264
275
  ),
265
276
  )
266
277
 
267
- new_config = generate_default_config()
278
+ new_config = default_config
268
279
  new_config["model_cache"] = [
269
- {
270
- "repo_id": "test/model1",
271
- },
280
+ {"repo_id": "test/model1"},
272
281
  {"repo_id": "test/model2", "revision": "not-main2"},
273
282
  ]
274
283
 
@@ -277,37 +286,287 @@ def test_huggingface_cache_multiple_models_mixed_revision():
277
286
  assert config.to_dict(verbose=True)["model_cache"][1].get("revision") == "not-main2"
278
287
 
279
288
 
280
- def test_empty_config():
289
+ def test_empty_config(default_config):
281
290
  config = TrussConfig()
282
- new_config = generate_default_config()
291
+ new_config = default_config
283
292
 
284
293
  assert new_config == config.to_dict(verbose=False)
285
294
 
286
295
 
287
296
  def test_from_yaml():
288
- yaml_path = Path("test.yaml")
289
297
  data = {"description": "this is a test"}
290
- with yaml_path.open("w") as yaml_file:
298
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
299
+ yaml_path = Path(yaml_file.name)
291
300
  yaml.safe_dump(data, yaml_file)
292
301
 
293
- result = TrussConfig.from_yaml(yaml_path)
294
-
295
- assert result.description == "this is a test"
302
+ result = TrussConfig.from_yaml(yaml_path)
296
303
 
297
- yaml_path.unlink()
304
+ assert result.description == "this is a test"
298
305
 
299
306
 
300
307
  def test_from_yaml_empty():
301
- yaml_path = Path("test.yaml")
302
308
  data = {}
303
- with yaml_path.open("w") as yaml_file:
309
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
310
+ yaml_path = Path(yaml_file.name)
304
311
  yaml.safe_dump(data, yaml_file)
305
312
 
306
- result = TrussConfig.from_yaml(yaml_path)
313
+ result = TrussConfig.from_yaml(yaml_path)
307
314
 
308
- # test some attributes (should be default)
309
- assert result.description is None
310
- assert result.spec_version == "2.0"
311
- assert result.bundled_packages_dir == "packages"
315
+ # test some attributes (should be default)
316
+ assert result.description is None
317
+ assert result.spec_version == "2.0"
318
+ assert result.bundled_packages_dir == "packages"
319
+
320
+
321
+ def test_from_yaml_secrets_as_list():
322
+ data = {"description": "this is a test", "secrets": ["foo", "bar"]}
323
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
324
+ yaml_path = Path(yaml_file.name)
325
+ yaml.safe_dump(data, yaml_file)
312
326
 
313
- yaml_path.unlink()
327
+ with pytest.raises(ValueError):
328
+ TrussConfig.from_yaml(yaml_path)
329
+
330
+
331
+ def test_from_yaml_python_version():
332
+ invalid_py_version_data = {
333
+ "description": "this is a test",
334
+ "python_version": "py37",
335
+ }
336
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
337
+ yaml_path = Path(yaml_file.name)
338
+ yaml.safe_dump(invalid_py_version_data, yaml_file)
339
+
340
+ with pytest.raises(ValueError):
341
+ TrussConfig.from_yaml(yaml_path)
342
+
343
+ valid_py_version_data = {"description": "this is a test", "python_version": "py39"}
344
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
345
+ yaml_path = Path(yaml_file.name)
346
+ yaml.safe_dump(valid_py_version_data, yaml_file)
347
+
348
+ result = TrussConfig.from_yaml(yaml_path)
349
+ assert result.python_version == "py39"
350
+
351
+
352
+ def test_from_yaml_environment_variables():
353
+ data = {
354
+ "description": "this is a test",
355
+ "environment_variables": {"foo": "bar", "bool": True, "int": 0},
356
+ }
357
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
358
+ yaml_path = Path(yaml_file.name)
359
+ yaml.safe_dump(data, yaml_file)
360
+
361
+ result = TrussConfig.from_yaml(yaml_path)
362
+ assert result.environment_variables == {
363
+ "foo": "bar",
364
+ "bool": "true",
365
+ "int": "0",
366
+ }
367
+
368
+
369
+ def test_secret_to_path_mapping_correct_type(default_config):
370
+ data = {
371
+ "description": "this is a test",
372
+ "build": {"secret_to_path_mapping": {"foo": "/bar"}},
373
+ }
374
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
375
+ yaml_path = Path(yaml_file.name)
376
+ yaml.safe_dump(data, yaml_file)
377
+
378
+ truss_config = TrussConfig.from_yaml(yaml_path)
379
+ assert truss_config.build.secret_to_path_mapping == {"foo": "/bar"}
380
+
381
+
382
+ def test_secret_to_path_mapping_invalid_secret_name(default_config):
383
+ data = {
384
+ "description": "this is a test",
385
+ "build": {"secret_to_path_mapping": {"foo_bar": "/bar"}},
386
+ }
387
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
388
+ yaml_path = Path(yaml_file.name)
389
+ yaml.safe_dump(data, yaml_file)
390
+
391
+ with pytest.raises(ValueError):
392
+ TrussConfig.from_yaml(yaml_path)
393
+
394
+
395
+ def test_secret_to_path_mapping_incorrect_type(default_config):
396
+ data = {
397
+ "description": "this is a test",
398
+ "build": {"secret_to_path_mapping": ["something else"]},
399
+ }
400
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
401
+ yaml_path = Path(yaml_file.name)
402
+ yaml.safe_dump(data, yaml_file)
403
+
404
+ with pytest.raises(ValueError):
405
+ TrussConfig.from_yaml(yaml_path)
406
+
407
+
408
+ def test_max_beam_width_check(trtllm_config):
409
+ trtllm_config["trt_llm"]["build"]["max_beam_width"] = 2
410
+ with pytest.raises(ValueError):
411
+ TrussConfig.from_dict(trtllm_config)
412
+
413
+
414
+ def test_plugin_paged_context_fmha_check(trtllm_config):
415
+ trtllm_config["trt_llm"]["build"]["plugin_configuration"] = {
416
+ "paged_kv_cache": False,
417
+ "use_paged_context_fmha": True,
418
+ "use_fp8_context_fmha": False,
419
+ }
420
+ with pytest.raises(ValueError):
421
+ TrussConfig.from_dict(trtllm_config)
422
+
423
+
424
+ @pytest.mark.parametrize(
425
+ "repo",
426
+ [
427
+ "./llama-3.1-8b",
428
+ "../my-model-is-in-parent-directory",
429
+ "~/.huggingface/my--model--cache/model",
430
+ "foo.git",
431
+ "datasets/foo/bar",
432
+ ".repo_idother..repo..id",
433
+ ],
434
+ )
435
+ def test_invalid_hf_repo(trtllm_config, repo):
436
+ trtllm_config["trt_llm"]["build"]["checkpoint_repository"]["source"] = "HF"
437
+ trtllm_config["trt_llm"]["build"]["checkpoint_repository"]["repo"] = repo
438
+ with pytest.raises(ValueError):
439
+ TrussConfig.from_dict(trtllm_config)
440
+
441
+
442
+ def test_plugin_paged_fp8_context_fmha_check(trtllm_config):
443
+ trtllm_config["trt_llm"]["build"]["plugin_configuration"] = {
444
+ "paged_kv_cache": False,
445
+ "use_paged_context_fmha": False,
446
+ "use_fp8_context_fmha": True,
447
+ }
448
+ with pytest.raises(ValueError):
449
+ TrussConfig.from_dict(trtllm_config)
450
+ trtllm_config["trt_llm"]["build"]["plugin_configuration"] = {
451
+ "paged_kv_cache": True,
452
+ "use_paged_context_fmha": False,
453
+ "use_fp8_context_fmha": True,
454
+ }
455
+ with pytest.raises(ValueError):
456
+ TrussConfig.from_dict(trtllm_config)
457
+
458
+
459
+ def test_fp8_context_fmha_check_kv_dtype(trtllm_config):
460
+ trtllm_config["trt_llm"]["build"]["plugin_configuration"] = {
461
+ "paged_kv_cache": True,
462
+ "use_paged_context_fmha": True,
463
+ "use_fp8_context_fmha": True,
464
+ }
465
+ trtllm_config["trt_llm"]["build"]["quantization_type"] = (
466
+ TrussTRTLLMQuantizationType.FP8_KV.value
467
+ )
468
+ TrussConfig.from_dict(trtllm_config)
469
+
470
+ del trtllm_config["trt_llm"]["build"]["quantization_type"]
471
+ with pytest.raises(ValueError):
472
+ TrussConfig.from_dict(trtllm_config)
473
+
474
+
475
+ @pytest.mark.parametrize("verbose, expect_equal", [(False, True), (True, False)])
476
+ def test_to_dict_trtllm(
477
+ verbose,
478
+ expect_equal,
479
+ trtllm_config,
480
+ trtllm_spec_dec_config,
481
+ trtllm_spec_dec_config_full,
482
+ ):
483
+ assert (
484
+ TrussConfig.from_dict(trtllm_config).to_dict(verbose=verbose) == trtllm_config
485
+ ) == expect_equal
486
+ assert (
487
+ TrussConfig.from_dict(trtllm_spec_dec_config).to_dict(verbose=verbose)
488
+ == trtllm_spec_dec_config
489
+ ) == expect_equal
490
+ assert (
491
+ TrussConfig.from_dict(trtllm_spec_dec_config_full).to_dict(verbose=verbose)
492
+ == trtllm_spec_dec_config_full
493
+ ) == expect_equal
494
+
495
+
496
+ @pytest.mark.parametrize("should_raise", [False, True])
497
+ def test_from_dict_spec_dec_trt_llm(should_raise, trtllm_spec_dec_config):
498
+ test_config = copy.deepcopy(trtllm_spec_dec_config)
499
+ if should_raise:
500
+ test_config["trt_llm"]["build"]["speculator"]["speculative_decoding_mode"] = (
501
+ None
502
+ )
503
+ with pytest.raises(ValueError):
504
+ TrussConfig.from_dict(test_config)
505
+ test_config["trt_llm"]["build"]["speculator"]["checkpoint_repository"] = None
506
+ with pytest.raises(ValueError):
507
+ TrussConfig.from_dict(test_config)
508
+ test_config["trt_llm"]["build"]["speculator"]["checkpoint_repository"] = (
509
+ trtllm_spec_dec_config["trt_llm"]["build"]["speculator"][
510
+ "checkpoint_repository"
511
+ ]
512
+ )
513
+ test_config["trt_llm"]["build"]["plugin_configuration"][
514
+ "use_paged_context_fmha"
515
+ ] = False
516
+ with pytest.raises(ValueError):
517
+ TrussConfig.from_dict(test_config)
518
+ test_config["trt_llm"]["build"]["plugin_configuration"][
519
+ "use_paged_context_fmha"
520
+ ] = True
521
+ test_config["trt_llm"]["build"]["speculator"]["speculative_decoding_mode"] = (
522
+ trtllm_spec_dec_config["trt_llm"]["build"]["speculator"][
523
+ "speculative_decoding_mode"
524
+ ]
525
+ )
526
+ test_config["trt_llm"]["build"]["speculator"]["num_draft_tokens"] = None
527
+ with pytest.raises(ValueError):
528
+ TrussConfig.from_dict(test_config)
529
+ else:
530
+ TrussConfig.from_dict(trtllm_spec_dec_config)
531
+
532
+
533
+ def test_from_yaml_invalid_requirements_configuration():
534
+ invalid_requirements = {
535
+ "requirements_file": "requirements.txt",
536
+ "requirements": ["requests"],
537
+ }
538
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as yaml_file:
539
+ yaml_path = Path(yaml_file.name)
540
+ yaml.safe_dump(invalid_requirements, yaml_file)
541
+
542
+ with pytest.raises(ValueError):
543
+ TrussConfig.from_yaml(yaml_path)
544
+
545
+
546
+ @pytest.mark.parametrize(
547
+ "quant_format, accelerator, expectation",
548
+ [
549
+ (TrussTRTLLMQuantizationType.NO_QUANT, Accelerator.A100, does_not_raise()),
550
+ (TrussTRTLLMQuantizationType.FP8, Accelerator.H100, does_not_raise()),
551
+ (TrussTRTLLMQuantizationType.FP8_KV, Accelerator.H100_40GB, does_not_raise()),
552
+ (
553
+ TrussTRTLLMQuantizationType.WEIGHTS_ONLY_INT8,
554
+ Accelerator.A100,
555
+ pytest.raises(ValueError),
556
+ ),
557
+ (TrussTRTLLMQuantizationType.FP8, Accelerator.A100, pytest.raises(ValueError)),
558
+ (
559
+ TrussTRTLLMQuantizationType.FP8_KV,
560
+ Accelerator.A100,
561
+ pytest.raises(ValueError),
562
+ ),
563
+ ],
564
+ )
565
+ def test_validate_quant_format_and_accelerator_for_trt_llm_builder(
566
+ quant_format, accelerator, expectation, custom_model_trt_llm
567
+ ):
568
+ config = TrussHandle(custom_model_trt_llm).spec.config
569
+ config.trt_llm.build.quantization_type = quant_format
570
+ config.resources.accelerator.accelerator = accelerator
571
+ with expectation:
572
+ TrussConfig.from_dict(config.to_dict())
@@ -5,12 +5,10 @@ import pytest
5
5
 
6
6
 
7
7
  @pytest.mark.integration
8
- def test_build_docker_image():
8
+ def test_build_docker_image(test_data_path):
9
9
  root_path = Path(__file__).parent.parent.parent
10
10
  root = str(root_path)
11
- context_builder_image_test_dir = str(
12
- root_path / "truss" / "test_data" / "context_builder_image_test"
13
- )
11
+ context_builder_image_test_dir = str(test_data_path / "context_builder_image_test")
14
12
 
15
13
  subprocess.run(
16
14
  [
@@ -44,11 +42,5 @@ def test_build_docker_image():
44
42
 
45
43
  # This will throw if building docker build context fails
46
44
  subprocess.run(
47
- [
48
- "docker",
49
- "run",
50
- "baseten/truss-context-builder-test",
51
- ],
52
- check=True,
53
- cwd=root,
45
+ ["docker", "run", "baseten/truss-context-builder-test"], check=True, cwd=root
54
46
  )
@@ -1,9 +1,10 @@
1
1
  from dataclasses import replace
2
2
  from pathlib import Path
3
- from typing import Tuple
4
3
 
5
4
  import pytest
6
- from truss.constants import SUPPORTED_PYTHON_VERSIONS
5
+
6
+ from truss.base.constants import SUPPORTED_PYTHON_VERSIONS
7
+ from truss.base.truss_config import ExternalDataItem
7
8
  from truss.local.local_config_handler import LocalConfigHandler
8
9
  from truss.tests.test_testing_utilities_for_other_tests import ensure_kill_all
9
10
  from truss.tests.test_truss_handle import (
@@ -12,9 +13,8 @@ from truss.tests.test_truss_handle import (
12
13
  verify_system_package_installed_on_container,
13
14
  verify_system_requirement_not_installed_on_container,
14
15
  )
15
- from truss.truss_config import ExternalDataItem
16
- from truss.truss_gatherer import calc_shadow_truss_dirname
17
- from truss.truss_handle import TrussHandle
16
+ from truss.truss_handle.truss_gatherer import calc_shadow_truss_dirname
17
+ from truss.truss_handle.truss_handle import TrussHandle
18
18
 
19
19
 
20
20
  def current_num_docker_images(th: TrussHandle) -> int:
@@ -24,7 +24,7 @@ def current_num_docker_images(th: TrussHandle) -> int:
24
24
  @pytest.fixture
25
25
  def control_model_handle_tag_tuple(
26
26
  custom_model_control,
27
- ) -> Tuple[Path, TrussHandle, str]:
27
+ ) -> tuple[Path, TrussHandle, str]:
28
28
  th = TrussHandle(custom_model_control)
29
29
  tag = "test-docker-custom-model-control-tag:0.0.1"
30
30
  return (custom_model_control, th, tag)
@@ -410,12 +410,7 @@ class Model:
410
410
  )
411
411
  ],
412
412
  )
413
- th._update_config(
414
- lambda conf: replace(
415
- conf,
416
- external_data=new_external_data,
417
- )
418
- )
413
+ th._update_config(lambda conf: replace(conf, external_data=new_external_data))
419
414
  result = th.docker_predict([], tag=tag, network="host")
420
415
  assert result == content and orig_num_truss_images == current_num_docker_images(
421
416
  th
@@ -0,0 +1,38 @@
1
+ import pytest
2
+ import requests
3
+ from tenacity import stop_after_attempt
4
+
5
+ from truss.local.local_config_handler import LocalConfigHandler
6
+ from truss.tests.test_testing_utilities_for_other_tests import ensure_kill_all
7
+ from truss.truss_handle.truss_handle import TrussHandle
8
+
9
+
10
+ @pytest.mark.integration
11
+ def test_custom_server_truss(test_data_path):
12
+ with ensure_kill_all():
13
+ print("Running test_custom_server_truss")
14
+ truss_dir = test_data_path / "test_custom_server_truss"
15
+ print(f"truss_dir: {truss_dir}")
16
+ tr = TrussHandle(truss_dir)
17
+ print("Setting secret")
18
+ LocalConfigHandler.set_secret("hf_access_token", "123")
19
+ try:
20
+ print("Starting container")
21
+ _ = tr.docker_run(
22
+ local_port=8090,
23
+ detach=True,
24
+ wait_for_server_ready=True,
25
+ model_server_stop_retry_override=stop_after_attempt(3),
26
+ )
27
+ except Exception as e:
28
+ raise Exception(f"Failed to start container: {e}")
29
+ truss_server_addr = "http://localhost:8090"
30
+ full_url = f"{truss_server_addr}/v1/models/model:predict"
31
+
32
+ response = requests.post(full_url, json={})
33
+ assert response.status_code == 200
34
+ assert response.json() == {
35
+ "message": "Hello World",
36
+ "is_env_var_passed": True,
37
+ "is_secret_mounted": True,
38
+ }
@@ -0,0 +1,3 @@
1
+ from truss.base import truss_config
2
+
3
+ print(truss_config)