title: sagemaker inference container ModuleNotFoundError: No module named 'model_handler'
body: <p>I am trying to deploy a model using my own custom inference container on sagemaker. I am following the documentation here <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/adapt-inference-container.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/sagemaker/latest/dg/adapt-inference-container.html</a></p>
  <p>I have an entrypoint file:</p>
  <pre><code>from sagemaker_inference import model_server
  #HANDLER_SERVICE = &quot;/home/model-server/model_handler.py:handle&quot;
  HANDLER_SERVICE = &quot;model_handler.py&quot;
  model_server.start_model_server(handler_service=HANDLER_SERVICE)
  </code></pre>
  <p>I have a model_handler.py file:</p>
  <pre><code>from sagemaker_inference.default_handler_service import DefaultHandlerService
  from sagemaker_inference.transformer import Transformer
  from CustomHandler import CustomHandler
  
  
  class ModelHandler(DefaultHandlerService):
      def __init__(self):
          transformer = Transformer(default_inference_handler=CustomHandler())
          super(HandlerService, self).__init__(transformer=transformer)
  </code></pre>
  <p>And I have my CustomHandler.py file:</p>
  <pre><code>import os
  import json
  import pandas as pd
  from joblib import dump, load
  from sagemaker_inference import default_inference_handler, decoder, encoder, errors, utils, content_types
  
  
  class CustomHandler(default_inference_handler.DefaultInferenceHandler):
  
      def model_fn(self, model_dir: str) -&gt; str:
          clf = load(os.path.join(model_dir, &quot;model.joblib&quot;))
          return clf
  
      def input_fn(self, request_body: str, content_type: str) -&gt; pd.DataFrame:
          if content_type == &quot;application/json&quot;:
              items = json.loads(request_body)
  
              for item in items:
                  processed_item1 = process_item1(items[&quot;item1&quot;])
                  processed_item2 = process_item2(items[&quot;item2])
                  all_item1 += [processed_item1]
                  all_item2 += [processed_item2]
              return pd.DataFrame({&quot;item1&quot;: all_item1, &quot;comments&quot;: all_item2})
  
      def predict_fn(self, input_data, model):
          return model.predict(input_data)
  </code></pre>
  <p>Once I deploy the model to an endpoint with these files in the image, I get the following error: <code>ml.mms.wlm.WorkerLifeCycle - ModuleNotFoundError: No module named 'model_handler'</code>.</p>
  <p>I am really stuck what to do here. I wish there was an example of how to do this in the above way end to end but I don't think there is. Thanks!</p>