40
40
SHAP_BASELINE = "1,2,3,4,5,6,7"
41
41
XGBOOST_DATA_PATH = os .path .join (DATA_DIR , "xgboost_model" )
42
42
43
+ CLARIFY_SHAP_BASELINE_CONFIG = ClarifyShapBaselineConfig (shap_baseline = SHAP_BASELINE )
44
+ CLARIFY_SHAP_CONFIG = ClarifyShapConfig (shap_baseline_config = CLARIFY_SHAP_BASELINE_CONFIG )
45
+ CLARIFY_EXPLAINER_CONFIG = ClarifyExplainerConfig (shap_config = CLARIFY_SHAP_CONFIG )
46
+ EXPLAINER_CONFIG = ExplainerConfig (clarify_explainer_config = CLARIFY_EXPLAINER_CONFIG )
47
+
43
48
44
49
@pytest .yield_fixture (scope = "module" )
45
50
def endpoint_name (sagemaker_session ):
@@ -66,19 +71,26 @@ def endpoint_name(sagemaker_session):
66
71
role = ROLE ,
67
72
sagemaker_session = sagemaker_session ,
68
73
)
69
- clarify_shap_baseline_config = ClarifyShapBaselineConfig (shap_baseline = SHAP_BASELINE )
70
- clarify_shap_config = ClarifyShapConfig (shap_baseline_config = clarify_shap_baseline_config )
71
- clarify_explainer_config = ClarifyExplainerConfig (shap_config = clarify_shap_config )
72
- explainer_config = ExplainerConfig (clarify_explainer_config = clarify_explainer_config )
73
74
xgb_model .deploy (
74
75
INSTANCE_COUNT ,
75
76
INSTANCE_TYPE ,
76
77
endpoint_name = endpoint_name ,
77
- explainer_config = explainer_config ,
78
+ explainer_config = EXPLAINER_CONFIG ,
78
79
)
79
80
yield endpoint_name
80
81
81
82
83
+ def test_describe_explainer_config (sagemaker_session , endpoint_name ):
84
+ endpoint_desc = sagemaker_session .sagemaker_client .describe_endpoint (
85
+ EndpointName = endpoint_name
86
+ )
87
+
88
+ endpoint_config_desc = sagemaker_session .sagemaker_client .describe_endpoint_config (
89
+ EndpointConfigName = endpoint_desc ["EndpointConfigName" ]
90
+ )
91
+ assert endpoint_config_desc ["ExplainerConfig" ] == EXPLAINER_CONFIG ._to_request_dict ()
92
+
93
+
82
94
def test_invoke_explainer_enabled_endpoint (sagemaker_session , endpoint_name ):
83
95
response = sagemaker_session .sagemaker_runtime_client .invoke_endpoint (
84
96
EndpointName = endpoint_name ,
0 commit comments