Skip to content

Commit 0b860d5

Browse files
committed
fix: Correct Clarify API docstrings by changing JSONPath to JMESPath
SageMaker Clarify API docstrings use term JSONPath, but actually the Clarify processing container expects JMESPath expression. The commit corrects the term to avoid customer confusion.
1 parent 32969da commit 0b860d5

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

src/sagemaker/clarify.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ def __init__(
331331
s3_analysis_config_output_path (str): S3 prefix to store the analysis config output.
332332
If this field is None, then the ``s3_output_path`` will be used
333333
to store the ``analysis_config`` output.
334-
label (str): Target attribute of the model required by bias metrics.
335-
Specified as column name or index for CSV dataset or as JSONPath for JSONLines.
334+
label (str): Target attribute of the model required by bias metrics. Specified as
335+
column name or index for CSV dataset or as JMESPath expression for JSONLines.
336336
*Required parameter* except for when the input dataset does not contain the label.
337-
features (List[str]): JSONPath for locating the feature columns for bias metrics if the
338-
dataset format is JSONLines.
337+
features (List[str]): JMESPath expression to locate the feature columns for
338+
bias metrics if the dataset format is JSONLines.
339339
dataset_type (str): Format of the dataset. Valid values are ``"text/csv"`` for CSV,
340340
``"application/jsonlines"`` for JSONLines, and
341341
``"application/x-parquet"`` for Parquet.
@@ -717,11 +717,11 @@ def __init__(
717717
``label_headers=['cat','dog','fish']`` and infer the predicted label to be ``'fish'``.
718718
719719
Args:
720-
label (str or int): Index or JSONPath location in the model output for the prediction.
721-
In case, this is a predicted label of the same type as the label in the dataset,
722-
no further arguments need to be specified.
723-
probability (str or int): Index or JSONPath location in the model output
724-
for the predicted score(s).
720+
label (str or int): Index or JMESPath expression to locate the prediction
721+
in the model output. In case, this is a predicted label of the same type
722+
as the label in the dataset, no further arguments need to be specified.
723+
probability (str or int): Index or JMESPath expression to locate the predicted score(s)
724+
in the model output.
725725
probability_threshold (float): An optional value for binary prediction tasks in which
726726
the model returns a probability, to indicate the threshold to convert the
727727
prediction to a boolean value. Default is ``0.5``.
@@ -1646,9 +1646,9 @@ def run_explainability(
16461646
You can request multiple methods at once by passing in a list of
16471647
`~sagemaker.clarify.ExplainabilityConfig`.
16481648
model_scores (int or str or :class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
1649-
Index or JSONPath to locate the predicted scores in the model output. This is not
1650-
required if the model output is a single score. Alternatively, it can be an instance
1651-
of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
1649+
Index or JMESPath expression to locate the predicted scores in the model output.
1650+
This is not required if the model output is a single score. Alternatively,
1651+
it can be an instance of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
16521652
to provide more parameters like ``label_headers``.
16531653
wait (bool): Whether the call should wait until the job completes (default: True).
16541654
logs (bool): Whether to show the logs produced by the job.
@@ -1775,9 +1775,9 @@ def run_bias_and_explainability(
17751775
str or
17761776
:class:`~sagemaker.clarify.ModelPredictedLabelConfig`
17771777
):
1778-
Index or JSONPath to locate the predicted scores in the model output. This is not
1779-
required if the model output is a single score. Alternatively, it can be an instance
1780-
of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
1778+
Index or JMESPath expression to locate the predicted scores in the model output.
1779+
This is not required if the model output is a single score. Alternatively,
1780+
it can be an instance of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
17811781
to provide more parameters like ``label_headers``.
17821782
wait (bool): Whether the call should wait until the job completes (default: True).
17831783
logs (bool): Whether to show the logs produced by the job.

src/sagemaker/model_monitor/clarify_model_monitoring.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ def __init__(self, bias_config, headers=None, label=None):
842842
bias_config (sagemaker.clarify.BiasConfig): Config object related to bias
843843
configurations.
844844
headers (list[str]): A list of column names in the input dataset.
845-
label (str): Target attribute for the model required by bias metrics.
846-
Specified as column name or index for CSV dataset, or as JSONPath for JSONLines.
845+
label (str): Target attribute for the model required by bias metrics. Specified as
846+
column name or index for CSV dataset, or as JMESPath expression for JSONLines.
847847
"""
848848
self.analysis_config = bias_config.get_config()
849849
if headers is not None:
@@ -889,9 +889,10 @@ def suggest_baseline(
889889
model_config (:class:`~sagemaker.clarify.ModelConfig`): Config of the model and its
890890
endpoint to be created.
891891
model_scores (int or str or :class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
892-
Index or JSONPath to locate the predicted scores in the model output. This is not
893-
required if the model output is a single score. Alternatively, it can be an instance
894-
of ModelPredictedLabelConfig to provide more parameters like label_headers.
892+
Index or JMESPath expression to locate the predicted scores in the model output.
893+
This is not required if the model output is a single score. Alternatively,
894+
it can be an instance of ModelPredictedLabelConfig to provide more parameters
895+
like label_headers.
895896
wait (bool): Whether the call should wait until the job completes (default: False).
896897
logs (bool): Whether to show the logs produced by the job.
897898
Only meaningful when wait is True (default: False).
@@ -1302,12 +1303,12 @@ def __init__(
13021303
Args:
13031304
analysis_config (BiasAnalysisConfig or ExplainabilityAnalysisConfig): analysis config
13041305
from configurations of the baselining job.
1305-
features_attribute (str): JSONpath to locate features in predictor request payload.
1306-
Only required when predictor content type is JSONlines.
1307-
inference_attribute (str): Index, header or JSONpath to locate predicted label in
1308-
predictor response payload.
1309-
probability_attribute (str): Index or JSONpath location in the model output for
1310-
probabilities or scores to be used for explainability.
1306+
features_attribute (str): JMESPath expression to locate features in predictor request
1307+
payload. Only required when predictor content type is JSONlines.
1308+
inference_attribute (str): Index, header or JMESPath expression to locate predicted
1309+
label in predictor response payload.
1310+
probability_attribute (str): Index or JMESPath expression to locate probabilities or
1311+
scores in the model output for computing feature attribution.
13111312
probability_threshold_attribute (float): Value to indicate the threshold to select
13121313
the binary label in the case of binary classification. Default is 0.5.
13131314
"""

src/sagemaker/model_monitor/model_monitoring.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1061,12 +1061,13 @@ def _generate_env_map(
10611061
dataset_format (dict): The format of the baseline_dataset.
10621062
dataset_source_container_path (str): The path to the dataset source.
10631063
inference_attribute (str): Index or JSONpath to locate predicted label(s).
1064-
Only used for ModelQualityMonitor, ModelBiasMonitor, and ModelExplainabilityMonitor
1064+
Only used for ModelQualityMonitor.
10651065
probability_attribute (str or int): Index or JSONpath to locate probabilities.
1066-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
1067-
ground_truth_attribute (str): Index or JSONpath to locate actual label(s).
1066+
Only used for ModelQualityMonitor.
1067+
ground_truth_attribute (str): Index to locate actual label(s).
1068+
Only used for ModelQualityMonitor.
10681069
probability_threshold_attribute (float): threshold to convert probabilities to binaries
1069-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
1070+
Only used for ModelQualityMonitor.
10701071
10711072
Returns:
10721073
dict: Dictionary of environment keys and values.
@@ -2600,10 +2601,13 @@ def suggest_baseline(
26002601
problem_type (str): The type of problem of this model quality monitoring. Valid
26012602
values are "Regression", "BinaryClassification", "MulticlassClassification".
26022603
inference_attribute (str): Index or JSONpath to locate predicted label(s).
2604+
Only used for ModelQualityMonitor.
26032605
probability_attribute (str or int): Index or JSONpath to locate probabilities.
2604-
ground_truth_attribute (str): Index or JSONpath to locate actual label(s).
2606+
Only used for ModelQualityMonitor.
2607+
ground_truth_attribute (str): Index to locate actual label(s).
2608+
Only used for ModelQualityMonitor.
26052609
probability_threshold_attribute (float): threshold to convert probabilities to binaries
2606-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
2610+
Only used for ModelQualityMonitor.
26072611
post_analytics_processor_script (str): The path to the record post-analytics processor
26082612
script. This can be a local path or an S3 uri.
26092613
output_s3_uri (str): Desired S3 destination Destination of the constraint_violations

src/sagemaker/workflow/clarify_check_step.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ class ModelExplainabilityCheckConfig(ClarifyCheckConfig):
132132
model_config (ModelConfig): Config of the model and its endpoint to be created.
133133
explainability_config (SHAPConfig): Config of the specific explainability method.
134134
Currently, only SHAP is supported.
135-
model_scores (str or int or ModelPredictedLabelConfig): Index or JSONPath location
136-
in the model output for the predicted scores to be explained (default: None).
135+
model_scores (str or int or ModelPredictedLabelConfig): Index or JMESPath expression
136+
to locate the predicted scores in the model output (default: None).
137137
This is not required if the model output is a single score. Alternatively,
138138
an instance of ModelPredictedLabelConfig can be provided
139139
but this field CANNOT be any type of the `PipelineVariable`.

0 commit comments

Comments
 (0)