@@ -302,12 +302,12 @@ class name in this argument.
302
302
- volume: Either a kubernetes.client.V1Volume object or a dictionary
303
303
containing volume configuration with required fields:
304
304
- name: Name of the volume
305
- - type: One of "pvc", "secret", "config_map ", or "empty_dir"
305
+ - type: One of "pvc", "secret", "configmap ", or "empty_dir"
306
306
Additional fields based on volume type:
307
307
- For pvc: claim_name, read_only (optional)
308
308
- For secret: secret_name, items (optional), default_mode (optional),
309
309
optional (optional)
310
- - For config_map: config_map_name , items (optional), default_mode
310
+ - For configmap: configmap_name , items (optional), default_mode
311
311
(optional), optional (optional)
312
312
- For empty_dir: medium (optional), size_limit (optional)
313
313
- mount_path: Either a kubernetes.client.V1VolumeMount object or a string
@@ -533,7 +533,6 @@ class name in this argument.
533
533
if isinstance (storage_per_trial , dict ):
534
534
storage_per_trial = [storage_per_trial ]
535
535
for storage in storage_per_trial :
536
- print (f"storage: { storage } " )
537
536
volume = None
538
537
if isinstance (storage ["volume" ], client .V1Volume ):
539
538
volume = storage ["volume" ]
@@ -576,11 +575,11 @@ class name in this argument.
576
575
optional = storage ["volume" ].get ("optional" , False ),
577
576
),
578
577
)
579
- elif volume_type == "config_map " :
578
+ elif volume_type == "configmap " :
580
579
volume = client .V1Volume (
581
580
name = volume_name ,
582
- config_map = client .V1ConfigMapVolumeSource (
583
- name = storage ["volume" ].get ("config_map_name " ),
581
+ configmap = client .V1ConfigMapVolumeSource (
582
+ name = storage ["volume" ].get ("configmap_name " ),
584
583
items = storage ["volume" ].get ("items" , []),
585
584
default_mode = storage ["volume" ].get (
586
585
"default_mode" , None
@@ -624,52 +623,37 @@ class name in this argument.
624
623
"client.V1VolumeMount or a str"
625
624
)
626
625
627
- # Create Trial specification.
628
- trial_spec = client .V1Job (
629
- api_version = "batch/v1" ,
630
- kind = "Job" ,
631
- spec = client .V1JobSpec (
632
- template = client .V1PodTemplateSpec (
633
- metadata = models .V1ObjectMeta (
634
- annotations = {"sidecar.istio.io/inject" : "false" }
635
- ),
636
- spec = client .V1PodSpec (
637
- restart_policy = "Never" ,
638
- containers = [
639
- client .V1Container (
640
- name = constants .DEFAULT_PRIMARY_CONTAINER_NAME ,
641
- image = base_image ,
642
- command = ["bash" , "-c" ],
643
- args = [exec_script ],
644
- env = env if env else None ,
645
- env_from = env_from if env_from else None ,
646
- resources = resources_per_trial ,
647
- volume_mounts = (
648
- volume_mounts if volume_mounts else None
649
- ),
650
- )
651
- ],
652
- volumes = volumes if volumes else None ,
653
- ),
654
- )
655
- ),
656
- )
626
+ # inject volume mounts to the container spec, do nothing if volume_mounts is empty
627
+ if volume_mounts :
628
+ if isinstance (container_spec .volume_mounts , list ):
629
+ container_spec .volume_mounts .extend (volume_mounts )
630
+ else :
631
+ container_spec .volume_mounts = volume_mounts
657
632
658
633
# Trial uses PyTorchJob for distributed training if TrainerResources is set.
659
634
if isinstance (resources_per_trial , TrainerResources ):
660
635
trial_template = utils .get_trial_template_with_pytorchjob (
661
636
retain_trials ,
662
637
trial_parameters ,
663
638
resources_per_trial ,
664
- training_utils .get_pod_template_spec (containers = [container_spec ]),
665
- training_utils .get_pod_template_spec (containers = [container_spec ]),
639
+ training_utils .get_pod_template_spec (
640
+ containers = [container_spec ],
641
+ volumes = volumes if volumes else None ,
642
+ ),
643
+ training_utils .get_pod_template_spec (
644
+ containers = [container_spec ],
645
+ volumes = volumes if volumes else None ,
646
+ ),
666
647
)
667
648
# Otherwise, Trial uses Job for model training.
668
649
else :
669
650
trial_template = utils .get_trial_template_with_job (
670
651
retain_trials ,
671
652
trial_parameters ,
672
- training_utils .get_pod_template_spec (containers = [container_spec ]),
653
+ training_utils .get_pod_template_spec (
654
+ containers = [container_spec ],
655
+ volumes = volumes if volumes else None ,
656
+ ),
673
657
)
674
658
675
659
# If users choose to use external models and datasets.
0 commit comments