Skip to content

Commit

Permalink
raise value error for wrong name format by reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdikhashan committed Jan 27, 2025
1 parent 274060f commit c74b4d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
19 changes: 5 additions & 14 deletions sdk/python/v1beta1/kubeflow/katib/api/katib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,20 +560,6 @@ class name in this argument.
# Create PVC for the Storage Initializer.
# TODO (helenxie-bit): PVC Creation should be part of Katib Controller.
try:
if not utils.is_valid_pvc_name(name):
raise ValueError(
f"""
Invalid PVC name '{name}'. It must comply with RFC 1123.
A lowercase RFC 1123 subdomain must consist of lowercase
alphanumeric characters, '-' or '.',
and must start and end with an alphanumeric character.
For example, 'example.com' is valid.
The regex used for validation is:
'[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
"""
)

self.core_api.create_namespaced_persistent_volume_claim(
namespace=namespace,
body=training_utils.get_pvc_spec(
Expand All @@ -583,6 +569,11 @@ class name in this argument.
),
)
except Exception as e:
if hasattr(e, "status") and e.status == 422:
raise ValueError(
f"An Experiment with the name {name} is not valid."
)

pvc_list = self.core_api.list_namespaced_persistent_volume_claim(
namespace=namespace
)
Expand Down
7 changes: 7 additions & 0 deletions sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ def create_experiment(
},
ValueError,
),
(
"wrong name format",
{
"name": "Llama3.1-fine-tune",
},
ValueError,
),
(
"invalid hybrid parameters - objective and model_provider_parameters",
{
Expand Down

0 comments on commit c74b4d6

Please sign in to comment.