Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SageMaker list_models inconsistent results #4020

Closed
b5y opened this issue Feb 15, 2024 · 2 comments
Closed

SageMaker list_models inconsistent results #4020

b5y opened this issue Feb 15, 2024 · 2 comments
Assignees
Labels
bug This issue is a confirmed bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p3 This is a minor priority issue sagemaker

Comments

@b5y
Copy link

b5y commented Feb 15, 2024

Describe the bug

This bug duplicates this one. In my case if I don't put MaxResults at all, I get empty list of models. If I put 20 or more, I get only 1 model, but there are 2 models with same suffix in NameContains argument.

Expected Behavior

List of all models, no matter whether MaxResults were defined or not.

Current Behavior

1 model shows up or no model if you don't specify MaxResults.

Reproduction Steps

from boto3 import client

sagemaker = client("sagemaker", region_name="eu-west-1")
sagemaker.list_models(
        NameContains="some-prefix",
        MaxResults=<a number>,
)

Possible Solution

as for now, even defining MaxResults doesn't help.

Additional Information/Context

Same behavior happens if I define sagemaker client via sagemaker-python-sdk:

import os

import boto3
import sagemaker


REGION_NAME = "eu-west-1"
S3_CLIENT = boto3.client("s3", region_name=REGION_NAME)

BOTO_SESSION = boto3.session.Session(
    region_name=REGION_NAME,
)
SAGEMAKER_SESSION = sagemaker.Session(BOTO_SESSION)
SM_CLIENT = SAGEMAKER_SESSION.sagemaker_client
RUNTIME_SG_CLIENT = SAGEMAKER_SESSION.sagemaker_runtime_client


models = SM_CLIENT.list_models(
        SortBy='Name',
        NameContains="some-prefix",
        # CreationTimeAfter=datetime(today.year, today.month, today.day)
    )

Surprisingly, the approach above worked last month (without MaxResults). Recently it stopped working.

SDK version used

1.34.23

Environment details (OS name and version, etc.)

Ubuntu 22.04, Python 3.9 and above.

@b5y b5y added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Feb 15, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Feb 21, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added investigating This issue is being investigated and/or work is in progress to resolve the issue. sagemaker p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Feb 21, 2024
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @b5y, thanks for reaching out. This behavior is known and intended. For Sagemaker operations that return a paginated result, the MaxResult number of resources are retrieved before applying any filters. You're intended to use pagination here in order to get all resources that match your filter.

The Sagemaker team is currently in the process of documenting this behavior. You can see an example of the type of note being added to the documentation here. I did reach out to the service team to ask for an update about this, and I'll leave any updates in this tracking issue (aws/aws-sdk#701) in our cross-SDK repository. Thanks!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p3 This is a minor priority issue sagemaker
Projects
None yet
Development

No branches or pull requests

2 participants