Skip to content

Commit

Permalink
fix: fix loading user custom script
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperBo authored and Y Nguyen committed Aug 30, 2022
1 parent 0cc05b2 commit b26d2f2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/sagemaker_inference/default_handler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""This module contains functionality for the default handler service."""
from __future__ import absolute_import

import os
import sys

from sagemaker_inference.transformer import Transformer

Expand Down Expand Up @@ -57,10 +57,7 @@ def initialize(self, context):
model_dir = properties.get("model_dir")

# add model_dir/code to python path
code_dir_path = "{}:".format(model_dir + "/code")
if PYTHON_PATH_ENV in os.environ:
os.environ[PYTHON_PATH_ENV] = code_dir_path + os.environ[PYTHON_PATH_ENV]
else:
os.environ[PYTHON_PATH_ENV] = code_dir_path
code_dir_path = model_dir + "/code"
sys.path.insert(1, code_dir_path)

self._service.validate_and_initialize(model_dir=model_dir, context=context)

0 comments on commit b26d2f2

Please sign in to comment.