Home > Enterprise >  How to specifify the class of an AWS client in Python?
How to specifify the class of an AWS client in Python?

Time:08-17

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?

CodePudding user response:

In boto3, there is basically 2 levels of objects avaialble:

  1. A client
  2. Actual objects like you are asking about

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.

CodePudding user response:

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):

  • SageMaker - Most of SageMaker features
  • SageMakerRuntime - Invoking endpoints
  • SageMaker* - Other misc SageMaker features like feature store, edge manager, ...
  • Related