1616
1717def normalize_model_name (model_name : str ) -> str :
1818 """
19- Normalize a model name to be safe for use as a directory name.
19+ Normalize a model name to be safe for use as a directory name and ECR repository .
2020
21- Replaces special characters (including hyphens) with underscores to create
22- a cross-platform safe directory name.
21+ Replaces special characters (including hyphens) with underscores and lowercases
22+ the result to create a cross-platform safe directory name that's also valid for ECR .
2323
2424 Args:
2525 model_name: Original model name (e.g., 'schroneko/gemma-2-2b-jpn-it')
@@ -33,7 +33,8 @@ def normalize_model_name(model_name: str) -> str:
3333 normalized = re .sub (r"_+" , "_" , normalized )
3434 # Remove leading/trailing underscores
3535 normalized = normalized .strip ("_" )
36- return normalized
36+ # Lowercase for ECR compatibility (ECR requires lowercase repository names)
37+ return normalized .lower ()
3738
3839
3940def sanitize_for_cloudformation (name : str ) -> str :
@@ -47,7 +48,7 @@ def sanitize_for_cloudformation(name: str) -> str:
4748 name: Input name (may contain underscores or other invalid characters)
4849
4950 Returns:
50- Sanitized name safe for CloudFormation (underscores replaced with hyphens)
51+ Sanitized name safe for CloudFormation (underscores replaced with hyphens, lowercased )
5152 """
5253 # Replace underscores and other invalid characters with hyphens
5354 sanitized = re .sub (r"[_/\\:*?\"<>|]" , "-" , name )
@@ -58,7 +59,8 @@ def sanitize_for_cloudformation(name: str) -> str:
5859 # Ensure starts with a letter (prepend 'p-' if it starts with a number)
5960 if sanitized and sanitized [0 ].isdigit ():
6061 sanitized = f"p-{ sanitized } "
61- return sanitized
62+ # Lowercase for consistency with ECR and other AWS resource naming
63+ return sanitized .lower ()
6264
6365
6466def get_default_project_name () -> str :
0 commit comments