Skip to content

Commit 572e960

Browse files
mollyheamazonnargokul
authored andcommitted
fix: validation error for json format that accomadates both single and double quotes (#224)
* update cloud formation template to 1.1, fix instance group setting format * fix unit test * fix: validation error for json format that accomadates both single and double quotes
1 parent f34c546 commit 572e960

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sagemaker/hyperpod/cluster_management/hp_cluster_stack.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from pydantic import Field, field_validator
66
from typing import Optional, List, Dict, Any, Union
7-
7+
import ast
88
import boto3
99
import click
1010
import yaml
@@ -66,7 +66,11 @@ def validate_list_fields(cls, v):
6666
import json
6767
v = json.loads(v)
6868
except (json.JSONDecodeError, TypeError):
69-
pass # Keep original value if parsing fails
69+
try:
70+
# Try Python literal eval (single quotes)
71+
v = ast.literal_eval(v)
72+
except:
73+
pass # Keep original value if parsing fails
7074

7175
if isinstance(v, list) and len(v) == 0:
7276
raise ValueError('Empty lists [] are not allowed. Use proper YAML array format or leave field empty.')

0 commit comments

Comments
 (0)