Skip to content

Commit

Permalink
py sdk create_exp - added type validation
Browse files Browse the repository at this point in the history
Signed-off-by: Bharath Krishna <[email protected]>
  • Loading branch information
bharathk005 committed Apr 2, 2024
1 parent 2260c8b commit 1285b85
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sdk/python/v1beta1/kubeflow/katib/api/katib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ def create_experiment(
namespace = namespace or self.namespace

experiment_name = None
if experiment.metadata.name is not None:
experiment_name = experiment.metadata.name
elif experiment.metadata.generate_name is not None:
experiment_name = experiment.metadata.generate_name
if type(experiment) == models.V1beta1Experiment:
if experiment.metadata.name is not None:
experiment_name = experiment.metadata.name
elif experiment.metadata.generate_name is not None:
experiment_name = experiment.metadata.generate_name
elif "name" in experiment["metadata"]:
experiment_name = experiment["metadata"]["name"]
elif "generate_name" in experiment["metadata"]:
experiment_name = experiment["metadata"]["generate_name"]

if experiment_name is None:
raise ValueError("Experiment must have a name or generateName")
Expand Down

0 comments on commit 1285b85

Please sign in to comment.