Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the name of PVC in train API #2187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions sdk/python/kubeflow/training/api/training_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def train(
self.core_api.create_namespaced_persistent_volume_claim(
namespace=namespace,
body=utils.get_pvc_spec(
pvc_name=constants.STORAGE_INITIALIZER,
pvc_name=name,
namespace=namespace,
storage_config=storage_config,
),
Expand All @@ -213,11 +213,8 @@ def train(
pvc_list = self.core_api.list_namespaced_persistent_volume_claim(namespace)
# Check if the PVC with the specified name exists
for pvc in pvc_list.items:
if pvc.metadata.name == constants.STORAGE_INITIALIZER:
print(
f"PVC '{constants.STORAGE_INITIALIZER}' already exists in namespace "
f"{namespace}."
)
if pvc.metadata.name == name:
print(f"PVC '{name}' already exists in namespace " f"{namespace}.")
break
else:
raise RuntimeError(f"failed to create PVC. Error: {e}")
Expand Down Expand Up @@ -279,17 +276,24 @@ def train(
resources=resources_per_worker,
)

storage_initializer_volume = models.V1Volume(
name=constants.STORAGE_INITIALIZER,
persistent_volume_claim=models.V1PersistentVolumeClaimVolumeSource(
claim_name=name
),
)

# create worker pod spec
worker_pod_template_spec = utils.get_pod_template_spec(
containers=[container_spec],
volumes=[constants.STORAGE_INITIALIZER_VOLUME],
volumes=[storage_initializer_volume],
)

# create master pod spec
master_pod_template_spec = utils.get_pod_template_spec(
containers=[container_spec],
init_containers=[init_container_spec],
volumes=[constants.STORAGE_INITIALIZER_VOLUME],
volumes=[storage_initializer_volume],
)

job = utils.get_pytorchjob_template(
Expand Down
7 changes: 1 addition & 6 deletions sdk/python/kubeflow/training/constants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@
name=STORAGE_INITIALIZER,
mount_path=INIT_CONTAINER_MOUNT_PATH,
)
STORAGE_INITIALIZER_VOLUME = models.V1Volume(
name=STORAGE_INITIALIZER,
persistent_volume_claim=models.V1PersistentVolumeClaimVolumeSource(
claim_name=STORAGE_INITIALIZER
),
)

TRAINER_TRANSFORMER_IMAGE = "docker.io/kubeflow/trainer-huggingface"

# TFJob constants.
Expand Down
Loading