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.
- truss/__init__.py +10 -3
- truss/api/__init__.py +123 -0
- truss/api/definitions.py +51 -0
- truss/base/constants.py +116 -0
- truss/base/custom_types.py +29 -0
- truss/{errors.py → base/errors.py} +4 -0
- truss/base/trt_llm_config.py +310 -0
- truss/{truss_config.py → base/truss_config.py} +344 -31
- truss/{truss_spec.py → base/truss_spec.py} +20 -6
- truss/{validation.py → base/validation.py} +60 -11
- truss/cli/cli.py +841 -88
- truss/{remote → cli}/remote_cli.py +2 -7
- truss/contexts/docker_build_setup.py +67 -0
- truss/contexts/image_builder/cache_warmer.py +2 -8
- truss/contexts/image_builder/image_builder.py +1 -1
- truss/contexts/image_builder/serving_image_builder.py +292 -46
- truss/contexts/image_builder/util.py +1 -3
- truss/contexts/local_loader/docker_build_emulator.py +58 -0
- truss/contexts/local_loader/load_model_local.py +2 -2
- truss/contexts/local_loader/truss_module_loader.py +1 -1
- truss/contexts/local_loader/utils.py +1 -1
- truss/local/local_config.py +2 -6
- truss/local/local_config_handler.py +20 -5
- truss/patch/__init__.py +1 -0
- truss/patch/hash.py +4 -70
- truss/patch/signature.py +4 -16
- truss/patch/truss_dir_patch_applier.py +3 -78
- truss/remote/baseten/api.py +308 -23
- truss/remote/baseten/auth.py +3 -3
- truss/remote/baseten/core.py +257 -50
- truss/remote/baseten/custom_types.py +44 -0
- truss/remote/baseten/error.py +4 -0
- truss/remote/baseten/remote.py +369 -118
- truss/remote/baseten/service.py +118 -11
- truss/remote/baseten/utils/status.py +29 -0
- truss/remote/baseten/utils/tar.py +34 -22
- truss/remote/baseten/utils/transfer.py +36 -23
- truss/remote/remote_factory.py +14 -5
- truss/remote/truss_remote.py +72 -45
- truss/templates/base.Dockerfile.jinja +18 -16
- truss/templates/cache.Dockerfile.jinja +3 -3
- truss/{server → templates/control}/control/application.py +14 -35
- truss/{server → templates/control}/control/endpoints.py +39 -9
- truss/{server/control/patch/types.py → templates/control/control/helpers/custom_types.py} +13 -52
- truss/{server → templates/control}/control/helpers/inference_server_controller.py +4 -8
- truss/{server → templates/control}/control/helpers/inference_server_process_controller.py +2 -4
- truss/{server → templates/control}/control/helpers/inference_server_starter.py +5 -10
- truss/{server/control → templates/control/control/helpers}/truss_patch/model_code_patch_applier.py +8 -6
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/model_container_patch_applier.py +18 -26
- truss/templates/control/control/helpers/truss_patch/requirement_name_identifier.py +66 -0
- truss/{server → templates/control}/control/server.py +11 -6
- truss/templates/control/requirements.txt +9 -0
- truss/templates/custom_python_dx/my_model.py +28 -0
- truss/templates/docker_server/proxy.conf.jinja +42 -0
- truss/templates/docker_server/supervisord.conf.jinja +27 -0
- truss/templates/docker_server_requirements.txt +1 -0
- truss/templates/server/common/errors.py +231 -0
- truss/{server → templates/server}/common/patches/whisper/patch.py +1 -0
- truss/{server/common/patches/__init__.py → templates/server/common/patches.py} +1 -3
- truss/{server → templates/server}/common/retry.py +1 -0
- truss/{server → templates/server}/common/schema.py +11 -9
- truss/templates/server/common/tracing.py +157 -0
- truss/templates/server/main.py +9 -0
- truss/templates/server/model_wrapper.py +961 -0
- truss/templates/server/requirements.txt +21 -0
- truss/templates/server/truss_server.py +447 -0
- truss/templates/server.Dockerfile.jinja +62 -14
- truss/templates/shared/dynamic_config_resolver.py +28 -0
- truss/templates/shared/lazy_data_resolver.py +164 -0
- truss/templates/shared/log_config.py +125 -0
- truss/{server → templates}/shared/secrets_resolver.py +1 -2
- truss/{server → templates}/shared/serialization.py +31 -9
- truss/{server → templates}/shared/util.py +3 -13
- truss/templates/trtllm-audio/model/model.py +49 -0
- truss/templates/trtllm-audio/packages/sigint_patch.py +14 -0
- truss/templates/trtllm-audio/packages/whisper_trt/__init__.py +215 -0
- truss/templates/trtllm-audio/packages/whisper_trt/assets.py +25 -0
- truss/templates/trtllm-audio/packages/whisper_trt/batching.py +52 -0
- truss/templates/trtllm-audio/packages/whisper_trt/custom_types.py +26 -0
- truss/templates/trtllm-audio/packages/whisper_trt/modeling.py +184 -0
- truss/templates/trtllm-audio/packages/whisper_trt/tokenizer.py +185 -0
- truss/templates/trtllm-audio/packages/whisper_trt/utils.py +245 -0
- truss/templates/trtllm-briton/src/extension.py +64 -0
- truss/tests/conftest.py +302 -94
- truss/tests/contexts/image_builder/test_serving_image_builder.py +74 -31
- truss/tests/contexts/local_loader/test_load_local.py +2 -2
- truss/tests/contexts/local_loader/test_truss_module_finder.py +1 -1
- truss/tests/patch/test_calc_patch.py +439 -127
- truss/tests/patch/test_dir_signature.py +3 -12
- truss/tests/patch/test_hash.py +1 -1
- truss/tests/patch/test_signature.py +1 -1
- truss/tests/patch/test_truss_dir_patch_applier.py +23 -11
- truss/tests/patch/test_types.py +2 -2
- truss/tests/remote/baseten/test_api.py +153 -58
- truss/tests/remote/baseten/test_auth.py +2 -1
- truss/tests/remote/baseten/test_core.py +160 -12
- truss/tests/remote/baseten/test_remote.py +489 -77
- truss/tests/remote/baseten/test_service.py +55 -0
- truss/tests/remote/test_remote_factory.py +16 -18
- truss/tests/remote/test_truss_remote.py +26 -17
- truss/tests/templates/control/control/helpers/test_context_managers.py +11 -0
- truss/tests/templates/control/control/helpers/test_model_container_patch_applier.py +184 -0
- truss/tests/templates/control/control/helpers/test_requirement_name_identifier.py +89 -0
- truss/tests/{server → templates/control}/control/test_server.py +79 -24
- truss/tests/{server → templates/control}/control/test_server_integration.py +24 -16
- truss/tests/templates/core/server/test_dynamic_config_resolver.py +108 -0
- truss/tests/templates/core/server/test_lazy_data_resolver.py +329 -0
- truss/tests/templates/core/server/test_lazy_data_resolver_v2.py +79 -0
- truss/tests/{server → templates}/core/server/test_secrets_resolver.py +1 -1
- truss/tests/{server → templates/server}/common/test_retry.py +3 -3
- truss/tests/templates/server/test_model_wrapper.py +248 -0
- truss/tests/{server → templates/server}/test_schema.py +3 -5
- truss/tests/{server/core/server/common → templates/server}/test_truss_server.py +8 -5
- truss/tests/test_build.py +9 -52
- truss/tests/test_config.py +336 -77
- truss/tests/test_context_builder_image.py +3 -11
- truss/tests/test_control_truss_patching.py +7 -12
- truss/tests/test_custom_server.py +38 -0
- truss/tests/test_data/context_builder_image_test/test.py +3 -0
- truss/tests/test_data/happy.ipynb +56 -0
- truss/tests/test_data/model_load_failure_test/config.yaml +2 -0
- truss/tests/test_data/model_load_failure_test/model/__init__.py +0 -0
- truss/tests/test_data/patch_ping_test_server/__init__.py +0 -0
- truss/{test_data → tests/test_data}/patch_ping_test_server/app.py +3 -9
- truss/{test_data → tests/test_data}/server.Dockerfile +20 -21
- truss/tests/test_data/server_conformance_test_truss/__init__.py +0 -0
- truss/tests/test_data/server_conformance_test_truss/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/server_conformance_test_truss/model/model.py +1 -3
- truss/tests/test_data/test_async_truss/__init__.py +0 -0
- truss/tests/test_data/test_async_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_basic_truss/__init__.py +0 -0
- truss/tests/test_data/test_basic_truss/config.yaml +16 -0
- truss/tests/test_data/test_basic_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_build_commands/__init__.py +0 -0
- truss/tests/test_data/test_build_commands/config.yaml +13 -0
- truss/tests/test_data/test_build_commands/model/__init__.py +0 -0
- truss/{test_data/test_streaming_async_generator_truss → tests/test_data/test_build_commands}/model/model.py +2 -3
- truss/tests/test_data/test_build_commands_failure/__init__.py +0 -0
- truss/tests/test_data/test_build_commands_failure/config.yaml +14 -0
- truss/tests/test_data/test_build_commands_failure/model/__init__.py +0 -0
- truss/tests/test_data/test_build_commands_failure/model/model.py +17 -0
- truss/tests/test_data/test_concurrency_truss/__init__.py +0 -0
- truss/tests/test_data/test_concurrency_truss/config.yaml +4 -0
- truss/tests/test_data/test_concurrency_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/config.yaml +20 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/Dockerfile +17 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/README.md +10 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/VERSION +1 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/app.py +19 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/build_upload_new_image.sh +6 -0
- truss/tests/test_data/test_openai/__init__.py +0 -0
- truss/{test_data/test_basic_truss → tests/test_data/test_openai}/config.yaml +1 -2
- truss/tests/test_data/test_openai/model/__init__.py +0 -0
- truss/tests/test_data/test_openai/model/model.py +15 -0
- truss/tests/test_data/test_pyantic_v1/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v1/model/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v1/model/model.py +28 -0
- truss/tests/test_data/test_pyantic_v1/requirements.txt +1 -0
- truss/tests/test_data/test_pyantic_v2/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v2/config.yaml +13 -0
- truss/tests/test_data/test_pyantic_v2/model/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v2/model/model.py +30 -0
- truss/tests/test_data/test_pyantic_v2/requirements.txt +1 -0
- truss/tests/test_data/test_requirements_file_truss/__init__.py +0 -0
- truss/tests/test_data/test_requirements_file_truss/config.yaml +13 -0
- truss/tests/test_data/test_requirements_file_truss/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/test_requirements_file_truss/model/model.py +1 -0
- truss/tests/test_data/test_streaming_async_generator_truss/__init__.py +0 -0
- truss/tests/test_data/test_streaming_async_generator_truss/config.yaml +4 -0
- truss/tests/test_data/test_streaming_async_generator_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_async_generator_truss/model/model.py +7 -0
- truss/tests/test_data/test_streaming_read_timeout/__init__.py +0 -0
- truss/tests/test_data/test_streaming_read_timeout/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss/config.yaml +4 -0
- truss/tests/test_data/test_streaming_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/test_streaming_truss_with_error/model/model.py +3 -11
- truss/tests/test_data/test_streaming_truss_with_error/packages/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_1.py +5 -0
- truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_2.py +2 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/config.yaml +43 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/model/model.py +65 -0
- truss/tests/test_data/test_trt_llm_truss/__init__.py +0 -0
- truss/tests/test_data/test_trt_llm_truss/config.yaml +15 -0
- truss/tests/test_data/test_trt_llm_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_trt_llm_truss/model/model.py +15 -0
- truss/tests/test_data/test_truss/__init__.py +0 -0
- truss/tests/test_data/test_truss/config.yaml +4 -0
- truss/tests/test_data/test_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_truss/model/dummy +0 -0
- truss/tests/test_data/test_truss/packages/__init__.py +0 -0
- truss/tests/test_data/test_truss/packages/test_package/__init__.py +0 -0
- truss/tests/test_data/test_truss_server_caching_truss/__init__.py +0 -0
- truss/tests/test_data/test_truss_server_caching_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/config.yaml +4 -0
- truss/tests/test_data/test_truss_with_error/model/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/model/model.py +8 -0
- truss/tests/test_data/test_truss_with_error/packages/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/packages/helpers_1.py +5 -0
- truss/tests/test_data/test_truss_with_error/packages/helpers_2.py +2 -0
- truss/tests/test_docker.py +2 -1
- truss/tests/test_model_inference.py +1340 -292
- truss/tests/test_model_schema.py +33 -26
- truss/tests/test_testing_utilities_for_other_tests.py +50 -5
- truss/tests/test_truss_gatherer.py +3 -5
- truss/tests/test_truss_handle.py +62 -59
- truss/tests/test_util.py +2 -1
- truss/tests/test_validation.py +15 -13
- truss/tests/trt_llm/test_trt_llm_config.py +41 -0
- truss/tests/trt_llm/test_validation.py +91 -0
- truss/tests/util/test_config_checks.py +40 -0
- truss/tests/util/test_env_vars.py +14 -0
- truss/tests/util/test_path.py +10 -23
- truss/trt_llm/config_checks.py +43 -0
- truss/trt_llm/validation.py +42 -0
- truss/truss_handle/__init__.py +0 -0
- truss/truss_handle/build.py +122 -0
- truss/{decorators.py → truss_handle/decorators.py} +1 -1
- truss/truss_handle/patch/__init__.py +0 -0
- truss/{patch → truss_handle/patch}/calc_patch.py +146 -92
- truss/{types.py → truss_handle/patch/custom_types.py} +35 -27
- truss/{patch → truss_handle/patch}/dir_signature.py +1 -1
- truss/truss_handle/patch/hash.py +71 -0
- truss/{patch → truss_handle/patch}/local_truss_patch_applier.py +6 -4
- truss/truss_handle/patch/signature.py +22 -0
- truss/truss_handle/patch/truss_dir_patch_applier.py +87 -0
- truss/{readme_generator.py → truss_handle/readme_generator.py} +3 -2
- truss/{truss_gatherer.py → truss_handle/truss_gatherer.py} +3 -2
- truss/{truss_handle.py → truss_handle/truss_handle.py} +174 -78
- truss/util/.truss_ignore +3 -0
- truss/{docker.py → util/docker.py} +6 -2
- truss/util/download.py +6 -15
- truss/util/env_vars.py +41 -0
- truss/util/log_utils.py +52 -0
- truss/util/path.py +20 -20
- truss/util/requirements.py +11 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/METADATA +18 -16
- truss-0.60.0.dist-info/RECORD +324 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/WHEEL +1 -1
- truss-0.60.0.dist-info/entry_points.txt +4 -0
- truss_chains/__init__.py +71 -0
- truss_chains/definitions.py +756 -0
- truss_chains/deployment/__init__.py +0 -0
- truss_chains/deployment/code_gen.py +816 -0
- truss_chains/deployment/deployment_client.py +871 -0
- truss_chains/framework.py +1480 -0
- truss_chains/public_api.py +231 -0
- truss_chains/py.typed +0 -0
- truss_chains/pydantic_numpy.py +131 -0
- truss_chains/reference_code/reference_chainlet.py +34 -0
- truss_chains/reference_code/reference_model.py +10 -0
- truss_chains/remote_chainlet/__init__.py +0 -0
- truss_chains/remote_chainlet/model_skeleton.py +60 -0
- truss_chains/remote_chainlet/stub.py +380 -0
- truss_chains/remote_chainlet/utils.py +332 -0
- truss_chains/streaming.py +378 -0
- truss_chains/utils.py +178 -0
- CODE_OF_CONDUCT.md +0 -131
- CONTRIBUTING.md +0 -48
- README.md +0 -137
- context_builder.Dockerfile +0 -24
- truss/blob/blob_backend.py +0 -10
- truss/blob/blob_backend_registry.py +0 -23
- truss/blob/http_public_blob_backend.py +0 -23
- truss/build/__init__.py +0 -2
- truss/build/build.py +0 -143
- truss/build/configure.py +0 -63
- truss/cli/__init__.py +0 -2
- truss/cli/console.py +0 -5
- truss/cli/create.py +0 -5
- truss/config/trt_llm.py +0 -81
- truss/constants.py +0 -61
- truss/model_inference.py +0 -123
- truss/patch/types.py +0 -30
- truss/pytest.ini +0 -7
- truss/server/common/errors.py +0 -100
- truss/server/common/termination_handler_middleware.py +0 -64
- truss/server/common/truss_server.py +0 -389
- truss/server/control/patch/model_code_patch_applier.py +0 -46
- truss/server/control/patch/requirement_name_identifier.py +0 -17
- truss/server/inference_server.py +0 -29
- truss/server/model_wrapper.py +0 -434
- truss/server/shared/logging.py +0 -81
- truss/templates/trtllm/model/model.py +0 -97
- truss/templates/trtllm/packages/build_engine_utils.py +0 -34
- truss/templates/trtllm/packages/constants.py +0 -11
- truss/templates/trtllm/packages/schema.py +0 -216
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/ensemble/config.pbtxt +0 -246
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/1/model.py +0 -181
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/config.pbtxt +0 -64
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/1/model.py +0 -260
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/config.pbtxt +0 -99
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/tensorrt_llm/config.pbtxt +0 -208
- truss/templates/trtllm/packages/triton_client.py +0 -150
- truss/templates/trtllm/packages/utils.py +0 -43
- truss/test_data/context_builder_image_test/test.py +0 -4
- truss/test_data/happy.ipynb +0 -54
- truss/test_data/model_load_failure_test/config.yaml +0 -2
- truss/test_data/test_concurrency_truss/config.yaml +0 -2
- truss/test_data/test_streaming_async_generator_truss/config.yaml +0 -2
- truss/test_data/test_streaming_truss/config.yaml +0 -3
- truss/test_data/test_truss/config.yaml +0 -2
- truss/tests/server/common/test_termination_handler_middleware.py +0 -93
- truss/tests/server/control/test_model_container_patch_applier.py +0 -203
- truss/tests/server/core/server/common/test_util.py +0 -19
- truss/tests/server/test_model_wrapper.py +0 -87
- truss/util/data_structures.py +0 -16
- truss-0.10.0rc1.dist-info/RECORD +0 -216
- truss-0.10.0rc1.dist-info/entry_points.txt +0 -3
- truss/{server/shared → base}/__init__.py +0 -0
- truss/{server → templates/control}/control/helpers/context_managers.py +0 -0
- truss/{server/control → templates/control/control/helpers}/errors.py +0 -0
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/__init__.py +0 -0
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/system_packages.py +0 -0
- truss/{test_data/annotated_types_truss/model → templates/server}/__init__.py +0 -0
- truss/{server → templates/server}/common/__init__.py +0 -0
- truss/{test_data/gcs_fix/model → templates/shared}/__init__.py +0 -0
- truss/templates/{trtllm → trtllm-briton}/README.md +0 -0
- truss/{test_data/server_conformance_test_truss/model → tests/test_data}/__init__.py +0 -0
- truss/{test_data/test_basic_truss/model → tests/test_data/annotated_types_truss}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/annotated_types_truss/config.yaml +0 -0
- truss/{test_data/test_requirements_file_truss → tests/test_data/annotated_types_truss}/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/annotated_types_truss/model/model.py +0 -0
- truss/{test_data → tests/test_data}/auto-mpg.data +0 -0
- truss/{test_data → tests/test_data}/context_builder_image_test/Dockerfile +0 -0
- truss/{test_data/test_truss/model → tests/test_data/context_builder_image_test}/__init__.py +0 -0
- truss/{test_data/test_truss_server_caching_truss/model → tests/test_data/gcs_fix}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/gcs_fix/config.yaml +0 -0
- truss/tests/{local → test_data/gcs_fix/model}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/gcs_fix/model/model.py +0 -0
- truss/{test_data/test_truss/model/dummy → tests/test_data/model_load_failure_test/__init__.py} +0 -0
- truss/{test_data → tests/test_data}/model_load_failure_test/model/model.py +0 -0
- truss/{test_data → tests/test_data}/pima-indians-diabetes.csv +0 -0
- truss/{test_data → tests/test_data}/readme_int_example.md +0 -0
- truss/{test_data → tests/test_data}/readme_no_example.md +0 -0
- truss/{test_data → tests/test_data}/readme_str_example.md +0 -0
- truss/{test_data → tests/test_data}/server_conformance_test_truss/config.yaml +0 -0
- truss/{test_data → tests/test_data}/test_async_truss/config.yaml +0 -0
- truss/{test_data → tests/test_data}/test_async_truss/model/model.py +3 -3
- /truss/{test_data → tests/test_data}/test_basic_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_concurrency_truss/model/model.py +0 -0
- /truss/{test_data/test_requirements_file_truss → tests/test_data/test_pyantic_v1}/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_requirements_file_truss/requirements.txt +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_read_timeout/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_read_timeout/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_truss_with_error/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss/examples.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_truss/packages/test_package/test.py +0 -0
- /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/model/model.py +0 -0
- /truss/{patch → truss_handle/patch}/constants.py +0 -0
- /truss/{notebook.py → util/notebook.py} +0 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/LICENSE +0 -0
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import json
|
|
3
|
-
import logging
|
|
4
|
-
import multiprocessing
|
|
5
|
-
import os
|
|
6
|
-
import signal
|
|
7
|
-
import socket
|
|
8
|
-
import sys
|
|
9
|
-
import time
|
|
10
|
-
from collections.abc import Generator
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
from typing import AsyncGenerator, Dict, List, Optional, Union
|
|
13
|
-
|
|
14
|
-
import truss.server.common.errors as errors
|
|
15
|
-
import truss.server.shared.util as utils
|
|
16
|
-
import uvicorn
|
|
17
|
-
from fastapi import Depends, FastAPI, HTTPException, Request
|
|
18
|
-
from fastapi.responses import ORJSONResponse, StreamingResponse
|
|
19
|
-
from fastapi.routing import APIRoute as FastAPIRoute
|
|
20
|
-
from starlette.middleware.base import BaseHTTPMiddleware
|
|
21
|
-
from starlette.requests import ClientDisconnect
|
|
22
|
-
from starlette.responses import Response
|
|
23
|
-
from truss.server.common.termination_handler_middleware import (
|
|
24
|
-
TerminationHandlerMiddleware,
|
|
25
|
-
)
|
|
26
|
-
from truss.server.model_wrapper import ModelWrapper
|
|
27
|
-
from truss.server.shared.logging import setup_logging
|
|
28
|
-
from truss.server.shared.serialization import (
|
|
29
|
-
DeepNumpyEncoder,
|
|
30
|
-
truss_msgpack_deserialize,
|
|
31
|
-
truss_msgpack_serialize,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# [IMPORTANT] A lot of things depend on this currently.
|
|
35
|
-
# Please consider the following when increasing this:
|
|
36
|
-
# 1. Self-termination on model load fail.
|
|
37
|
-
# 2. Graceful termination.
|
|
38
|
-
DEFAULT_NUM_WORKERS = 1
|
|
39
|
-
DEFAULT_NUM_SERVER_PROCESSES = 1
|
|
40
|
-
WORKER_TERMINATION_TIMEOUT_SECS = 120.0
|
|
41
|
-
WORKER_TERMINATION_CHECK_INTERVAL_SECS = 0.5
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
async def parse_body(request: Request) -> bytes:
|
|
45
|
-
"""
|
|
46
|
-
Used by FastAPI to read body in an asynchronous manner
|
|
47
|
-
"""
|
|
48
|
-
try:
|
|
49
|
-
return await request.body()
|
|
50
|
-
except ClientDisconnect as exc:
|
|
51
|
-
error_message = "Client disconnected"
|
|
52
|
-
logging.error(error_message)
|
|
53
|
-
raise HTTPException(status_code=499, detail=error_message) from exc
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
FORMAT = "%(asctime)s.%(msecs)03d %(name)s %(levelname)s [%(funcName)s():%(lineno)s] %(message)s"
|
|
57
|
-
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
58
|
-
INFERENCE_SERVER_FAILED_FILE = Path("~/inference_server_crashed.txt").expanduser()
|
|
59
|
-
logging.basicConfig(level=logging.INFO, format=FORMAT, datefmt=DATE_FORMAT)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class UvicornCustomServer(multiprocessing.Process):
|
|
63
|
-
def __init__(
|
|
64
|
-
self, config: uvicorn.Config, sockets: Optional[List[socket.socket]] = None
|
|
65
|
-
):
|
|
66
|
-
super().__init__()
|
|
67
|
-
self.sockets = sockets
|
|
68
|
-
self.config = config
|
|
69
|
-
|
|
70
|
-
def stop(self):
|
|
71
|
-
self.terminate()
|
|
72
|
-
|
|
73
|
-
def run(self):
|
|
74
|
-
server = uvicorn.Server(config=self.config)
|
|
75
|
-
asyncio.run(server.serve(sockets=self.sockets))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class BasetenEndpoints:
|
|
79
|
-
"""The implementation of the model server endpoints.
|
|
80
|
-
|
|
81
|
-
Historically, we relied on the kserve server interface, which assumes that
|
|
82
|
-
multiple models are running behind a registry. As a result, some arguments to
|
|
83
|
-
to functions will rename unused except for backwards compatibility checks.
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
def __init__(self, model: ModelWrapper) -> None:
|
|
87
|
-
self._model = model
|
|
88
|
-
|
|
89
|
-
def _safe_lookup_model(self, model_name: str) -> ModelWrapper:
|
|
90
|
-
if model_name != self._model.name:
|
|
91
|
-
raise errors.ModelMissingError(model_name)
|
|
92
|
-
return self._model
|
|
93
|
-
|
|
94
|
-
@staticmethod
|
|
95
|
-
def check_healthy(model: ModelWrapper):
|
|
96
|
-
if model.load_failed():
|
|
97
|
-
INFERENCE_SERVER_FAILED_FILE.touch()
|
|
98
|
-
os.kill(os.getpid(), signal.SIGKILL)
|
|
99
|
-
|
|
100
|
-
if not model.ready:
|
|
101
|
-
raise errors.ModelNotReady(model.name)
|
|
102
|
-
|
|
103
|
-
async def model_ready(self, model_name: str) -> Dict[str, Union[str, bool]]:
|
|
104
|
-
self.check_healthy(self._safe_lookup_model(model_name))
|
|
105
|
-
|
|
106
|
-
return {}
|
|
107
|
-
|
|
108
|
-
async def invocations_ready(self) -> Dict[str, Union[str, bool]]:
|
|
109
|
-
"""
|
|
110
|
-
This method provides compatibility with Sagemaker hosting for the 'ping' endpoint.
|
|
111
|
-
"""
|
|
112
|
-
if self._model is None:
|
|
113
|
-
raise errors.ModelMissingError("model")
|
|
114
|
-
self.check_healthy(self._model)
|
|
115
|
-
|
|
116
|
-
return {}
|
|
117
|
-
|
|
118
|
-
async def invocations(
|
|
119
|
-
self, request: Request, body_raw: bytes = Depends(parse_body)
|
|
120
|
-
) -> Response:
|
|
121
|
-
"""
|
|
122
|
-
This method provides compatibility with Sagemaker hosting for the 'invocations' endpoint.
|
|
123
|
-
"""
|
|
124
|
-
return await self.predict(self._model.name, request, body_raw)
|
|
125
|
-
|
|
126
|
-
async def predict(
|
|
127
|
-
self, model_name: str, request: Request, body_raw: bytes = Depends(parse_body)
|
|
128
|
-
) -> Response:
|
|
129
|
-
"""
|
|
130
|
-
This method calls the user-provided predict method
|
|
131
|
-
"""
|
|
132
|
-
model: ModelWrapper = self._safe_lookup_model(model_name)
|
|
133
|
-
|
|
134
|
-
self.check_healthy(model)
|
|
135
|
-
|
|
136
|
-
body: Dict
|
|
137
|
-
if self.is_binary(request):
|
|
138
|
-
body = truss_msgpack_deserialize(body_raw)
|
|
139
|
-
else:
|
|
140
|
-
try:
|
|
141
|
-
body = json.loads(body_raw)
|
|
142
|
-
except json.JSONDecodeError as e:
|
|
143
|
-
error_message = f"Invalid JSON payload: {str(e)}"
|
|
144
|
-
logging.error(error_message)
|
|
145
|
-
raise HTTPException(status_code=400, detail=error_message)
|
|
146
|
-
|
|
147
|
-
# calls ModelWrapper.__call__, which runs validate, preprocess, predict, and postprocess
|
|
148
|
-
response: Union[Dict, Generator] = await model(
|
|
149
|
-
body,
|
|
150
|
-
headers=utils.transform_keys(request.headers, lambda key: key.lower()),
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
# In the case that the model returns a Generator object, return a
|
|
154
|
-
# StreamingResponse instead.
|
|
155
|
-
if isinstance(response, (AsyncGenerator, Generator)):
|
|
156
|
-
# media_type in StreamingResponse sets the Content-Type header
|
|
157
|
-
return StreamingResponse(response, media_type="application/octet-stream")
|
|
158
|
-
|
|
159
|
-
response_headers = {}
|
|
160
|
-
if self.is_binary(request):
|
|
161
|
-
response_headers["Content-Type"] = "application/octet-stream"
|
|
162
|
-
return Response(
|
|
163
|
-
content=truss_msgpack_serialize(response), headers=response_headers
|
|
164
|
-
)
|
|
165
|
-
else:
|
|
166
|
-
response_headers["Content-Type"] = "application/json"
|
|
167
|
-
return Response(
|
|
168
|
-
content=json.dumps(response, cls=DeepNumpyEncoder),
|
|
169
|
-
headers=response_headers,
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
async def schema(self, model_name: str) -> Dict:
|
|
173
|
-
model: ModelWrapper = self._safe_lookup_model(model_name)
|
|
174
|
-
|
|
175
|
-
if model.truss_schema is None:
|
|
176
|
-
print("DID NOT FIND MODEL SCHEMA")
|
|
177
|
-
# If there is not a TrussSchema, we return a 404.
|
|
178
|
-
|
|
179
|
-
if model.ready:
|
|
180
|
-
raise HTTPException(status_code=404, detail="No schema found")
|
|
181
|
-
else:
|
|
182
|
-
raise HTTPException(
|
|
183
|
-
status_code=503,
|
|
184
|
-
detail="Schema not available, please try again later.",
|
|
185
|
-
)
|
|
186
|
-
else:
|
|
187
|
-
return model.truss_schema.serialize()
|
|
188
|
-
|
|
189
|
-
@staticmethod
|
|
190
|
-
def is_binary(request: Request):
|
|
191
|
-
return (
|
|
192
|
-
"Content-Type" in request.headers
|
|
193
|
-
and request.headers["Content-Type"] == "application/octet-stream"
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
class TrussServer:
|
|
198
|
-
"""This wrapper class manages creation and cleanup of uvicorn server processes running the FastAPI inference server app
|
|
199
|
-
|
|
200
|
-
TrussServer runs as a main process managing UvicornCustomServer subprocesses that in turn may manage
|
|
201
|
-
their own worker processes. Notably, this main process is kept alive when running `servers_task()`
|
|
202
|
-
because of the child uvicorn server processes' main loop.
|
|
203
|
-
|
|
204
|
-
"""
|
|
205
|
-
|
|
206
|
-
def __init__(
|
|
207
|
-
self,
|
|
208
|
-
http_port: int,
|
|
209
|
-
config: Dict,
|
|
210
|
-
setup_json_logger: bool = True,
|
|
211
|
-
):
|
|
212
|
-
self.http_port = http_port
|
|
213
|
-
self._config = config
|
|
214
|
-
self._model = ModelWrapper(self._config)
|
|
215
|
-
self._endpoints = BasetenEndpoints(self._model)
|
|
216
|
-
self._setup_json_logger = setup_json_logger
|
|
217
|
-
|
|
218
|
-
def cleanup(self):
|
|
219
|
-
if INFERENCE_SERVER_FAILED_FILE.exists():
|
|
220
|
-
INFERENCE_SERVER_FAILED_FILE.unlink()
|
|
221
|
-
|
|
222
|
-
def on_startup(self):
|
|
223
|
-
"""
|
|
224
|
-
This method will be started inside the main process, so here is where we want to setup our logging and model
|
|
225
|
-
"""
|
|
226
|
-
self.cleanup()
|
|
227
|
-
|
|
228
|
-
if self._setup_json_logger:
|
|
229
|
-
setup_logging()
|
|
230
|
-
|
|
231
|
-
self._model.start_load()
|
|
232
|
-
|
|
233
|
-
def create_application(self):
|
|
234
|
-
app = FastAPI(
|
|
235
|
-
title="Baseten Inference Server",
|
|
236
|
-
docs_url=None,
|
|
237
|
-
redoc_url=None,
|
|
238
|
-
default_response_class=ORJSONResponse,
|
|
239
|
-
on_startup=[self.on_startup],
|
|
240
|
-
routes=[
|
|
241
|
-
# liveness endpoint
|
|
242
|
-
FastAPIRoute(r"/", lambda: True),
|
|
243
|
-
# readiness endpoint
|
|
244
|
-
FastAPIRoute(
|
|
245
|
-
r"/v1/models/{model_name}", self._endpoints.model_ready, tags=["V1"]
|
|
246
|
-
),
|
|
247
|
-
FastAPIRoute(
|
|
248
|
-
r"/v1/models/{model_name}/schema",
|
|
249
|
-
self._endpoints.schema,
|
|
250
|
-
methods=["GET"],
|
|
251
|
-
tags=["V1"],
|
|
252
|
-
),
|
|
253
|
-
FastAPIRoute(
|
|
254
|
-
r"/v1/models/{model_name}:predict",
|
|
255
|
-
self._endpoints.predict,
|
|
256
|
-
methods=["POST"],
|
|
257
|
-
tags=["V1"],
|
|
258
|
-
),
|
|
259
|
-
FastAPIRoute(
|
|
260
|
-
r"/v1/models/{model_name}:predict_binary",
|
|
261
|
-
self._endpoints.predict,
|
|
262
|
-
methods=["POST"],
|
|
263
|
-
tags=["V1"],
|
|
264
|
-
),
|
|
265
|
-
# Endpoint aliases for Sagemaker hosting
|
|
266
|
-
FastAPIRoute(r"/ping", self._endpoints.invocations_ready),
|
|
267
|
-
FastAPIRoute(
|
|
268
|
-
r"/invocations",
|
|
269
|
-
self._endpoints.invocations,
|
|
270
|
-
methods=["POST"],
|
|
271
|
-
),
|
|
272
|
-
],
|
|
273
|
-
exception_handlers={
|
|
274
|
-
errors.InferenceError: errors.inference_error_handler,
|
|
275
|
-
errors.ModelNotFound: errors.model_not_found_handler,
|
|
276
|
-
errors.ModelNotReady: errors.model_not_ready_handler,
|
|
277
|
-
NotImplementedError: errors.not_implemented_error_handler,
|
|
278
|
-
HTTPException: errors.http_exception_handler,
|
|
279
|
-
Exception: errors.generic_exception_handler,
|
|
280
|
-
},
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
def exit_self():
|
|
284
|
-
# Note that this kills the current process, the worker process, not
|
|
285
|
-
# the main truss_server process.
|
|
286
|
-
utils.kill_child_processes(os.getpid())
|
|
287
|
-
sys.exit()
|
|
288
|
-
|
|
289
|
-
termination_handler_middleware = TerminationHandlerMiddleware(
|
|
290
|
-
on_stop=lambda: None,
|
|
291
|
-
on_term=exit_self,
|
|
292
|
-
)
|
|
293
|
-
app.add_middleware(BaseHTTPMiddleware, dispatch=termination_handler_middleware)
|
|
294
|
-
return app
|
|
295
|
-
|
|
296
|
-
def start(self):
|
|
297
|
-
cfg = uvicorn.Config(
|
|
298
|
-
self.create_application(),
|
|
299
|
-
# We hard-code the http parser as h11 (the default) in case the user has
|
|
300
|
-
# httptools installed, which does not work with our requests & version
|
|
301
|
-
# of uvicorn.
|
|
302
|
-
http="h11",
|
|
303
|
-
host="0.0.0.0",
|
|
304
|
-
port=self.http_port,
|
|
305
|
-
workers=DEFAULT_NUM_WORKERS,
|
|
306
|
-
log_config={
|
|
307
|
-
"version": 1,
|
|
308
|
-
"formatters": {
|
|
309
|
-
"default": {
|
|
310
|
-
"()": "uvicorn.logging.DefaultFormatter",
|
|
311
|
-
"datefmt": DATE_FORMAT,
|
|
312
|
-
"fmt": "%(asctime)s.%(msecs)03d %(name)s %(levelprefix)s %(message)s",
|
|
313
|
-
"use_colors": None,
|
|
314
|
-
},
|
|
315
|
-
"access": {
|
|
316
|
-
"()": "uvicorn.logging.AccessFormatter",
|
|
317
|
-
"datefmt": DATE_FORMAT,
|
|
318
|
-
"fmt": "%(asctime)s.%(msecs)03d %(name)s %(levelprefix)s %(client_addr)s %(process)s - "
|
|
319
|
-
'"%(request_line)s" %(status_code)s',
|
|
320
|
-
# noqa: E501
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
"handlers": {
|
|
324
|
-
"default": {
|
|
325
|
-
"formatter": "default",
|
|
326
|
-
"class": "logging.StreamHandler",
|
|
327
|
-
"stream": "ext://sys.stderr",
|
|
328
|
-
},
|
|
329
|
-
"access": {
|
|
330
|
-
"formatter": "access",
|
|
331
|
-
"class": "logging.StreamHandler",
|
|
332
|
-
"stream": "ext://sys.stdout",
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
"loggers": {
|
|
336
|
-
"uvicorn": {"handlers": ["default"], "level": "INFO"},
|
|
337
|
-
"uvicorn.error": {"level": "INFO"},
|
|
338
|
-
"uvicorn.access": {
|
|
339
|
-
"handlers": ["access"],
|
|
340
|
-
"level": "INFO",
|
|
341
|
-
"propagate": False,
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
# Call this so uvloop gets used
|
|
348
|
-
cfg.setup_event_loop()
|
|
349
|
-
|
|
350
|
-
async def serve():
|
|
351
|
-
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
352
|
-
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
353
|
-
serversocket.bind((cfg.host, cfg.port))
|
|
354
|
-
serversocket.listen(5)
|
|
355
|
-
|
|
356
|
-
num_server_procs = self._config.get("runtime", {}).get(
|
|
357
|
-
"num_workers", DEFAULT_NUM_SERVER_PROCESSES
|
|
358
|
-
)
|
|
359
|
-
logging.info(f"starting {num_server_procs} uvicorn server processes")
|
|
360
|
-
servers: List[UvicornCustomServer] = []
|
|
361
|
-
for _ in range(num_server_procs):
|
|
362
|
-
server = UvicornCustomServer(config=cfg, sockets=[serversocket])
|
|
363
|
-
server.start()
|
|
364
|
-
servers.append(server)
|
|
365
|
-
|
|
366
|
-
def stop_servers():
|
|
367
|
-
# Send stop signal, then wait for all to exit
|
|
368
|
-
for server in servers:
|
|
369
|
-
# Sends term signal to the process, which should be handled
|
|
370
|
-
# by the termination handler.
|
|
371
|
-
server.stop()
|
|
372
|
-
|
|
373
|
-
termination_check_attempts = int(
|
|
374
|
-
WORKER_TERMINATION_TIMEOUT_SECS
|
|
375
|
-
/ WORKER_TERMINATION_CHECK_INTERVAL_SECS
|
|
376
|
-
)
|
|
377
|
-
for _ in range(termination_check_attempts):
|
|
378
|
-
time.sleep(WORKER_TERMINATION_CHECK_INTERVAL_SECS)
|
|
379
|
-
if utils.all_processes_dead(servers):
|
|
380
|
-
return
|
|
381
|
-
|
|
382
|
-
for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGQUIT]:
|
|
383
|
-
signal.signal(sig, lambda sig, frame: stop_servers())
|
|
384
|
-
|
|
385
|
-
async def servers_task():
|
|
386
|
-
servers = [serve()]
|
|
387
|
-
await asyncio.gather(*servers)
|
|
388
|
-
|
|
389
|
-
asyncio.run(servers_task())
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Union
|
|
5
|
-
|
|
6
|
-
from truss.server.control.patch.types import Action, ModelCodePatch, PackagePatch
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def apply_code_patch(
|
|
10
|
-
relative_dir: Path,
|
|
11
|
-
patch: Union[ModelCodePatch, PackagePatch],
|
|
12
|
-
logger: logging.Logger,
|
|
13
|
-
):
|
|
14
|
-
logger.debug(f"Applying code patch {patch.to_dict()}")
|
|
15
|
-
filepath: Path = relative_dir / patch.path
|
|
16
|
-
action = patch.action
|
|
17
|
-
|
|
18
|
-
if action in [Action.ADD, Action.UPDATE]:
|
|
19
|
-
filepath.parent.mkdir(parents=True, exist_ok=True)
|
|
20
|
-
action_log = "Adding" if action == Action.ADD else "Updating"
|
|
21
|
-
logger.info(f"{action_log} file {filepath}")
|
|
22
|
-
with filepath.open("w") as file:
|
|
23
|
-
content = patch.content
|
|
24
|
-
if content is None:
|
|
25
|
-
raise ValueError(
|
|
26
|
-
"Invalid patch: content of a file update patch should not be None."
|
|
27
|
-
)
|
|
28
|
-
file.write(content)
|
|
29
|
-
|
|
30
|
-
elif action == Action.REMOVE:
|
|
31
|
-
if not filepath.exists():
|
|
32
|
-
logger.warning(f"Could not delete file {filepath}: not found.")
|
|
33
|
-
elif filepath.is_file():
|
|
34
|
-
logger.info(f"Deleting file {filepath}")
|
|
35
|
-
filepath.unlink()
|
|
36
|
-
# attempt to recursively remove potentially empty directories, if applicable
|
|
37
|
-
# os.removedirs raises OSError with errno 39 when this process encounters a non-empty dir
|
|
38
|
-
try:
|
|
39
|
-
os.removedirs(filepath.parent)
|
|
40
|
-
except OSError as e:
|
|
41
|
-
if e.errno == 39: # Directory not empty
|
|
42
|
-
pass
|
|
43
|
-
else:
|
|
44
|
-
raise
|
|
45
|
-
else:
|
|
46
|
-
raise ValueError(f"Unknown patch action {action}")
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from typing import Dict, List
|
|
2
|
-
|
|
3
|
-
import pkg_resources
|
|
4
|
-
from pkg_resources.extern.packaging import requirements # type: ignore
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def identify_requirement_name(req: str) -> str:
|
|
8
|
-
try:
|
|
9
|
-
parsed_req = pkg_resources.Requirement.parse(req)
|
|
10
|
-
return parsed_req.name # type: ignore
|
|
11
|
-
except (requirements.InvalidRequirement, ValueError):
|
|
12
|
-
# default to the whole line if we can't parse it.
|
|
13
|
-
return req.strip()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def reqs_by_name(reqs: List[str]) -> Dict[str, str]:
|
|
17
|
-
return {identify_requirement_name(req): req for req in reqs}
|
truss/server/inference_server.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import Dict
|
|
4
|
-
|
|
5
|
-
from truss.server.common.truss_server import TrussServer
|
|
6
|
-
from truss.server.shared.logging import setup_logging
|
|
7
|
-
from truss.truss_config import TrussConfig
|
|
8
|
-
|
|
9
|
-
CONFIG_FILE = "config.yaml"
|
|
10
|
-
|
|
11
|
-
setup_logging()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class ConfiguredTrussServer:
|
|
15
|
-
_config: Dict
|
|
16
|
-
_port: int
|
|
17
|
-
|
|
18
|
-
def __init__(self, config_path: str, port: int):
|
|
19
|
-
self._port = port
|
|
20
|
-
self._config = TrussConfig.from_yaml(Path(config_path)).to_dict(verbose=True)
|
|
21
|
-
|
|
22
|
-
def start(self):
|
|
23
|
-
server = TrussServer(http_port=self._port, config=self._config)
|
|
24
|
-
server.start()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if __name__ == "__main__":
|
|
28
|
-
env_port = int(os.environ.get("INFERENCE_SERVER_PORT", "8080"))
|
|
29
|
-
ConfiguredTrussServer(CONFIG_FILE, env_port).start()
|