Skip to content

Commit 45d94b7

Browse files
authored
Merge pull request #118 from chen3933/main
Add warning message to log this error.
2 parents d7821e6 + be43bdb commit 45d94b7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/sagemaker_huggingface_inference_toolkit/handler_service.py

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self):
6060
self.model = None
6161
self.device = -1
6262
self.initialized = False
63+
self.attempted_init = False
6364
self.context = None
6465
self.manifest = None
6566
self.environment = environment.Environment()
@@ -75,6 +76,7 @@ def initialize(self, context):
7576
:param context: Initial context contains model server system properties.
7677
:return:
7778
"""
79+
self.attempted_init = True
7880
self.context = context
7981
properties = context.system_properties
8082
self.model_dir = properties.get("model_dir")
@@ -245,6 +247,11 @@ def handle(self, data, context):
245247
"""
246248
try:
247249
if not self.initialized:
250+
if self.attempted_init:
251+
logger.warn(
252+
"Model is not initialized, will try to load model again.\n"
253+
"Please consider increase wait time for model loading.\n"
254+
)
248255
self.initialize(context)
249256

250257
input_data = data[0].get("body")

0 commit comments

Comments
 (0)