19
19
import json
20
20
import os
21
21
import tempfile
22
-
22
+ import re
23
23
from sagemaker .processing import ProcessingInput , ProcessingOutput , Processor
24
24
from sagemaker import image_uris , s3 , utils
25
25
@@ -124,8 +124,9 @@ def __init__(
124
124
content_template = None ,
125
125
custom_attributes = None ,
126
126
accelerator_type = None ,
127
+ endpoint_name_prefix = None ,
127
128
):
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.
129
130
130
131
Args:
131
132
model_name (str): Model name (as created by 'CreateModel').
@@ -155,12 +156,21 @@ def __init__(
155
156
accelerator_type (str): The Elastic Inference accelerator type to deploy to the model
156
157
endpoint instance for making inferences to the model, see
157
158
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]".
158
161
"""
159
162
self .predictor_config = {
160
163
"model_name" : model_name ,
161
164
"instance_type" : instance_type ,
162
165
"initial_instance_count" : instance_count ,
163
166
}
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
164
174
if accept_type is not None :
165
175
if accept_type not in ["text/csv" , "application/jsonlines" ]:
166
176
raise ValueError (
@@ -277,6 +287,7 @@ def __init__(
277
287
agg_method ,
278
288
use_logit = False ,
279
289
save_local_shap_values = True ,
290
+ seed = None ,
280
291
):
281
292
"""Initializes config for SHAP.
282
293
@@ -297,6 +308,7 @@ def __init__(
297
308
have log-odds units.
298
309
save_local_shap_values (bool): Indicator of whether to save the local SHAP values
299
310
in the output location. Default is True.
311
+ seed (int): seed value to get deterministic SHAP values. Default is None.
300
312
"""
301
313
if agg_method not in ["mean_abs" , "median" , "mean_sq" ]:
302
314
raise ValueError (
@@ -310,6 +322,8 @@ def __init__(
310
322
"use_logit" : use_logit ,
311
323
"save_local_shap_values" : save_local_shap_values ,
312
324
}
325
+ if seed is not None :
326
+ self .shap_config ["seed" ] = seed
313
327
314
328
def get_explainability_config (self ):
315
329
"""Returns config."""
@@ -336,6 +350,7 @@ def __init__(
336
350
env = None ,
337
351
tags = None ,
338
352
network_config = None ,
353
+ version = None ,
339
354
):
340
355
"""Initializes a ``Processor`` instance, computing bias metrics and model explanations.
341
356
@@ -369,8 +384,9 @@ def __init__(
369
384
A :class:`~sagemaker.network.NetworkConfig`
370
385
object that configures network isolation, encryption of
371
386
inter-container traffic, security group IDs, and subnets.
387
+ version (str): Clarify version want to be used.
372
388
"""
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 )
374
390
super (SageMakerClarifyProcessor , self ).__init__ (
375
391
role ,
376
392
container_uri ,
0 commit comments