import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages an AWS SageMaker AI Algorithm. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.sagemaker.Algorithm("example", { * trainingSpecification: { * trainingChannels: [{ * name: "train", * supportedContentTypes: ["text/csv"], * supportedInputModes: ["File"], * }], * supportedTrainingInstanceTypes: ["ml.m5.large"], * trainingImage: "123456789012.dkr.ecr.us-west-2.amazonaws.com/example-training:latest", * }, * algorithmName: "example-algorithm", * tags: { * Environment: "test", * }, * }); * ``` * * ### Training Specification * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.sagemaker.getPrebuiltEcrImage({ * repositoryName: "linear-learner", * imageTag: "1", * }); * const exampleAlgorithm = new aws.sagemaker.Algorithm("example", { * trainingSpecification: { * metricDefinitions: [{ * name: "train:loss", * regex: "loss=(.*?);", * }], * supportedHyperParameters: [ * { * range: { * continuousParameterRangeSpecification: { * minValue: "0.1", * maxValue: "0.9", * }, * }, * defaultValue: "0.5", * description: "Continuous learning rate", * isRequired: true, * isTunable: true, * name: "eta", * type: "Continuous", * }, * { * range: { * integerParameterRangeSpecification: { * minValue: "1", * maxValue: "10", * }, * }, * defaultValue: "5", * description: "Maximum tree depth", * isRequired: false, * isTunable: true, * name: "max_depth", * type: "Integer", * }, * { * range: { * categoricalParameterRangeSpecification: { * values: [ * "reg:squarederror", * "binary:logistic", * ], * }, * }, * defaultValue: "reg:squarederror", * description: "Objective function", * isRequired: false, * isTunable: false, * name: "objective", * type: "Categorical", * }, * ], * supportedTuningJobObjectiveMetrics: [{ * metricName: "train:loss", * type: "Minimize", * }], * trainingChannels: [ * { * description: "Training data channel", * isRequired: true, * name: "train", * supportedCompressionTypes: [ * "None", * "Gzip", * ], * supportedContentTypes: ["text/csv"], * supportedInputModes: ["File"], * }, * { * name: "validation", * supportedContentTypes: ["application/json"], * supportedInputModes: ["Pipe"], * }, * ], * supportedTrainingInstanceTypes: [ * "ml.m5.large", * "ml.c5.xlarge", * ], * supportsDistributedTraining: true, * trainingImage: example.then(example => example.registryPath), * }, * algorithmName: "example-training-algorithm", * }); * ``` * * ### Inference Specification * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.sagemaker.getPrebuiltEcrImage({ * repositoryName: "linear-learner", * imageTag: "1", * }); * const exampleAlgorithm = new aws.sagemaker.Algorithm("example", { * trainingSpecification: { * trainingChannels: [{ * name: "train", * supportedContentTypes: ["text/csv"], * supportedInputModes: ["File"], * }], * supportedTrainingInstanceTypes: ["ml.m5.large"], * trainingImage: example.then(example => example.registryPath), * }, * inferenceSpecification: { * containers: [{ * baseModel: { * hubContentName: "basemodel", * hubContentVersion: "1.0.0", * recipeName: "recipe", * }, * modelInput: { * dataInputConfig: "{}", * }, * containerHostname: "test-host", * environment: { * TEST: "value", * }, * framework: "XGBOOST", * frameworkVersion: "1.5-1", * image: example.then(example => example.registryPath), * isCheckpoint: true, * nearestModelName: "nearest-model", * }], * supportedContentTypes: ["text/csv"], * supportedRealtimeInferenceInstanceTypes: ["ml.m5.large"], * supportedResponseMimeTypes: ["text/csv"], * supportedTransformInstanceTypes: ["ml.m5.large"], * }, * algorithmName: "example-inference-algorithm", * }); * ``` * * ### Validation Specification * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const current = aws.getPartition({}); * const example = aws.sagemaker.getPrebuiltEcrImage({ * repositoryName: "linear-learner", * imageTag: "1", * }); * const assumeRole = current.then(current => aws.iam.getPolicyDocument({ * statements: [{ * principals: [{ * type: "Service", * identifiers: [`sagemaker.${current.dnsSuffix}`], * }], * actions: ["sts:AssumeRole"], * }], * })); * const exampleRole = new aws.iam.Role("example", { * name: "example-sagemaker-algorithm-role", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const exampleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("example", { * role: exampleRole.name, * policyArn: current.then(current => `arn:${current.partition}:iam::aws:policy/AmazonSageMakerFullAccess`), * }); * const exampleBucket = new aws.s3.Bucket("example", { * bucket: "example-sagemaker-algorithm-validation-bucket", * forceDestroy: true, * }); * const s3Access = aws.iam.getPolicyDocumentOutput({ * statements: [{ * effect: "Allow", * actions: [ * "s3:GetBucketLocation", * "s3:ListBucket", * "s3:GetObject", * "s3:PutObject", * ], * resources: [ * exampleBucket.arn, * pulumi.interpolate`${exampleBucket.arn}/*`, * ], * }], * }); * const exampleRolePolicy = new aws.iam.RolePolicy("example", { * role: exampleRole.name, * policy: s3Access.json, * }); * const training = new aws.s3.BucketObjectv2("training", { * bucket: exampleBucket.bucket, * key: "algorithm/training/data.csv", * content: `1,1.0,0.0 * 0,0.0,1.0 * 1,1.0,1.0 * 0,0.0,0.0 * `, * }); * const transform = new aws.s3.BucketObjectv2("transform", { * bucket: exampleBucket.bucket, * key: "algorithm/transform/input.csv", * content: `1.0,0.0 * 0.0,1.0 * `, * }); * const exampleAlgorithm = new aws.sagemaker.Algorithm("example", { * trainingSpecification: { * supportedHyperParameters: [ * { * range: { * integerParameterRangeSpecification: { * minValue: "2", * maxValue: "2", * }, * }, * defaultValue: "2", * description: "Feature dimension", * isRequired: true, * isTunable: false, * name: "feature_dim", * type: "Integer", * }, * { * range: { * integerParameterRangeSpecification: { * minValue: "4", * maxValue: "4", * }, * }, * defaultValue: "4", * description: "Mini batch size", * isRequired: true, * isTunable: false, * name: "mini_batch_size", * type: "Integer", * }, * { * range: { * categoricalParameterRangeSpecification: { * values: ["binary_classifier"], * }, * }, * defaultValue: "binary_classifier", * description: "Predictor type", * isRequired: true, * isTunable: false, * name: "predictor_type", * type: "Categorical", * }, * ], * trainingChannels: [{ * name: "train", * supportedContentTypes: ["text/csv"], * supportedInputModes: ["File"], * }], * trainingImage: example.then(example => example.registryPath), * supportedTrainingInstanceTypes: ["ml.m5.large"], * }, * inferenceSpecification: { * containers: [{ * image: example.then(example => example.registryPath), * }], * supportedContentTypes: ["text/csv"], * supportedResponseMimeTypes: ["text/csv"], * supportedTransformInstanceTypes: ["ml.m5.large"], * }, * validationSpecification: { * validationProfiles: { * trainingJobDefinition: { * outputDataConfig: { * compressionType: "GZIP", * s3OutputPath: pulumi.interpolate`s3://${exampleBucket.bucket}/algorithm/output`, * }, * resourceConfig: { * instanceCount: 1, * instanceType: "ml.m5.large", * keepAlivePeriodInSeconds: 60, * volumeSizeInGb: 30, * }, * stoppingCondition: { * maxPendingTimeInSeconds: 7200, * maxRuntimeInSeconds: 1800, * maxWaitTimeInSeconds: 3600, * }, * inputDataConfigs: [{ * shuffleConfig: { * seed: 1, * }, * dataSource: { * s3DataSource: { * attributeNames: ["label"], * s3DataDistributionType: "ShardedByS3Key", * s3DataType: "S3Prefix", * s3Uri: pulumi.interpolate`s3://${exampleBucket.bucket}/algorithm/training/`, * }, * }, * channelName: "train", * compressionType: "None", * contentType: "text/csv", * inputMode: "File", * recordWrapperType: "None", * }], * hyperParameters: { * feature_dim: "2", * mini_batch_size: "4", * predictor_type: "binary_classifier", * }, * trainingInputMode: "File", * }, * transformJobDefinition: { * transformInput: { * dataSource: { * s3DataSource: { * s3DataType: "S3Prefix", * s3Uri: pulumi.interpolate`s3://${exampleBucket.bucket}/algorithm/transform/`, * }, * }, * compressionType: "None", * contentType: "text/csv", * splitType: "Line", * }, * transformOutput: { * accept: "text/csv", * assembleWith: "Line", * s3OutputPath: pulumi.interpolate`s3://${exampleBucket.bucket}/algorithm/transform-output`, * }, * transformResources: { * instanceCount: 1, * instanceType: "ml.m5.large", * }, * batchStrategy: "MultiRecord", * environment: { * Te: "enabled", * }, * maxConcurrentTransforms: 1, * maxPayloadInMb: 6, * }, * profileName: "validation-profile", * }, * validationRole: exampleRole.arn, * }, * algorithmName: "example-validation-algorithm", * }, { * dependsOn: [ * exampleRolePolicyAttachment, * exampleRolePolicy, * training, * transform, * ], * }); * ``` * * ## Import * * ### Identity Schema * * #### Required * * * `algorithmName` - (String) Name of the algorithm. * * #### Optional * * * `accountId` - (String) AWS account where this resource is managed. * * `region` - (String) Region where this resource is managed. * * Using `pulumi import`, import SageMaker AI Algorithms using `algorithmName`. For example: * * ```sh * $ pulumi import aws:sagemaker/algorithm:Algorithm example example-algorithm * ``` */ export declare class Algorithm extends pulumi.CustomResource { /** * Get an existing Algorithm resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: AlgorithmState, opts?: pulumi.CustomResourceOptions): Algorithm; /** * Returns true if the given object is an instance of Algorithm. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Algorithm; /** * Description of the algorithm. */ readonly algorithmDescription: pulumi.Output; /** * Name of the algorithm. */ readonly algorithmName: pulumi.Output; /** * Status of the algorithm. */ readonly algorithmStatus: pulumi.Output; /** * ARN of the algorithm. */ readonly arn: pulumi.Output; /** * Whether to certify the algorithm for AWS Marketplace. */ readonly certifyForMarketplace: pulumi.Output; /** * Time when the algorithm was created, in RFC3339 format. */ readonly creationTime: pulumi.Output; /** * Configuration for inference jobs that use this algorithm. See Inference Specification. */ readonly inferenceSpecification: pulumi.Output; /** * AWS Marketplace product ID associated with the algorithm. */ readonly productId: pulumi.Output; /** * Region where this resource is managed. Defaults to the Region set in the provider configuration. */ readonly region: pulumi.Output; /** * Map of tags to assign to the resource. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Map of tags assigned to the resource, including tags inherited from the provider `defaultTags` configuration block. */ readonly tagsAll: pulumi.Output<{ [key: string]: string; }>; readonly timeouts: pulumi.Output; /** * Configuration for training jobs that use this algorithm. See Training Specification. */ readonly trainingSpecification: pulumi.Output; /** * Configuration used to validate the algorithm. See Validation Specification. */ readonly validationSpecification: pulumi.Output; /** * Create a Algorithm resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: AlgorithmArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Algorithm resources. */ export interface AlgorithmState { /** * Description of the algorithm. */ algorithmDescription?: pulumi.Input; /** * Name of the algorithm. */ algorithmName?: pulumi.Input; /** * Status of the algorithm. */ algorithmStatus?: pulumi.Input; /** * ARN of the algorithm. */ arn?: pulumi.Input; /** * Whether to certify the algorithm for AWS Marketplace. */ certifyForMarketplace?: pulumi.Input; /** * Time when the algorithm was created, in RFC3339 format. */ creationTime?: pulumi.Input; /** * Configuration for inference jobs that use this algorithm. See Inference Specification. */ inferenceSpecification?: pulumi.Input; /** * AWS Marketplace product ID associated with the algorithm. */ productId?: pulumi.Input; /** * Region where this resource is managed. Defaults to the Region set in the provider configuration. */ region?: pulumi.Input; /** * Map of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; } | undefined>; /** * Map of tags assigned to the resource, including tags inherited from the provider `defaultTags` configuration block. */ tagsAll?: pulumi.Input<{ [key: string]: pulumi.Input; } | undefined>; timeouts?: pulumi.Input; /** * Configuration for training jobs that use this algorithm. See Training Specification. */ trainingSpecification?: pulumi.Input; /** * Configuration used to validate the algorithm. See Validation Specification. */ validationSpecification?: pulumi.Input; } /** * The set of arguments for constructing a Algorithm resource. */ export interface AlgorithmArgs { /** * Description of the algorithm. */ algorithmDescription?: pulumi.Input; /** * Name of the algorithm. */ algorithmName: pulumi.Input; /** * Whether to certify the algorithm for AWS Marketplace. */ certifyForMarketplace?: pulumi.Input; /** * Configuration for inference jobs that use this algorithm. See Inference Specification. */ inferenceSpecification?: pulumi.Input; /** * Region where this resource is managed. Defaults to the Region set in the provider configuration. */ region?: pulumi.Input; /** * Map of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; } | undefined>; timeouts?: pulumi.Input; /** * Configuration for training jobs that use this algorithm. See Training Specification. */ trainingSpecification: pulumi.Input; /** * Configuration used to validate the algorithm. See Validation Specification. */ validationSpecification?: pulumi.Input; } //# sourceMappingURL=algorithm.d.ts.map