Update build code and notebook to support the breaking changes coming in v2.0 of SageMaker Python SDK
Image URI Functions (e.g. get_image_uri)
try:
# Support SageMaker 2 SDK: https://sagemaker.readthedocs.io/en/stable/v2.html
def get_training_image(region=None):
region = region or boto3.Session().region_name
return sagemaker.image_uris.retrieve(region=region,
framework='xgboost', version="1.0-1")
except:
from sagemaker.amazon.amazon_estimator import get_image_uri
def get_training_image(region=None):
region = region or boto3.Session().region_name
return get_image_uri(region, "xgboost", "1.0-1")
XGBoost Predictor
try:
# Support SageMaker 2 SDK: https://sagemaker.readthedocs.io/en/stable/v2.html
from sagemaker.predictor import Predictor
from sagemaker.serializers import CSVSerializer
def get_predictor(endpoint_name):
xgb_predictor = Predictor(endpoint_name)
xgb_predictor.serializer = CSVSerializer()
return xgb_predictor
except Exception as e:
from sagemaker.predictor import RealTimePredictor, csv_serializer
def get_predictor(endpoint_name):
xgb_predictor = RealTimePredictor(endpoint_name)
xgb_predictor.content_type = 'text/csv'
xgb_predictor.serializer = csv_serializer
return xgb_predictor
Update build code and notebook to support the breaking changes coming in v2.0 of SageMaker Python SDK
Image URI Functions (e.g. get_image_uri)
XGBoost Predictor