Skip to content

fix(serve): resolve Triton model.py and pack_conda_env.sh from model_server/triton - #6413

Open
AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/triton-asset-paths
Open

AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/triton-asset-paths

Conversation

@AkshayShah03

Copy link
Copy Markdown

Issue #, if available: N/A

Description of changes:

When the Triton build code moved from model_server/triton/triton_builder.py into model_builder_utils.py, two Path(__file__).parent lookups weren't updated:

triton_model_path = Path(__file__).parent.joinpath("model.py")        # -> sagemaker/serve/model.py
script_path = Path(__file__).parent.joinpath("pack_conda_env.sh")     # -> sagemaker/serve/pack_conda_env.sh

Neither file exists in sagemaker/serve/; both live in sagemaker/serve/model_server/triton/. So ModelBuilder(model_server=ModelServer.TRITON, inference_spec=...) fails with FileNotFoundError when it copies model.py, and the conda-env pack script isn't found either.

Fixing the paths alone isn't enough. pack_conda_env.sh isn't in the published sagemaker-serve wheel: 1.24.0 ships only schema/task.json as package data. This change also adds model_server/triton/*.sh to [tool.setuptools.package-data].

Testing:

  • test_prepare_for_triton_inference_spec_copies_triton_model_py and test_pack_conda_env_runs_triton_pack_script check that the resolved files exist. The existing tests mock shutil.copy2 and _pack_conda_env, which hid this. Both new tests fail before this change.
  • tests/unit/test_model_builder_utils_triton.py: 29 passed.
  • A wheel built with uv build --wheel sagemaker-serve now contains sagemaker/serve/model_server/triton/pack_conda_env.sh.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…server/triton

When this code moved from model_server/triton/triton_builder.py into
model_builder_utils.py, the Path(__file__).parent lookups for the Triton
python-backend model.py and pack_conda_env.sh were not updated. They now
resolve to sagemaker/serve/model.py and sagemaker/serve/pack_conda_env.sh,
which do not exist, so building a Triton model with an inference_spec failed
with FileNotFoundError when copying model.py (and the conda env pack script
would not be found either).

Point both lookups at model_server/triton, and add the .sh script to the
package data: it is currently not included in the published sagemaker-serve
wheel (1.24.0), so the path fix alone would not help installed users.

This branch had an error being deployed

1 failed deployment
manual-approval — 065af8a9 Deployed Oct 9, 2026 by AkshayShah03 via wait-for-approval #595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant