createCompilationJob method
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.
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.
May throw ResourceInUse.
May throw ResourceLimitExceeded.
Parameter compilationJobName :
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.
Parameter outputConfig :
Provides information about the output location for the compiled model and
the target device the model runs on.
Parameter roleArn :
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
iam:PassRole permission. For more information, see Amazon
SageMaker AI Roles.
Parameter stoppingCondition :
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.
Parameter inputConfig :
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.
Parameter modelPackageVersionArn :
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.
Parameter tags :
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.
Parameter vpcConfig :
A VpcConfig
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 Protect
Compilation Jobs by Using an Amazon Virtual Private Cloud.
Implementation
Future<CreateCompilationJobResponse> createCompilationJob({
required String compilationJobName,
required OutputConfig outputConfig,
required String roleArn,
required StoppingCondition stoppingCondition,
InputConfig? inputConfig,
String? modelPackageVersionArn,
List<Tag>? tags,
NeoVpcConfig? vpcConfig,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'SageMaker.CreateCompilationJob'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'CompilationJobName': compilationJobName,
'OutputConfig': outputConfig,
'RoleArn': roleArn,
'StoppingCondition': stoppingCondition,
if (inputConfig != null) 'InputConfig': inputConfig,
if (modelPackageVersionArn != null)
'ModelPackageVersionArn': modelPackageVersionArn,
if (tags != null) 'Tags': tags,
if (vpcConfig != null) 'VpcConfig': vpcConfig,
},
);
return CreateCompilationJobResponse.fromJson(jsonResponse.body);
}