Skip to content
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
4 changes: 2 additions & 2 deletions google/cloud/aiplatform/utils/gcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def stage_local_data_in_gcs(
# regional.
staging_bucket_name = (
project + "-vertex-staging-" + location + "-" + _DEFAULT_STAGING_BUCKET_SALT
)[:63]
)[:63].rstrip("-")
client = storage.Client(project=project, credentials=credentials)
staging_bucket = storage.Bucket(client=client, name=staging_bucket_name)
if not staging_bucket.exists():
Expand Down Expand Up @@ -301,7 +301,7 @@ def generate_gcs_directory_for_pipeline_artifacts(

pipelines_bucket_name = (
project + "-vertex-pipelines-" + location + "-" + _DEFAULT_STAGING_BUCKET_SALT
)
)[:63].rstrip("-")
output_artifacts_gcs_dir = "gs://" + pipelines_bucket_name + "/output_artifacts/"
return output_artifacts_gcs_dir

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/aiplatform/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,17 @@ def test_generate_gcs_directory_for_pipeline_artifacts(self):
assert output.startswith("gs://project-vertex-pipelines-us-central1-")
assert output.endswith("/output_artifacts/")

def test_generate_gcs_directory_for_pipeline_artifacts_max_length(self):
long_project = "gcp-daci-apinsights-prd"
location = "us-east4"
output = gcs_utils.generate_gcs_directory_for_pipeline_artifacts(
long_project, location
)
bucket_name = output.replace("gs://", "").split("/")[0]
assert len(bucket_name) <= 63
assert not bucket_name.endswith("-")
assert output.endswith("/output_artifacts/")

@patch.object(storage.Bucket, "exists", return_value=False)
@patch.object(storage, "Client")
@patch.object(
Expand Down
Loading