Skip to content

Commit c80b63d

Browse files
author
Naresh Kumar Kolloju
committed
change: [pr-827][followups]Improve documentation of some functions
Also some unit test fixes. See comments from mario in aws#827
1 parent 91e658c commit c80b63d

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/sagemaker/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,9 @@ def transform(self, job_name, model_name, strategy, max_concurrent_transforms, m
514514
input_config (dict): A dictionary describing the input data (and its location) for the job.
515515
output_config (dict): A dictionary describing the output location for the job.
516516
resource_config (dict): A dictionary describing the resources to complete the job.
517-
tags (list[dict]): List of tags for labeling a transform job.
517+
tags (list[dict]): List of tags for labeling a transform job. For more information,
518+
see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
518519
data_processing(dict): A dictionary describing config for combining the input data and transformed data.
519-
For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
520520
"""
521521
transform_request = {
522522
'TransformJobName': job_name,

src/sagemaker/transformer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ def transform(self, data, data_type='S3Prefix', content_type=None, compression_t
9999
job_name (str): job name (default: None). If not specified, one will be generated.
100100
input_filter (str): A JSONPath to select a portion of the input to pass to the algorithm container for
101101
inference. If you omit the field, it gets the value '$', representing the entire input.
102+
For more information, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html
102103
Some examples: "$[1:]", "$.features"(default: None).
103104
output_filter (str): A JSONPath to select a portion of the joined/original output to return as the output.
105+
For more information, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html
104106
Some examples: "$[1:]", "$.prediction" (default: None).
105107
join_source (str): The source of data to be joined to the transform output. It can be set to 'Input'
106108
meaning the entire input record will be joined to the inference result.

tests/integ/test_transformer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ def test_transform_mxnet(sagemaker_session, mxnet_full_version):
5555

5656
kms_key_arn = get_or_create_kms_key(sagemaker_session)
5757
output_filter = "$"
58+
input_filter = "$"
5859

5960
transformer = _create_transformer_and_transform_job(mx, transform_input, kms_key_arn,
60-
input_filter=None, output_filter=output_filter,
61+
input_filter=input_filter, output_filter=output_filter,
6162
join_source=None)
6263
with timeout_and_delete_model_with_transformer(transformer, sagemaker_session,
6364
minutes=TRANSFORM_DEFAULT_TIMEOUT_MINUTES):
@@ -67,6 +68,7 @@ def test_transform_mxnet(sagemaker_session, mxnet_full_version):
6768
TransformJobName=transformer.latest_transform_job.name)
6869
assert kms_key_arn == job_desc['TransformResources']['VolumeKmsKeyId']
6970
assert output_filter == job_desc['DataProcessing']['OutputFilter']
71+
assert input_filter == job_desc['DataProcessing']['InputFilter']
7072

7173

7274
@pytest.mark.canary_quick

tests/unit/test_session.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,17 +578,24 @@ def test_transform_pack_to_request(sagemaker_session):
578578
'InstanceType': INSTANCE_TYPE,
579579
}
580580

581+
data_processing = {
582+
'OutputFilter': '$',
583+
'InputFilter': '$',
584+
'JoinSource': 'Input'
585+
}
586+
581587
expected_args = {
582588
'TransformJobName': JOB_NAME,
583589
'ModelName': model_name,
584590
'TransformInput': in_config,
585591
'TransformOutput': out_config,
586592
'TransformResources': resource_config,
593+
'DataProcessing': data_processing,
587594
}
588595

589596
sagemaker_session.transform(job_name=JOB_NAME, model_name=model_name, strategy=None, max_concurrent_transforms=None,
590597
max_payload=None, env=None, input_config=in_config, output_config=out_config,
591-
resource_config=resource_config, tags=None, data_processing=None)
598+
resource_config=resource_config, tags=None, data_processing=data_processing)
592599

593600
_, _, actual_args = sagemaker_session.sagemaker_client.method_calls[0]
594601
assert actual_args == expected_args

0 commit comments

Comments
 (0)