In Java, for instance, we have a class that represents the SageMaker client class: AmazonSageMakerClient
, but I couldn’t find the equivalent for Python.
I was hoping to be able to do something like:
from sagemaker import SageMakerClient
client: SageMakerClient = boto3.client("sagemaker")
I looked into the library code and docs but I couldn’t find any references to such class containing the defined methods for that client. In fact, I couldn’t find any classes for AWS clients like s3
, sqs
, etc. Are those hidden somewhere or am I missing something obvious?
4
Answers
In boto3, there is basically 2 levels of objects avaialble:
Take a look at S3, and you will see that in addition to the Client object there are also other rich object types like Bucket.
It would seem that Sagemaker doesn’t (yet) have this second level of abstraction available.
To be more productive, and work with Python classes rather than Json, try to use the SageMaker Python SDK whenever possible rather than Boto3 clients.
With Boto3 you have several SageMaker clients (As @anon said correctly):
The boto3-stubs library can help with this.
Install using the instructions for your IDE on the package page, and then install the specific type annotations for SageMaker.
You should be able to see type hints for the
client
object (type:SageMakerClient
).If you need to add hints yourself:
You may not need to do that. Here’s some tricks I have used for a while:
I checked the source code, it use boto_stub under the hood and enumerate all available client and explicitly give them type hint.
Hope this is helpful