cursus.core.compiler.name_generator

Name generator utilities for pipeline naming.

This module provides utilities for generating pipeline names with consistent formats that comply with SageMaker naming constraints.

generate_random_word(length=4)[source]

Generate a random word of specified length.

Parameters:

length (int) – Length of the random word

Returns:

Random string of specified length

Return type:

str

validate_pipeline_name(name)[source]

Validate that a pipeline name conforms to SageMaker constraints.

Parameters:

name (str) – The pipeline name to validate

Returns:

True if the name is valid, False otherwise

Return type:

bool

sanitize_pipeline_name(name)[source]

Sanitize a pipeline name to conform to SageMaker constraints.

This function: 1. Replaces dots with hyphens 2. Replaces underscores with hyphens 3. Removes any other special characters 4. Ensures the name starts with an alphanumeric character 5. Ensures the name ends with an alphanumeric character

Parameters:

name (str) – The pipeline name to sanitize

Returns:

A sanitized version of the name that conforms to SageMaker constraints

Return type:

str

generate_pipeline_name(base_name, version='1.0')[source]

Generate a valid pipeline name with the format: {base_name}-{random_word}-{version}-pipeline

This function ensures the generated name conforms to SageMaker constraints by sanitizing it before returning.

Parameters:
  • base_name (str) – Base name for the pipeline

  • version (str) – Version string to include in the name

Returns:

A string with the generated pipeline name that passes SageMaker validation

Return type:

str