CfnInferenceExperiment
- class aws_cdk.aws_sagemaker.CfnInferenceExperiment(scope, id, *, endpoint_name, model_variants, name, role_arn, type, data_storage_config=None, description=None, desired_state=None, kms_key=None, schedule=None, shadow_mode_config=None, status_reason=None, tags=None)
Bases:
CfnResource
A CloudFormation
AWS::SageMaker::InferenceExperiment
.Creates an inference experiment using the configurations specified in the request.
Use this API to setup and schedule an experiment to compare model variants on a Amazon SageMaker inference endpoint. For more information about inference experiments, see Shadow tests .
Amazon SageMaker begins your experiment at the scheduled time and routes traffic to your endpoint’s model variants based on your specified configuration.
While the experiment is in progress or after it has concluded, you can view metrics that compare your model variants. For more information, see View, monitor, and edit shadow tests .
- CloudformationResource:
AWS::SageMaker::InferenceExperiment
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker cfn_inference_experiment = sagemaker.CfnInferenceExperiment(self, "MyCfnInferenceExperiment", endpoint_name="endpointName", model_variants=[sagemaker.CfnInferenceExperiment.ModelVariantConfigProperty( infrastructure_config=sagemaker.CfnInferenceExperiment.ModelInfrastructureConfigProperty( infrastructure_type="infrastructureType", real_time_inference_config=sagemaker.CfnInferenceExperiment.RealTimeInferenceConfigProperty( instance_count=123, instance_type="instanceType" ) ), model_name="modelName", variant_name="variantName" )], name="name", role_arn="roleArn", type="type", # the properties below are optional data_storage_config=sagemaker.CfnInferenceExperiment.DataStorageConfigProperty( destination="destination", # the properties below are optional content_type=sagemaker.CfnInferenceExperiment.CaptureContentTypeHeaderProperty( csv_content_types=["csvContentTypes"], json_content_types=["jsonContentTypes"] ), kms_key="kmsKey" ), description="description", desired_state="desiredState", kms_key="kmsKey", schedule=sagemaker.CfnInferenceExperiment.InferenceExperimentScheduleProperty( end_time="endTime", start_time="startTime" ), shadow_mode_config=sagemaker.CfnInferenceExperiment.ShadowModeConfigProperty( shadow_model_variants=[sagemaker.CfnInferenceExperiment.ShadowModelVariantConfigProperty( sampling_percentage=123, shadow_model_variant_name="shadowModelVariantName" )], source_model_variant_name="sourceModelVariantName" ), status_reason="statusReason", tags=[CfnTag( key="key", value="value" )] )
Create a new
AWS::SageMaker::InferenceExperiment
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
endpoint_name (
str
) – The name of the endpoint.model_variants (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ModelVariantConfigProperty
,Dict
[str
,Any
]]]]) – An array ofModelVariantConfigSummary
objects. There is one for each variant in the inference experiment. EachModelVariantConfigSummary
object in the array describes the infrastructure configuration for deploying the corresponding variant.name (
str
) – The name of the inference experiment.role_arn (
str
) – The ARN of the IAM role that Amazon SageMaker can assume to access model artifacts and container images, and manage Amazon SageMaker Inference endpoints for model deployment.type (
str
) – The type of the inference experiment.data_storage_config (
Union
[IResolvable
,DataStorageConfigProperty
,Dict
[str
,Any
],None
]) – The Amazon S3 location and configuration for storing inference request and response data.description (
Optional
[str
]) – The description of the inference experiment.desired_state (
Optional
[str
]) – The desired state of the experiment after stopping. The possible states are the following:. -Completed
: The experiment completed successfully -Cancelled
: The experiment was canceledkms_key (
Optional
[str
]) – The AWS Key Management Service key that Amazon SageMaker uses to encrypt captured data at rest using Amazon S3 server-side encryption.schedule (
Union
[IResolvable
,InferenceExperimentScheduleProperty
,Dict
[str
,Any
],None
]) – The duration for which the inference experiment ran or will run. The maximum duration that you can set for an inference experiment is 30 days.shadow_mode_config (
Union
[IResolvable
,ShadowModeConfigProperty
,Dict
[str
,Any
],None
]) – The configuration ofShadowMode
inference experiment type, which shows the production variant that takes all the inference requests, and the shadow variant to which Amazon SageMaker replicates a percentage of the inference requests. For the shadow variant it also shows the percentage of requests that Amazon SageMaker replicates.status_reason (
Optional
[str
]) – The error message for the inference experiment status result.tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – An array of key-value pairs to apply to this resource. For more information, see Tag .
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::SageMaker::InferenceExperiment'
- attr_arn
Arn
- Type:
cloudformationAttribute
- attr_creation_time
CreationTime
- Type:
cloudformationAttribute
- attr_endpoint_metadata_endpoint_config_name
EndpointMetadata.EndpointConfigName
- Type:
cloudformationAttribute
- attr_endpoint_metadata_endpoint_name
EndpointMetadata.EndpointName
- Type:
cloudformationAttribute
- attr_endpoint_metadata_endpoint_status
EndpointMetadata.EndpointStatus
- Type:
cloudformationAttribute
- attr_last_modified_time
LastModifiedTime
- Type:
cloudformationAttribute
- attr_status
Status
- Type:
cloudformationAttribute
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- data_storage_config
The Amazon S3 location and configuration for storing inference request and response data.
- description
The description of the inference experiment.
- desired_state
.
Completed
: The experiment completed successfullyCancelled
: The experiment was canceled
- Link:
- Type:
The desired state of the experiment after stopping. The possible states are the following
- endpoint_name
The name of the endpoint.
- kms_key
The AWS Key Management Service key that Amazon SageMaker uses to encrypt captured data at rest using Amazon S3 server-side encryption.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- model_variants
An array of
ModelVariantConfigSummary
objects.There is one for each variant in the inference experiment. Each
ModelVariantConfigSummary
object in the array describes the infrastructure configuration for deploying the corresponding variant.
- name
The name of the inference experiment.
- node
The construct tree node associated with this construct.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- role_arn
The ARN of the IAM role that Amazon SageMaker can assume to access model artifacts and container images, and manage Amazon SageMaker Inference endpoints for model deployment.
- schedule
The duration for which the inference experiment ran or will run.
The maximum duration that you can set for an inference experiment is 30 days.
- shadow_mode_config
The configuration of
ShadowMode
inference experiment type, which shows the production variant that takes all the inference requests, and the shadow variant to which Amazon SageMaker replicates a percentage of the inference requests.For the shadow variant it also shows the percentage of requests that Amazon SageMaker replicates.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- status_reason
The error message for the inference experiment status result.
- type
The type of the inference experiment.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
CaptureContentTypeHeaderProperty
- class CfnInferenceExperiment.CaptureContentTypeHeaderProperty(*, csv_content_types=None, json_content_types=None)
Bases:
object
Configuration specifying how to treat different headers.
If no headers are specified SageMaker will by default base64 encode when capturing the data.
- Parameters:
csv_content_types (
Optional
[Sequence
[str
]]) – The list of all content type headers that SageMaker will treat as CSV and capture accordingly.json_content_types (
Optional
[Sequence
[str
]]) – The list of all content type headers that SageMaker will treat as JSON and capture accordingly.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker capture_content_type_header_property = sagemaker.CfnInferenceExperiment.CaptureContentTypeHeaderProperty( csv_content_types=["csvContentTypes"], json_content_types=["jsonContentTypes"] )
Attributes
- csv_content_types
The list of all content type headers that SageMaker will treat as CSV and capture accordingly.
- json_content_types
The list of all content type headers that SageMaker will treat as JSON and capture accordingly.
DataStorageConfigProperty
- class CfnInferenceExperiment.DataStorageConfigProperty(*, destination, content_type=None, kms_key=None)
Bases:
object
The Amazon S3 location and configuration for storing inference request and response data.
This is an optional parameter that you can use for data capture. For more information, see Capture data .
- Parameters:
destination (
str
) – The Amazon S3 bucket where the inference request and response data is stored.content_type (
Union
[IResolvable
,CaptureContentTypeHeaderProperty
,Dict
[str
,Any
],None
]) – Configuration specifying how to treat different headers. If no headers are specified SageMaker will by default base64 encode when capturing the data.kms_key (
Optional
[str
]) – The AWS Key Management Service key that Amazon SageMaker uses to encrypt captured data at rest using Amazon S3 server-side encryption.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker data_storage_config_property = sagemaker.CfnInferenceExperiment.DataStorageConfigProperty( destination="destination", # the properties below are optional content_type=sagemaker.CfnInferenceExperiment.CaptureContentTypeHeaderProperty( csv_content_types=["csvContentTypes"], json_content_types=["jsonContentTypes"] ), kms_key="kmsKey" )
Attributes
- content_type
Configuration specifying how to treat different headers.
If no headers are specified SageMaker will by default base64 encode when capturing the data.
- destination
The Amazon S3 bucket where the inference request and response data is stored.
- kms_key
The AWS Key Management Service key that Amazon SageMaker uses to encrypt captured data at rest using Amazon S3 server-side encryption.
EndpointMetadataProperty
- class CfnInferenceExperiment.EndpointMetadataProperty(*, endpoint_name, endpoint_config_name=None, endpoint_status=None)
Bases:
object
The metadata of the endpoint.
- Parameters:
endpoint_name (
str
) – The name of the endpoint.endpoint_config_name (
Optional
[str
]) – The name of the endpoint configuration.endpoint_status (
Optional
[str
]) – The status of the endpoint. For possible values of the status of an endpoint, see ` <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-inferenceexperiment-endpointmetadata.html#cfn-sagemaker-inferenceexperiment-endpointmetadata-endpointstatus>`_ .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker endpoint_metadata_property = sagemaker.CfnInferenceExperiment.EndpointMetadataProperty( endpoint_name="endpointName", # the properties below are optional endpoint_config_name="endpointConfigName", endpoint_status="endpointStatus" )
Attributes
- endpoint_config_name
The name of the endpoint configuration.
- endpoint_name
The name of the endpoint.
- endpoint_status
The status of the endpoint.
For possible values of the status of an endpoint, see ` <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-inferenceexperiment-endpointmetadata.html#cfn-sagemaker-inferenceexperiment-endpointmetadata-endpointstatus>`_ .
InferenceExperimentScheduleProperty
- class CfnInferenceExperiment.InferenceExperimentScheduleProperty(*, end_time=None, start_time=None)
Bases:
object
The start and end times of an inference experiment.
The maximum duration that you can set for an inference experiment is 30 days.
- Parameters:
end_time (
Optional
[str
]) – The timestamp at which the inference experiment ended or will end.start_time (
Optional
[str
]) – The timestamp at which the inference experiment started or will start.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker inference_experiment_schedule_property = sagemaker.CfnInferenceExperiment.InferenceExperimentScheduleProperty( end_time="endTime", start_time="startTime" )
Attributes
- end_time
The timestamp at which the inference experiment ended or will end.
- start_time
The timestamp at which the inference experiment started or will start.
ModelInfrastructureConfigProperty
- class CfnInferenceExperiment.ModelInfrastructureConfigProperty(*, infrastructure_type, real_time_inference_config)
Bases:
object
The configuration for the infrastructure that the model will be deployed to.
- Parameters:
infrastructure_type (
str
) – The inference option to which to deploy your model. Possible values are the following:. -RealTime
: Deploy to real-time inference.real_time_inference_config (
Union
[IResolvable
,RealTimeInferenceConfigProperty
,Dict
[str
,Any
]]) – The infrastructure configuration for deploying the model to real-time inference.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker model_infrastructure_config_property = sagemaker.CfnInferenceExperiment.ModelInfrastructureConfigProperty( infrastructure_type="infrastructureType", real_time_inference_config=sagemaker.CfnInferenceExperiment.RealTimeInferenceConfigProperty( instance_count=123, instance_type="instanceType" ) )
Attributes
- infrastructure_type
.
RealTime
: Deploy to real-time inference.
- Link:
- Type:
The inference option to which to deploy your model. Possible values are the following
- real_time_inference_config
The infrastructure configuration for deploying the model to real-time inference.
ModelVariantConfigProperty
- class CfnInferenceExperiment.ModelVariantConfigProperty(*, infrastructure_config, model_name, variant_name)
Bases:
object
Contains information about the deployment options of a model.
- Parameters:
infrastructure_config (
Union
[IResolvable
,ModelInfrastructureConfigProperty
,Dict
[str
,Any
]]) – The configuration for the infrastructure that the model will be deployed to.model_name (
str
) – The name of the Amazon SageMaker Model entity.variant_name (
str
) – The name of the variant.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker model_variant_config_property = sagemaker.CfnInferenceExperiment.ModelVariantConfigProperty( infrastructure_config=sagemaker.CfnInferenceExperiment.ModelInfrastructureConfigProperty( infrastructure_type="infrastructureType", real_time_inference_config=sagemaker.CfnInferenceExperiment.RealTimeInferenceConfigProperty( instance_count=123, instance_type="instanceType" ) ), model_name="modelName", variant_name="variantName" )
Attributes
- infrastructure_config
The configuration for the infrastructure that the model will be deployed to.
- model_name
The name of the Amazon SageMaker Model entity.
RealTimeInferenceConfigProperty
- class CfnInferenceExperiment.RealTimeInferenceConfigProperty(*, instance_count, instance_type)
Bases:
object
The infrastructure configuration for deploying the model to a real-time inference endpoint.
- Parameters:
instance_count (
Union
[int
,float
]) – The number of instances of the type specified byInstanceType
.instance_type (
str
) – The instance type the model is deployed to.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker real_time_inference_config_property = sagemaker.CfnInferenceExperiment.RealTimeInferenceConfigProperty( instance_count=123, instance_type="instanceType" )
Attributes
- instance_count
The number of instances of the type specified by
InstanceType
.
- instance_type
The instance type the model is deployed to.
ShadowModeConfigProperty
- class CfnInferenceExperiment.ShadowModeConfigProperty(*, shadow_model_variants, source_model_variant_name)
Bases:
object
The configuration of
ShadowMode
inference experiment type, which specifies a production variant to take all the inference requests, and a shadow variant to which Amazon SageMaker replicates a percentage of the inference requests.For the shadow variant it also specifies the percentage of requests that Amazon SageMaker replicates.
- Parameters:
shadow_model_variants (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ShadowModelVariantConfigProperty
,Dict
[str
,Any
]]]]) – List of shadow variant configurations.source_model_variant_name (
str
) – The name of the production variant, which takes all the inference requests.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker shadow_mode_config_property = sagemaker.CfnInferenceExperiment.ShadowModeConfigProperty( shadow_model_variants=[sagemaker.CfnInferenceExperiment.ShadowModelVariantConfigProperty( sampling_percentage=123, shadow_model_variant_name="shadowModelVariantName" )], source_model_variant_name="sourceModelVariantName" )
Attributes
- shadow_model_variants
List of shadow variant configurations.
- source_model_variant_name
The name of the production variant, which takes all the inference requests.
ShadowModelVariantConfigProperty
- class CfnInferenceExperiment.ShadowModelVariantConfigProperty(*, sampling_percentage, shadow_model_variant_name)
Bases:
object
The name and sampling percentage of a shadow variant.
- Parameters:
sampling_percentage (
Union
[int
,float
]) – The percentage of inference requests that Amazon SageMaker replicates from the production variant to the shadow variant.shadow_model_variant_name (
str
) – The name of the shadow variant.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_sagemaker as sagemaker shadow_model_variant_config_property = sagemaker.CfnInferenceExperiment.ShadowModelVariantConfigProperty( sampling_percentage=123, shadow_model_variant_name="shadowModelVariantName" )
Attributes
- sampling_percentage
The percentage of inference requests that Amazon SageMaker replicates from the production variant to the shadow variant.
- shadow_model_variant_name
The name of the shadow variant.