diff --git a/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py b/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py index 4b39d6427d9..97b58576cb0 100644 --- a/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py +++ b/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py @@ -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( @@ -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 ) diff --git a/sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py b/sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py index 0a78d75f3bb..674a5bdad61 100644 --- a/sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py +++ b/sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py @@ -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", {