Skip to content

Commit bfc6866

Browse files
committed
add better logging
1 parent ab21c2b commit bfc6866

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/autogluon/cloud/scripts/sagemaker_scripts/tabular_serve.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from autogluon.tabular import TabularPredictor
1717

1818
image_dir = os.path.join("/tmp", "ag_images")
19+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
20+
logger = logging.getLogger(__name__)
1921

2022

2123
def _save_image_and_update_dataframe_column(bytes):
@@ -34,9 +36,14 @@ def _save_image_and_update_dataframe_column(bytes):
3436

3537
def model_fn(model_dir):
3638
"""loads model from previously saved artifact"""
37-
model = TabularPredictor.load(model_dir)
38-
model.persist_models()
39-
globals()["column_names"] = model.original_features
39+
logger.info("Loading the model")
40+
try:
41+
model = TabularPredictor.load(model_dir)
42+
model.persist_models()
43+
globals()["column_names"] = model.original_features
44+
except Exception as e:
45+
logger.error(f"Error loading the model: {str(e)}")
46+
raise e
4047

4148
return model
4249

0 commit comments

Comments
 (0)