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

Limit bucket name length in templates #224

Merged
merged 8 commits into from
Aug 19, 2024
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### **Changed**
- Added accelerate as extra for transformers in finetune llm template
- Limited bucket name length in templates to avoid pipeline failures when using long project names
- Increased timeout on finetune_llm_evaluation project from 1 hour (default) to 4 hours

## v1.4.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(
pipeline_artifact_bucket = s3.Bucket(
self,
"Pipeline Artifacts Bucket",
bucket_name=f"mlops-{sagemaker_project_name}-{sagemaker_project_id}-{Aws.ACCOUNT_ID}",
bucket_name=f"mlops-{sagemaker_project_name}-{Aws.ACCOUNT_ID}",
encryption_key=kms_key_artifact,
versioned=True,
enforce_ssl=True, # Blocks insecure requests to the bucket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def __init__(
project_name=f"{project_name}-{construct_id}",
role=codebuild_role, # figure out what actually this role would need
build_spec=codebuild.BuildSpec.from_source_filename("buildspec.yml"),
timeout=aws_cdk.Duration.hours(4),
environment=codebuild.BuildEnvironment(
build_image=codebuild.LinuxBuildImage.STANDARD_5_0,
environment_variables={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
model_bucket = s3.Bucket(
self,
"S3 Artifact",
bucket_name=f"mlops-{sagemaker_project_name}-{sagemaker_project_id}-{Aws.ACCOUNT_ID}",
bucket_name=f"mlops-{sagemaker_project_name}-{Aws.ACCOUNT_ID}",
encryption_key=kms_key,
versioned=True,
removal_policy=RemovalPolicy.DESTROY,
Expand Down Expand Up @@ -230,7 +230,7 @@ def __init__(
pipeline_artifact_bucket = s3.Bucket(
self,
"Pipeline Bucket",
bucket_name=f"pipeline-{sagemaker_project_name}-{sagemaker_project_id}-{Aws.ACCOUNT_ID}",
bucket_name=f"pipeline-{sagemaker_project_name}-{Aws.ACCOUNT_ID}",
encryption_key=kms_key,
versioned=True,
removal_policy=RemovalPolicy.DESTROY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import json
import os

MAX_NAME_LENGTH = 63

MODEL_BUCKET_ARN = os.environ["MODEL_BUCKET_ARN"]
MODEL_PACKAGE_GROUP_NAME = os.getenv("MODEL_PACKAGE_GROUP_NAME", "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DOMAIN_ID,
ECR_REPO_ARN,
ENABLE_NETWORK_ISOLATION,
MAX_NAME_LENGTH,
MODEL_BUCKET_ARN,
MODEL_PACKAGE_GROUP_NAME,
PROJECT_ID,
Expand Down Expand Up @@ -160,7 +161,8 @@ def __init__(
latest_approved_model_package = get_approved_package()

# Sagemaker Model
model_name = f"{MODEL_PACKAGE_GROUP_NAME}-{id}-{timestamp}"
model_name = f"-{id}-{timestamp}"
model_name = MODEL_PACKAGE_GROUP_NAME[: MAX_NAME_LENGTH - len(model_name)] + model_name

vpc_config = None
if subnet_ids:
Expand All @@ -187,7 +189,10 @@ def __init__(
)

# Sagemaker Endpoint Config
endpoint_config_name = f"{MODEL_PACKAGE_GROUP_NAME}-{id}-ec-{timestamp}"
endpoint_config_name = f"-{id}-ec-{timestamp}"
endpoint_config_name = (
MODEL_PACKAGE_GROUP_NAME[: MAX_NAME_LENGTH - len(endpoint_config_name)] + endpoint_config_name
)

endpoint_config_production_variant = EndpointConfigProductionVariant()

Expand Down Expand Up @@ -226,7 +231,8 @@ def __init__(
endpoint_config.add_dependency(model)

# Sagemaker Endpoint
endpoint_name = f"{MODEL_PACKAGE_GROUP_NAME}-{id}-endpoint"
endpoint_name = f"-{id}-endpoint"
endpoint_name = MODEL_PACKAGE_GROUP_NAME[: MAX_NAME_LENGTH - len(endpoint_name)] + endpoint_name

endpoint = sagemaker.CfnEndpoint(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(
model_bucket = s3.Bucket(
self,
"S3 Artifact",
bucket_name=f"mlops-{sagemaker_project_name}-{sagemaker_project_id}-{Aws.ACCOUNT_ID}",
bucket_name=f"mlops-{sagemaker_project_name}-{Aws.ACCOUNT_ID}",
encryption_key=kms_key,
versioned=True,
removal_policy=RemovalPolicy.DESTROY,
Expand Down Expand Up @@ -247,7 +247,7 @@ def __init__(
pipeline_artifact_bucket = s3.Bucket(
self,
"Pipeline Bucket",
bucket_name=f"pipeline-{sagemaker_project_name}-{sagemaker_project_id}-{Aws.ACCOUNT_ID}",
bucket_name=f"pipeline-{sagemaker_project_name}-{Aws.ACCOUNT_ID}",
encryption_key=kms_key,
versioned=True,
removal_policy=RemovalPolicy.DESTROY,
Expand Down
Loading