Skip to content

Commit 16f595f

Browse files
committed
test(sdk): add test for storage_per_trial
Signed-off-by: truc0 <22969604+truc0@users.noreply.github.com>
1 parent adbd2c2 commit 16f595f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ class name in this argument.
532532
if storage_per_trial:
533533
if isinstance(storage_per_trial, dict):
534534
storage_per_trial = [storage_per_trial]
535+
elif not isinstance(storage_per_trial, list):
536+
raise ValueError("storage_per_trial must be a list of dictionaries")
535537
for storage in storage_per_trial:
536538
volume = None
537539
if isinstance(storage["volume"], client.V1Volume):

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,50 @@ def create_experiment(
404404
},
405405
ValueError,
406406
),
407+
(
408+
"invalid storage_per_trial - type mismatch",
409+
{
410+
"name": "tune_test",
411+
"objective": lambda x: print(f"a={x}"),
412+
"parameters": {"a": katib.search.int(min=10, max=100)},
413+
"storage_per_trial": "invalid",
414+
},
415+
ValueError,
416+
),
417+
(
418+
"invalid storage_per_trial - volume has no name",
419+
{
420+
"name": "tune_test",
421+
"objective": lambda x: print(f"a={x}"),
422+
"parameters": {"a": katib.search.int(min=10, max=100)},
423+
"storage_per_trial": [
424+
{
425+
"volume": {
426+
# do not provide name
427+
"type": "pvc",
428+
}
429+
}
430+
],
431+
},
432+
ValueError,
433+
),
434+
(
435+
"invalid storage_per_trial - volume has no type",
436+
{
437+
"name": "tune_test",
438+
"objective": lambda x: print(f"a={x}"),
439+
"parameters": {"a": katib.search.int(min=10, max=100)},
440+
"storage_per_trial": [
441+
{
442+
"volume": {
443+
"name": "test-pvc",
444+
# do not provide type
445+
}
446+
}
447+
],
448+
},
449+
ValueError,
450+
),
407451
(
408452
"invalid model_provider_parameters",
409453
{

0 commit comments

Comments
 (0)