boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
8.81k stars 1.84k forks source link

list_models API returns inconsistent results from AWS CLI and python SDK #4158

Open amada2023 opened 3 weeks ago

amada2023 commented 3 weeks ago

Describe the bug

I have to use list_models API with below request body

aws sagemaker list-models --name-contains "model-abc" --sort-by "CreationTime" --sort-order Descending --max-items 1

in CLI case it returns me latest model which contains the required name. it first filters by name and then applies pagination of max-items=1

but in case of python SDK response = sm_client.list_models( NameContains="model-abc", SortBy="CreationTime", SortOrder="Descending", MaxResults=1, ) its first applying the pagination because of MaxResults =1 and then applying filter of name contains which is then returning my model summary as empty [] because the top result is not that name.

This seems like inconsistent behavior in API calls. Conceptually you always filter first and then apply pagination on results as in CLI behavior today.

Expected Behavior

{ "Models": [ { "ModelName": "model-abc-123", "ModelArn": "", "CreationTime": "2024-06-07T13:37:49.303000-04:00" } ], "NextToken": "" }

Current Behavior

{ "Models": [] }

Reproduction Steps

added in description

Possible Solution

No response

Additional Information/Context

No response

SDK version used

python 3.9 on aws

Environment details (OS name and version, etc.)

Amazon Linux 2