create_compilation_job(
*,
config_overrides: Optional[AsyncSageMakerClientConfig] = None,
compilation_job_name: Optional[EntityName] = None,
role_arn: Optional[RoleArn] = None,
model_package_version_arn: Optional[ModelPackageArn] = None,
input_config: Optional[InputConfig] = None,
output_config: Optional[OutputConfig] = None,
vpc_config: Optional[NeoVpcConfig] = None,
stopping_condition: Optional[StoppingCondition] = None,
tags: Optional[TagList] = None,
) -> CreateCompilationJobResponse
Starts a model compilation job. After the model has been compiled, Amazon SageMaker AI saves the resulting model artifacts to an Amazon Simple Storage Service (Amazon S3) bucket that you specify.
If you choose to host your model using Amazon SageMaker AI hosting services, you can use the resulting model artifacts as part of the model. You can also use the artifacts with Amazon Web Services IoT Greengrass. In that case, deploy them as an ML resource.
In the request body, you provide the following:
-
A name for the compilation job
-
Information about the input model artifacts
-
The output location for the compiled model and the device (target) that the model runs on
-
The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker AI assumes to perform the model compilation job.
You can also provide a Tag to track the model compilation job's resource use and costs. The response body contains the CompilationJobArn for the compiled job.
To stop a model compilation job, use StopCompilationJob. To get information about a particular model compilation job, use DescribeCompilationJob. To get information about multiple model compilation jobs, use ListCompilationJobs.
Parameters:
-
compilation_job_name
(Optional[EntityName], default:
None
)
–
A name for the model compilation job. The name must be unique within the Amazon Web Services Region and within your Amazon Web Services account.
-
role_arn
(Optional[RoleArn], default:
None
)
–
The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker AI to perform tasks on your behalf.
During model compilation, Amazon SageMaker AI needs your permission to:
-
Read input data from an S3 bucket
-
Write model artifacts to an S3 bucket
-
Write logs to Amazon CloudWatch Logs
-
Publish metrics to Amazon CloudWatch
You grant permissions for all of these tasks to an IAM role. To pass this role to Amazon SageMaker AI, the caller of this API must have the iam:PassRole permission. For more information, see Amazon SageMaker AI Roles.
-
model_package_version_arn
(Optional[ModelPackageArn], default:
None
)
–
The Amazon Resource Name (ARN) of a versioned model package. Provide either a ModelPackageVersionArn or an InputConfig object in the request syntax. The presence of both objects in the CreateCompilationJob request will return an exception.
-
input_config
(Optional[InputConfig], default:
None
)
–
Provides information about the location of input model artifacts, the name and shape of the expected data inputs, and the framework in which the model was trained.
-
output_config
(Optional[OutputConfig], default:
None
)
–
Provides information about the output location for the compiled model and the target device the model runs on.
-
vpc_config
(Optional[NeoVpcConfig], default:
None
)
–
-
stopping_condition
(Optional[StoppingCondition], default:
None
)
–
Specifies a limit to how long a model compilation job can run. When the job reaches the time limit, Amazon SageMaker AI ends the compilation job. Use this API to cap model training costs.
-
tags
(Optional[TagList], default:
None
)
–
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.
Raises:
-
ResourceInUse
–
Resource being accessed is in use.
-
ResourceLimitExceeded
–
You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_sagemaker/_services/async_sage_maker.py
| async def create_compilation_job(
self,
*,
config_overrides: Optional[AsyncSageMakerClientConfig] = None,
compilation_job_name: Optional[
"capo_sagemaker.types.entity_name.EntityName"
] = None,
role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
model_package_version_arn: Optional[
"capo_sagemaker.types.model_package_arn.ModelPackageArn"
] = None,
input_config: Optional["capo_sagemaker.types.input_config.InputConfig"] = None,
output_config: Optional[
"capo_sagemaker.types.output_config.OutputConfig"
] = None,
vpc_config: Optional["capo_sagemaker.types.neo_vpc_config.NeoVpcConfig"] = None,
stopping_condition: Optional[
"capo_sagemaker.types.stopping_condition.StoppingCondition"
] = None,
tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_compilation_job_response.CreateCompilationJobResponse":
"""<p>Starts a model compilation job. After the model has been compiled, Amazon SageMaker AI saves the resulting model artifacts to an Amazon Simple Storage Service (Amazon S3) bucket that you specify. </p> <p>If you choose to host your model using Amazon SageMaker AI hosting services, you can use the resulting model artifacts as part of the model. You can also use the artifacts with Amazon Web Services IoT Greengrass. In that case, deploy them as an ML resource.</p> <p>In the request body, you provide the following:</p> <ul> <li> <p>A name for the compilation job</p> </li> <li> <p> Information about the input model artifacts </p> </li> <li> <p>The output location for the compiled model and the device (target) that the model runs on </p> </li> <li> <p>The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker AI assumes to perform the model compilation job. </p> </li> </ul> <p>You can also provide a <code>Tag</code> to track the model compilation job's resource use and costs. The response body contains the <code>CompilationJobArn</code> for the compiled job.</p> <p>To stop a model compilation job, use <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_StopCompilationJob.html">StopCompilationJob</a>. To get information about a particular model compilation job, use <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeCompilationJob.html">DescribeCompilationJob</a>. To get information about multiple model compilation jobs, use <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ListCompilationJobs.html">ListCompilationJobs</a>.</p>
Args:
compilation_job_name: <p>A name for the model compilation job. The name must be unique within the Amazon Web Services Region and within your Amazon Web Services account. </p>
role_arn: <p>The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker AI to perform tasks on your behalf. </p> <p>During model compilation, Amazon SageMaker AI needs your permission to:</p> <ul> <li> <p>Read input data from an S3 bucket</p> </li> <li> <p>Write model artifacts to an S3 bucket</p> </li> <li> <p>Write logs to Amazon CloudWatch Logs</p> </li> <li> <p>Publish metrics to Amazon CloudWatch</p> </li> </ul> <p>You grant permissions for all of these tasks to an IAM role. To pass this role to Amazon SageMaker AI, the caller of this API must have the <code>iam:PassRole</code> permission. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html">Amazon SageMaker AI Roles.</a> </p>
model_package_version_arn: <p>The Amazon Resource Name (ARN) of a versioned model package. Provide either a <code>ModelPackageVersionArn</code> or an <code>InputConfig</code> object in the request syntax. The presence of both objects in the <code>CreateCompilationJob</code> request will return an exception.</p>
input_config: <p>Provides information about the location of input model artifacts, the name and shape of the expected data inputs, and the framework in which the model was trained.</p>
output_config: <p>Provides information about the output location for the compiled model and the target device the model runs on.</p>
vpc_config: <p>A <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_VpcConfig.html">VpcConfig</a> object that specifies the VPC that you want your compilation job to connect to. Control access to your models by configuring the VPC. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/neo-vpc.html">Protect Compilation Jobs by Using an Amazon Virtual Private Cloud</a>.</p>
stopping_condition: <p>Specifies a limit to how long a model compilation job can run. When the job reaches the time limit, Amazon SageMaker AI ends the compilation job. Use this API to cap model training costs.</p>
tags: <p>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 <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a>.</p>
Raises:
capo_sagemaker.errors.resource_in_use.ResourceInUse: <p>Resource being accessed is in use.</p>
capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_sagemaker.types.create_compilation_job_request.CreateCompilationJobRequest]",
) -> AsyncOperationResponse[
"capo_sagemaker.types.create_compilation_job_response.CreateCompilationJobResponse"
]:
import capo_sagemaker._operations.sage_maker.create_compilation_job
(
output,
http_response,
) = await capo_sagemaker._operations.sage_maker.create_compilation_job.async_create_compilation_job(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateCompilationJob")
)
input_: capo_sagemaker.types.create_compilation_job_request.CreateCompilationJobRequest = {}
if compilation_job_name is not None:
input_["compilation_job_name"] = compilation_job_name
if role_arn is not None:
input_["role_arn"] = role_arn
if model_package_version_arn is not None:
input_["model_package_version_arn"] = model_package_version_arn
if input_config is not None:
input_["input_config"] = input_config
if output_config is not None:
input_["output_config"] = output_config
if vpc_config is not None:
input_["vpc_config"] = vpc_config
if stopping_condition is not None:
input_["stopping_condition"] = stopping_condition
if tags is not None:
input_["tags"] = tags
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|