sagemaker-inference-toolkit icon indicating copy to clipboard operation
sagemaker-inference-toolkit copied to clipboard

fix: fix loading user custom script

Open SuperBo opened this issue 3 years ago • 4 comments

Issue #86: I think the issue is very well mentioned here https://github.com/aws/sagemaker-inference-toolkit/issues/86 Description of changes:

Change PYTHONPATH environment after loading your python program won't affect the import paths that python will use to import libraries and modules. In order to change the import paths, we need to change "sys.path" variable.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • [x] I have read the CONTRIBUTING doc
  • [x] I used the commit message format described in CONTRIBUTING
  • [ ] I have used the regional endpoint when creating S3 and/or STS clients (if appropriate)
  • [x] I have updated any necessary documentation, including READMEs

Tests

  • [ ] I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • [ ] I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

SuperBo avatar Aug 30 '22 14:08 SuperBo

What is the status of this merge request? I'm experiencing the same issue and found that it was indeed caused by the same line of code. It would be great to have this updated.

Otje89 avatar May 01 '23 11:05 Otje89

I am still experiencing this issue in 2024. Has there been any fix? This looks like a simple solution given this is indeed the issue.

Alex-Wenner-FHR avatar Jan 25 '24 15:01 Alex-Wenner-FHR

Same issue here. When adding sagemaker-inference to my own container, this line: https://github.com/aws/sagemaker-inference-toolkit/blob/f79853d4e307a983ec5d76980be5ed6a9feb8c0e/src/sagemaker_inference/default_handler_service.py#L52 forces all modules that an entrypoint will use to be copied to "/opt/ml/model/code/" and the entrypoint to be placed at the root of "/opt/ml/model/code/". This is not documented in https://github.com/aws/sagemaker-inference-toolkit/tree/master?tab=readme-ov-file#implementation-steps

ViktorMalesevic avatar Mar 21 '24 15:03 ViktorMalesevic