Skip to content

Commit 946adeb

Browse files
knareshlaurenyu
authored andcommitted
change: improve documentation of some functions (#864)
[pr-827][followups] Improve documentation of some functions. Also some unit test fixes. See comments from marcio in #827
1 parent 910d9f8 commit 946adeb

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/sagemaker/session.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ def transform(
581581
input_config (dict): A dictionary describing the input data (and its location) for the job.
582582
output_config (dict): A dictionary describing the output location for the job.
583583
resource_config (dict): A dictionary describing the resources to complete the job.
584-
tags (list[dict]): List of tags for labeling a transform job.
584+
tags (list[dict]): List of tags for labeling a transform job. For more information,
585+
see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
585586
data_processing(dict): A dictionary describing config for combining the input data and transformed data.
586-
For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
587587
"""
588588
transform_request = {
589589
"TransformJobName": job_name,

src/sagemaker/transformer.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ def transform(
142142
input_filter (str): A JSONPath to select a portion of the input to
143143
pass to the algorithm container for inference. If you omit the
144144
field, it gets the value '$', representing the entire input.
145-
Some examples: "$[1:]", "$.features"(default: None).
145+
For more information, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html.
146+
Some examples: "$[1:]", "$.features" (default: None).
146147
output_filter (str): A JSONPath to select a portion of the
147-
joined/original output to return as the output. Some examples:
148-
"$[1:]", "$.prediction" (default: None).
148+
joined/original output to return as the output.
149+
For more information, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html.
150+
Some examples: "$[1:]", "$.prediction" (default: None).
149151
join_source (str): The source of data to be joined to the transform
150152
output. It can be set to 'Input' meaning the entire input record
151153
will be joined to the inference result. You can use OutputFilter

tests/integ/test_transformer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ def test_transform_mxnet(sagemaker_session, mxnet_full_version):
6767

6868
kms_key_arn = get_or_create_kms_key(sagemaker_session)
6969
output_filter = "$"
70+
input_filter = "$"
7071

7172
transformer = _create_transformer_and_transform_job(
7273
mx,
7374
transform_input,
7475
kms_key_arn,
75-
input_filter=None,
76+
input_filter=input_filter,
7677
output_filter=output_filter,
7778
join_source=None,
7879
)
@@ -86,6 +87,7 @@ def test_transform_mxnet(sagemaker_session, mxnet_full_version):
8687
)
8788
assert kms_key_arn == job_desc["TransformResources"]["VolumeKmsKeyId"]
8889
assert output_filter == job_desc["DataProcessing"]["OutputFilter"]
90+
assert input_filter == job_desc["DataProcessing"]["InputFilter"]
8991

9092

9193
@pytest.mark.canary_quick

tests/unit/test_session.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,15 @@ def test_transform_pack_to_request(sagemaker_session):
676676

677677
resource_config = {"InstanceCount": INSTANCE_COUNT, "InstanceType": INSTANCE_TYPE}
678678

679+
data_processing = {"OutputFilter": "$", "InputFilter": "$", "JoinSource": "Input"}
680+
679681
expected_args = {
680682
"TransformJobName": JOB_NAME,
681683
"ModelName": model_name,
682684
"TransformInput": in_config,
683685
"TransformOutput": out_config,
684686
"TransformResources": resource_config,
687+
"DataProcessing": data_processing,
685688
}
686689

687690
sagemaker_session.transform(
@@ -695,7 +698,7 @@ def test_transform_pack_to_request(sagemaker_session):
695698
output_config=out_config,
696699
resource_config=resource_config,
697700
tags=None,
698-
data_processing=None,
701+
data_processing=data_processing,
699702
)
700703

701704
_, _, actual_args = sagemaker_session.sagemaker_client.method_calls[0]

0 commit comments

Comments
 (0)