Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix too long resource name #124

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rag-engines/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class RagEngines extends Construct {

const sageMakerRagModels = new SageMakerRagModels(
this,
"SageMakerRagModels",
"SageMaker",
{
shared: props.shared,
config: props.config,
Expand Down
13 changes: 11 additions & 2 deletions lib/sagemaker-model/deploy-custom-script-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Construct } from "constructs";

import { HuggingFaceCustomScriptModel } from "./hf-custom-script-model";
import { SageMakerModelProps, ModelCustomScriptConfig } from "./types";
import { createHash } from "crypto";

export function deployCustomScriptModel(
scope: Construct,
Expand All @@ -11,9 +12,17 @@ export function deployCustomScriptModel(
const { vpc, region } = props;
const { modelId, instanceType, codeFolder, container, env } = modelConfig;

const endpointName = (Array.isArray(modelId) ? modelId.join(",") : modelId)
const endpointName = (
Array.isArray(modelId)
? `Multi${createHash("md5")
.update(modelId.join(","))
.digest("hex")
.toUpperCase()
.slice(-5)}`
: modelId
)
.replace(/[^a-zA-Z0-9]/g, "")
.slice(-20);
.slice(-10);
const llmModel = new HuggingFaceCustomScriptModel(scope, endpointName, {
vpc,
region,
Expand Down
6 changes: 3 additions & 3 deletions lib/sagemaker-model/hf-custom-script-model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export class HuggingFaceCustomScriptModel extends Construct {
? props.modelId.join(",")
: props.modelId;

const buildBucket = new s3.Bucket(this, "BuildBucket", {
const buildBucket = new s3.Bucket(this, "Bucket", {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});

// Upload build code to S3
new s3deploy.BucketDeployment(this, "BuildScriptDeployment", {
new s3deploy.BucketDeployment(this, "Script", {
sources: [s3deploy.Source.asset(path.join(__dirname, "./build-script"))],
retainOnDelete: false,
destinationBucket: buildBucket,
Expand All @@ -66,7 +66,7 @@ export class HuggingFaceCustomScriptModel extends Construct {
let deployment;
// Upload model folder to S3
if (codeFolder) {
deployment = new s3deploy.BucketDeployment(this, "ModelCodeDeployment", {
deployment = new s3deploy.BucketDeployment(this, "ModelCode", {
sources: [s3deploy.Source.asset(codeFolder)],
retainOnDelete: false,
destinationBucket: buildBucket,
Expand Down