Skip to content

Commit c74b4d6

Browse files
committed
raise value error for wrong name format by reconciliation
1 parent 274060f commit c74b4d6

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

sdk/python/v1beta1/kubeflow/katib/api/katib_client.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -560,20 +560,6 @@ class name in this argument.
560560
# Create PVC for the Storage Initializer.
561561
# TODO (helenxie-bit): PVC Creation should be part of Katib Controller.
562562
try:
563-
if not utils.is_valid_pvc_name(name):
564-
raise ValueError(
565-
f"""
566-
Invalid PVC name '{name}'. It must comply with RFC 1123.
567-
568-
A lowercase RFC 1123 subdomain must consist of lowercase
569-
alphanumeric characters, '-' or '.',
570-
and must start and end with an alphanumeric character.
571-
For example, 'example.com' is valid.
572-
The regex used for validation is:
573-
'[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
574-
"""
575-
)
576-
577563
self.core_api.create_namespaced_persistent_volume_claim(
578564
namespace=namespace,
579565
body=training_utils.get_pvc_spec(
@@ -583,6 +569,11 @@ class name in this argument.
583569
),
584570
)
585571
except Exception as e:
572+
if hasattr(e, "status") and e.status == 422:
573+
raise ValueError(
574+
f"An Experiment with the name {name} is not valid."
575+
)
576+
586577
pvc_list = self.core_api.list_namespaced_persistent_volume_claim(
587578
namespace=namespace
588579
)

sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ def create_experiment(
310310
},
311311
ValueError,
312312
),
313+
(
314+
"wrong name format",
315+
{
316+
"name": "Llama3.1-fine-tune",
317+
},
318+
ValueError,
319+
),
313320
(
314321
"invalid hybrid parameters - objective and model_provider_parameters",
315322
{

0 commit comments

Comments
 (0)