1919import json
2020import os
2121import tempfile
22-
22+ import re
2323from sagemaker .processing import ProcessingInput , ProcessingOutput , Processor
2424from sagemaker import image_uris , s3 , utils
2525
@@ -124,8 +124,9 @@ def __init__(
124124 content_template = None ,
125125 custom_attributes = None ,
126126 accelerator_type = None ,
127+ endpoint_name_prefix = None ,
127128 ):
128- """Initializes a configuration of a model and the endpoint to be created for it.
129+ r """Initializes a configuration of a model and the endpoint to be created for it.
129130
130131 Args:
131132 model_name (str): Model name (as created by 'CreateModel').
@@ -155,12 +156,21 @@ def __init__(
155156 accelerator_type (str): The Elastic Inference accelerator type to deploy to the model
156157 endpoint instance for making inferences to the model, see
157158 https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html.
159+ endpoint_name_prefix (str): The endpoint name prefix of a new endpoint. Must follow
160+ pattern "^[a-zA-Z0-9](-\*[a-zA-Z0-9]".
158161 """
159162 self .predictor_config = {
160163 "model_name" : model_name ,
161164 "instance_type" : instance_type ,
162165 "initial_instance_count" : instance_count ,
163166 }
167+ if endpoint_name_prefix is not None :
168+ if re .search ("^[a-zA-Z0-9](-*[a-zA-Z0-9])" , endpoint_name_prefix ) is None :
169+ raise ValueError (
170+ "Invalid endpoint_name_prefix."
171+ " Please follow pattern ^[a-zA-Z0-9](-*[a-zA-Z0-9])."
172+ )
173+ self .predictor_config ["endpoint_name_prefix" ] = endpoint_name_prefix
164174 if accept_type is not None :
165175 if accept_type not in ["text/csv" , "application/jsonlines" ]:
166176 raise ValueError (
@@ -277,6 +287,7 @@ def __init__(
277287 agg_method ,
278288 use_logit = False ,
279289 save_local_shap_values = True ,
290+ seed = None ,
280291 ):
281292 """Initializes config for SHAP.
282293
@@ -297,6 +308,7 @@ def __init__(
297308 have log-odds units.
298309 save_local_shap_values (bool): Indicator of whether to save the local SHAP values
299310 in the output location. Default is True.
311+ seed (int): seed value to get deterministic SHAP values. Default is None.
300312 """
301313 if agg_method not in ["mean_abs" , "median" , "mean_sq" ]:
302314 raise ValueError (
@@ -310,6 +322,8 @@ def __init__(
310322 "use_logit" : use_logit ,
311323 "save_local_shap_values" : save_local_shap_values ,
312324 }
325+ if seed is not None :
326+ self .shap_config ["seed" ] = seed
313327
314328 def get_explainability_config (self ):
315329 """Returns config."""
@@ -336,6 +350,7 @@ def __init__(
336350 env = None ,
337351 tags = None ,
338352 network_config = None ,
353+ version = None ,
339354 ):
340355 """Initializes a ``Processor`` instance, computing bias metrics and model explanations.
341356
@@ -369,8 +384,9 @@ def __init__(
369384 A :class:`~sagemaker.network.NetworkConfig`
370385 object that configures network isolation, encryption of
371386 inter-container traffic, security group IDs, and subnets.
387+ version (str): Clarify version want to be used.
372388 """
373- container_uri = image_uris .retrieve ("clarify" , sagemaker_session .boto_region_name )
389+ container_uri = image_uris .retrieve ("clarify" , sagemaker_session .boto_region_name , version )
374390 super (SageMakerClarifyProcessor , self ).__init__ (
375391 role ,
376392 container_uri ,
0 commit comments