Skip to content

Commit

Permalink
Merge branch 'main' into peterwoodworth/warningFix
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Apr 12, 2023
2 parents 2ea8d60 + 91553e5 commit b86475a
Show file tree
Hide file tree
Showing 200 changed files with 825 additions and 3,778 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-cdk.git",
"directory": "packages/@aws-cdk/aws-iot-actions"
"directory": "packages/@aws-cdk/aws-iot-actions-alpha"
},
"scripts": {
"build": "cdk-build",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-cdk.git",
"directory": "packages/@aws-cdk/aws-neptune"
"directory": "packages/@aws-cdk/aws-neptune-alpha"
},
"homepage": "https://github.com/aws/aws-cdk",
"scripts": {
Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-sagemaker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ const repository = ecr.Repository.fromRepositoryName(this, 'Repository', 'repo')
const image = sagemaker.ContainerImage.fromEcrRepository(repository, 'tag');
```

#### DLC Image

Reference a deep learning container image:

```typescript
import * as sagemaker from '@aws-cdk/aws-sagemaker-alpha';

const repositoryName = 'huggingface-pytorch-training';
const tag = '1.13.1-transformers4.26.0-gpu-py39-cu117-ubuntu20.04';

const image = sagemaker.ContainerImage.fromDlc(repositoryName, tag);
```

### Model Artifacts

If you choose to decouple your model artifacts from your inference code (as is natural given
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/aws-sagemaker/lib/container-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as assets from 'aws-cdk-lib/aws-ecr-assets';
import { Construct } from 'constructs';
import { Model } from './model';
import { hashcode } from './private/util';
import { FactName } from 'aws-cdk-lib/region-info';
import { Stack } from 'aws-cdk-lib/core';

/**
* The configuration for creating a container image.
Expand Down Expand Up @@ -38,6 +40,13 @@ export abstract class ContainerImage {
return new AssetImage(directory, options);
}

/**
* Reference an AWS Deep Learning Container image
*/
public static fromDlc(repositoryName: string, tag: string, accountId?: string): ContainerImage {
return new DlcEcrImage(repositoryName, tag, accountId);
}

/**
* Called when the image is used by a Model
*/
Expand Down Expand Up @@ -81,3 +90,27 @@ class AssetImage extends ContainerImage {
};
}
}

class DlcEcrImage extends ContainerImage {

constructor(private readonly repositoryName: string, private readonly tag: string, private readonly accountId?: string) {
super();
}

public bind(scope: Construct, model: Model): ContainerImageConfig {
const accountId = this.accountId ?? Stack.of(scope).regionalFact(FactName.DLC_REPOSITORY_ACCOUNT);

const repository = ecr.Repository.fromRepositoryAttributes(scope, 'DlcRepository', {
repositoryName: this.repositoryName,
repositoryArn: ecr.Repository.arnForLocalRepository(
this.repositoryName,
scope,
accountId,
),
});

repository.grantPull(model);

return { imageName: `${repository.repositoryUri}:${this.tag}` };
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "31.0.0",
"files": {
"126d48fa0e32fbef5078b9d88658b35ad29d4291eb86675a64c75fa4f1338916": {
"source": {
Expand All @@ -14,15 +14,15 @@
}
}
},
"eebf956b730b436212d72ff616d7ab38ac8a7c128b71f54c4e9d1f0d29b36604": {
"be0577003620b4cc844de880dc7d01b90719400dea1cc12c03d93a3ac8e451a3": {
"source": {
"path": "aws-cdk-sagemaker-model.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "eebf956b730b436212d72ff616d7ab38ac8a7c128b71f54c4e9d1f0d29b36604.json",
"objectKey": "be0577003620b4cc844de880dc7d01b90719400dea1cc12c03d93a3ac8e451a3.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,198 @@
"InferencePipelineModelRoleDefaultPolicy2AF0CDCF",
"InferencePipelineModelRole6A99C5B3"
]
},
"HuggingFaceModelRoleDA17DA00": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "sagemaker.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/AmazonSageMakerFullAccess"
]
]
}
]
}
},
"HuggingFaceModelRoleDefaultPolicy50587D35": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
],
"Effect": "Allow",
"Resource": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":ecr:",
{
"Ref": "AWS::Region"
},
":",
{
"Fn::FindInMap": [
"DlcRepositoryAccountMap",
{
"Ref": "AWS::Region"
},
"value"
]
},
":repository/huggingface-pytorch-training"
]
]
}
},
{
"Action": "ecr:GetAuthorizationToken",
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "HuggingFaceModelRoleDefaultPolicy50587D35",
"Roles": [
{
"Ref": "HuggingFaceModelRoleDA17DA00"
}
]
}
},
"HuggingFaceModel8E13DAA5": {
"Type": "AWS::SageMaker::Model",
"Properties": {
"ExecutionRoleArn": {
"Fn::GetAtt": [
"HuggingFaceModelRoleDA17DA00",
"Arn"
]
},
"PrimaryContainer": {
"Image": {
"Fn::Join": [
"",
[
{
"Fn::FindInMap": [
"DlcRepositoryAccountMap",
{
"Ref": "AWS::Region"
},
"value"
]
},
".dkr.ecr.",
{
"Ref": "AWS::Region"
},
".",
{
"Ref": "AWS::URLSuffix"
},
"/huggingface-pytorch-training:1.13.1-transformers4.26.0-gpu-py39-cu117-ubuntu20.04"
]
]
}
}
},
"DependsOn": [
"HuggingFaceModelRoleDefaultPolicy50587D35",
"HuggingFaceModelRoleDA17DA00"
]
}
},
"Mappings": {
"DlcRepositoryAccountMap": {
"ap-east-1": {
"value": "871362719292"
},
"ap-northeast-1": {
"value": "763104351884"
},
"ap-northeast-2": {
"value": "763104351884"
},
"ap-south-1": {
"value": "763104351884"
},
"ap-southeast-1": {
"value": "763104351884"
},
"ap-southeast-2": {
"value": "763104351884"
},
"ca-central-1": {
"value": "763104351884"
},
"cn-north-1": {
"value": "727897471807"
},
"cn-northwest-1": {
"value": "727897471807"
},
"eu-central-1": {
"value": "763104351884"
},
"eu-north-1": {
"value": "763104351884"
},
"eu-west-1": {
"value": "763104351884"
},
"eu-west-2": {
"value": "763104351884"
},
"eu-west-3": {
"value": "763104351884"
},
"me-south-1": {
"value": "217643126080"
},
"sa-east-1": {
"value": "763104351884"
},
"us-east-1": {
"value": "763104351884"
},
"us-east-2": {
"value": "763104351884"
},
"us-west-1": {
"value": "763104351884"
},
"us-west-2": {
"value": "763104351884"
}
}
},
"Parameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"31.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "31.0.0",
"testCases": {
"integtest-model/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "31.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Loading

0 comments on commit b86475a

Please sign in to comment.