Add list_models() method to the Session class
Is your feature request related to a problem? Please describe. Deployment is a 3-steps process: (1) Create the model in SM (2) Create endpoint configuration (3) Create endpoint
Assume that I decouple (a) model training and the final model evaluation via, e.g., batch transform from (b) the model deployment. For (a) I already created and registered a model in SM. For (b) the deployment, I need to reference the name of the registred model.
Based on my understanding of 2.x SM Python API, the user has no option to cover the decoupled deployment process just by using the SM Python SDK alone:
-
The SDK provides methods via the Session object to cover steps (2) and (3) of the deployment process:
create_endpoint_config(),create_endpoint().create_endpoint_config()requires the model name as a parameter -
However, no method seems to be available which allows me to retrieve the list of model names via the SM Python SDK.
I need to create an additional SM client using boto3 in my current process to deploy models in a decoupled fashion:
import sagemaker
session = sagemaker.Session()
sm_client = session.boto_session.client("sagemaker")
# Assume I like to create an endpoint for the last model created
model_name = sm_client.list_models()["Models"][1]["ModelName"]
session.create_endpoint_config(name = "test-config",
model_name = model_name,
initial_instance_count = 1,
instance_type = "ml.m5.large")
session.create_endpoint(endpoint_name = "test-endpoint",
config_name = "test-config",
wait = False)
To provide support for a fully decoupled deployment process using the SM Python SDK, I would vote for a list_models() method in the Session class. This method returns the list of names of all available models in SM. The user can retrieve the desired model name from this list and use it as a parameter in create_endpoint_config(). This eliminates the need to create an extra boto3 SM client.
@alex23lemm Thank you for using Amazon SageMaker.
I see that you are requesting the ability to list models from the sagemaker.Session instance itself in order to select one of the models for subsequent steps, such as creating endpoints.
You've cited one work-around for using the lower level boto3 client, which is not without precedence in the corpus.
We are always re-evaluating our backlog of features based on customer requests, so we appreciate the feedback on this feature.
Let us know if there is anything else we can be an assistance of.
Hi @alex23lemm
Great news! This issue has been resolved with the release of SageMaker Python SDK v3.
How to Get the Latest Version
You can upgrade to the latest v3 package using pip:
pip install --upgrade sagemaker
##Or specify the version explicitly:
pip install sagemaker>=3.0.0
Additional Resources:
PyPI: https://pypi.org/project/sagemaker/ Documentation: https://sagemaker.readthedocs.io/
If you're still experiencing this issue after upgrading, please feel free to reopen this issue or create a new one with updated details.