models
Creates, updates, deletes, gets or lists a models resource.
Overview
| Name | models |
| Type | Resource |
| Id | aws.sagemaker.models |
Fields
The following fields are returned by SELECT queries:
- describe_model
- list_models
| Name | Datatype | Description |
|---|---|---|
containers | array | The containers in the inference pipeline. |
creation_time | string (date-time) | A timestamp that shows when the model was created. |
deployment_recommendation | object | A set of recommended deployment configurations for the model. |
enable_network_isolation | boolean | If True, no inbound or outbound network calls can be made to or from the model container. |
execution_role_arn | string | The Amazon Resource Name (ARN) of the IAM role that you specified for the model. (pattern: <code>arn:aws[a-z-]*:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@-_/]+</code>) |
inference_execution_config | object | Specifies details of how containers in a multi-container endpoint are called. |
model_arn | string | The Amazon Resource Name (ARN) of the model. (pattern: <code>arn:aws[a-z-]:sagemaker:[a-z0-9-]:[0-9]{12}:model/.*</code>) |
model_name | string | Name of the SageMaker model. (pattern: <code>[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?</code>) |
primary_container | object | Describes the container, as part of model definition. |
vpc_config | object | Specifies an Amazon Virtual Private Cloud (VPC) that your SageMaker jobs, hosted models, and compute resources have access to. You can control access to and from your resources by configuring a VPC. For more information, see Give SageMaker Access to Resources in your Amazon VPC. |
| Name | Datatype | Description |
|---|---|---|
creation_time | string (date-time) | A timestamp that indicates when the model was created. |
model_arn | string | The Amazon Resource Name (ARN) of the model. (pattern: <code>arn:aws[a-z-]:sagemaker:[a-z0-9-]:[0-9]{12}:model/.*</code>) |
model_name | string | The name of the model that you want a summary for. (pattern: <code>[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?</code>) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_model | select | region | Describes a model that you created using the CreateModel API. | |
list_models | select | region | Lists models created with the CreateModel API. | |
create_model | insert | region, ModelName | Creates a model in SageMaker. In the request, you name the model and describe a primary container. For the primary container, you specify the Docker image that contains inference code, artifacts (from prior training), and a custom environment map that the inference code uses when you deploy the model for predictions. Use this API to create a model if you want to use SageMaker hosting services or run a batch transform job. To host your model, you create an endpoint configuration with the CreateEndpointConfig API, and then create an endpoint with the CreateEndpoint API. SageMaker then deploys all of the containers that you defined for the model in the hosting environment. To run a batch transform using your model, you start a job with the CreateTransformJob API. SageMaker uses your model and your dataset to get inferences which are then saved to a specified S3 location. In the request, you also provide an IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute hosting instances or for batch transform jobs. In addition, you also use the IAM role to manage permissions the inference code needs. For example, if the inference code access any other Amazon Web Services resources, you grant necessary permissions via this role. | |
delete_model | delete | region | Deletes a model. The DeleteModel API deletes only the model entry that was created in SageMaker when you called the CreateModel API. It does not delete model artifacts, inference code, or the IAM role that you specified when creating the model. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_model
- list_models
Describes a model that you created using the CreateModel API.
SELECT
containers,
creation_time,
deployment_recommendation,
enable_network_isolation,
execution_role_arn,
inference_execution_config,
model_arn,
model_name,
primary_container,
vpc_config
FROM aws.sagemaker.models
WHERE region = '{{ region }}' -- required
;
Lists models created with the CreateModel API.
SELECT
creation_time,
model_arn,
model_name
FROM aws.sagemaker.models
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_model
- Manifest
Creates a model in SageMaker. In the request, you name the model and describe a primary container. For the primary container, you specify the Docker image that contains inference code, artifacts (from prior training), and a custom environment map that the inference code uses when you deploy the model for predictions. Use this API to create a model if you want to use SageMaker hosting services or run a batch transform job. To host your model, you create an endpoint configuration with the CreateEndpointConfig API, and then create an endpoint with the CreateEndpoint API. SageMaker then deploys all of the containers that you defined for the model in the hosting environment. To run a batch transform using your model, you start a job with the CreateTransformJob API. SageMaker uses your model and your dataset to get inferences which are then saved to a specified S3 location. In the request, you also provide an IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute hosting instances or for batch transform jobs. In addition, you also use the IAM role to manage permissions the inference code needs. For example, if the inference code access any other Amazon Web Services resources, you grant necessary permissions via this role.
INSERT INTO aws.sagemaker.models (
ModelName,
PrimaryContainer,
Containers,
InferenceExecutionConfig,
ExecutionRoleArn,
Tags,
VpcConfig,
EnableNetworkIsolation,
region
)
SELECT
'{{ ModelName }}' /* required */,
'{{ PrimaryContainer }}',
'{{ Containers }}',
'{{ InferenceExecutionConfig }}',
'{{ ExecutionRoleArn }}',
'{{ Tags }}',
'{{ VpcConfig }}',
{{ EnableNetworkIsolation }},
'{{ region }}'
RETURNING
model_arn
;
# Description fields are for documentation purposes
- name: models
props:
- name: region
value: "{{ region }}"
description: Required parameter for the models resource.
- name: ModelName
value: "{{ ModelName }}"
description: |
The name of the new model.
- name: PrimaryContainer
description: |
The location of the primary docker image containing inference code, associated artifacts, and custom environment map that the inference code uses when the model is deployed for predictions.
value:
ContainerHostname: "{{ ContainerHostname }}"
Image: "{{ Image }}"
ImageConfig:
RepositoryAccessMode: "{{ RepositoryAccessMode }}"
RepositoryAuthConfig:
RepositoryCredentialsProviderArn: "{{ RepositoryCredentialsProviderArn }}"
Mode: "{{ Mode }}"
ModelDataUrl: "{{ ModelDataUrl }}"
ModelDataSource:
S3DataSource:
S3Uri: "{{ S3Uri }}"
S3DataType: "{{ S3DataType }}"
CompressionType: "{{ CompressionType }}"
ModelAccessConfig:
AcceptEula: {{ AcceptEula }}
HubAccessConfig:
HubContentArn: "{{ HubContentArn }}"
ManifestS3Uri: "{{ ManifestS3Uri }}"
ETag: "{{ ETag }}"
ManifestEtag: "{{ ManifestEtag }}"
AdditionalModelDataSources:
- ChannelName: "{{ ChannelName }}"
S3DataSource:
S3Uri: "{{ S3Uri }}"
S3DataType: "{{ S3DataType }}"
CompressionType: "{{ CompressionType }}"
ModelAccessConfig:
AcceptEula: {{ AcceptEula }}
HubAccessConfig:
HubContentArn: "{{ HubContentArn }}"
ManifestS3Uri: "{{ ManifestS3Uri }}"
ETag: "{{ ETag }}"
ManifestEtag: "{{ ManifestEtag }}"
Environment: "{{ Environment }}"
ModelPackageName: "{{ ModelPackageName }}"
InferenceSpecificationName: "{{ InferenceSpecificationName }}"
MultiModelConfig:
ModelCacheSetting: "{{ ModelCacheSetting }}"
ContainerMetricsConfig:
MetricsEndpoints:
- MetricsEndpointPath: "{{ MetricsEndpointPath }}"
MetricPublishFrequencyInSeconds: {{ MetricPublishFrequencyInSeconds }}
- name: Containers
description: |
Specifies the containers in the inference pipeline.
value:
- ContainerHostname: "{{ ContainerHostname }}"
Image: "{{ Image }}"
ImageConfig:
RepositoryAccessMode: "{{ RepositoryAccessMode }}"
RepositoryAuthConfig:
RepositoryCredentialsProviderArn: "{{ RepositoryCredentialsProviderArn }}"
Mode: "{{ Mode }}"
ModelDataUrl: "{{ ModelDataUrl }}"
ModelDataSource:
S3DataSource:
S3Uri: "{{ S3Uri }}"
S3DataType: "{{ S3DataType }}"
CompressionType: "{{ CompressionType }}"
ModelAccessConfig:
AcceptEula: {{ AcceptEula }}
HubAccessConfig:
HubContentArn: "{{ HubContentArn }}"
ManifestS3Uri: "{{ ManifestS3Uri }}"
ETag: "{{ ETag }}"
ManifestEtag: "{{ ManifestEtag }}"
AdditionalModelDataSources: "{{ AdditionalModelDataSources }}"
Environment: "{{ Environment }}"
ModelPackageName: "{{ ModelPackageName }}"
InferenceSpecificationName: "{{ InferenceSpecificationName }}"
MultiModelConfig:
ModelCacheSetting: "{{ ModelCacheSetting }}"
ContainerMetricsConfig:
MetricsEndpoints:
- MetricsEndpointPath: "{{ MetricsEndpointPath }}"
MetricPublishFrequencyInSeconds: {{ MetricPublishFrequencyInSeconds }}
- name: InferenceExecutionConfig
description: |
Specifies details of how containers in a multi-container endpoint are called.
value:
Mode: "{{ Mode }}"
- name: ExecutionRoleArn
value: "{{ ExecutionRoleArn }}"
description: |
The Amazon Resource Name (ARN) of the IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute instances or for batch transform jobs. Deploying on ML compute instances is part of model hosting. For more information, see SageMaker Roles. To be able to pass this role to SageMaker, the caller of this API must have the iam:PassRole permission.
- name: Tags
description: |
An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services Resources.
value:
- Key: "{{ Key }}"
Value: "{{ Value }}"
- name: VpcConfig
description: |
Specifies an Amazon Virtual Private Cloud (VPC) that your SageMaker jobs, hosted models, and compute resources have access to. You can control access to and from your resources by configuring a VPC. For more information, see Give SageMaker Access to Resources in your Amazon VPC.
value:
SecurityGroupIds:
- "{{ SecurityGroupIds }}"
Subnets:
- "{{ Subnets }}"
- name: EnableNetworkIsolation
value: {{ EnableNetworkIsolation }}
description: |
Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
DELETE examples
- delete_model
Deletes a model. The DeleteModel API deletes only the model entry that was created in SageMaker when you called the CreateModel API. It does not delete model artifacts, inference code, or the IAM role that you specified when creating the model.
DELETE FROM aws.sagemaker.models
WHERE region = '{{ region }}' --required
;