Skip to content

Commit aeba0c0

Browse files
chipspeakkryanbeane
authored andcommitted
task(RHOAIENG-33283): Elegantly handle runtime_env
Signed-off-by: Pat O'Connor <[email protected]>
1 parent 05162fb commit aeba0c0

File tree

5 files changed

+984
-760
lines changed

5 files changed

+984
-760
lines changed

src/codeflare_sdk/common/utils/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"3.11": CUDA_PY311_RUNTIME_IMAGE,
1313
"3.12": CUDA_PY312_RUNTIME_IMAGE,
1414
}
15-
MOUNT_PATH = "/home/ray/scripts"
15+
MOUNT_PATH = "/home/ray/files"

src/codeflare_sdk/ray/rayjobs/config.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -448,70 +448,70 @@ def _build_env_vars(self) -> list:
448448
"""Build environment variables list."""
449449
return [V1EnvVar(name=key, value=value) for key, value in self.envs.items()]
450450

451-
def add_script_volumes(self, configmap_name: str, mount_path: str = MOUNT_PATH):
451+
def add_file_volumes(self, configmap_name: str, mount_path: str = MOUNT_PATH):
452452
"""
453-
Add script volume and mount references to cluster configuration.
453+
Add file volume and mount references to cluster configuration.
454454
455455
Args:
456-
configmap_name: Name of the ConfigMap containing scripts
457-
mount_path: Where to mount scripts in containers (default: /home/ray/scripts)
456+
configmap_name: Name of the ConfigMap containing files
457+
mount_path: Where to mount files in containers (default: /home/ray/scripts)
458458
"""
459-
# Check if script volume already exists
460-
volume_name = "ray-job-scripts"
459+
# Check if file volume already exists
460+
volume_name = "ray-job-files"
461461
existing_volume = next(
462462
(v for v in self.volumes if getattr(v, "name", None) == volume_name), None
463463
)
464464
if existing_volume:
465-
logger.debug(f"Script volume '{volume_name}' already exists, skipping...")
465+
logger.debug(f"File volume '{volume_name}' already exists, skipping...")
466466
return
467467

468-
# Check if script mount already exists
468+
# Check if file mount already exists
469469
existing_mount = next(
470470
(m for m in self.volume_mounts if getattr(m, "name", None) == volume_name),
471471
None,
472472
)
473473
if existing_mount:
474474
logger.debug(
475-
f"Script volume mount '{volume_name}' already exists, skipping..."
475+
f"File volume mount '{volume_name}' already exists, skipping..."
476476
)
477477
return
478478

479-
# Add script volume to cluster configuration
480-
script_volume = V1Volume(
479+
# Add file volume to cluster configuration
480+
file_volume = V1Volume(
481481
name=volume_name, config_map=V1ConfigMapVolumeSource(name=configmap_name)
482482
)
483-
self.volumes.append(script_volume)
483+
self.volumes.append(file_volume)
484484

485-
# Add script volume mount to cluster configuration
486-
script_mount = V1VolumeMount(name=volume_name, mount_path=mount_path)
487-
self.volume_mounts.append(script_mount)
485+
# Add file volume mount to cluster configuration
486+
file_mount = V1VolumeMount(name=volume_name, mount_path=mount_path)
487+
self.volume_mounts.append(file_mount)
488488

489489
logger.info(
490-
f"Added script volume '{configmap_name}' to cluster config: mount_path={mount_path}"
490+
f"Added file volume '{configmap_name}' to cluster config: mount_path={mount_path}"
491491
)
492492

493-
def validate_configmap_size(self, scripts: Dict[str, str]) -> None:
494-
total_size = sum(len(content.encode("utf-8")) for content in scripts.values())
493+
def validate_configmap_size(self, files: Dict[str, str]) -> None:
494+
total_size = sum(len(content.encode("utf-8")) for content in files.values())
495495
if total_size > 1024 * 1024: # 1MB
496496
raise ValueError(
497497
f"ConfigMap size exceeds 1MB limit. Total size: {total_size} bytes"
498498
)
499499

500-
def build_script_configmap_spec(
501-
self, job_name: str, namespace: str, scripts: Dict[str, str]
500+
def build_file_configmap_spec(
501+
self, job_name: str, namespace: str, files: Dict[str, str]
502502
) -> Dict[str, Any]:
503503
"""
504-
Build ConfigMap specification for scripts
504+
Build ConfigMap specification for files
505505
506506
Args:
507507
job_name: Name of the RayJob (used for ConfigMap naming)
508508
namespace: Kubernetes namespace
509-
scripts: Dictionary of script_name -> script_content
509+
files: Dictionary of file_name -> file_content
510510
511511
Returns:
512512
Dict: ConfigMap specification ready for Kubernetes API
513513
"""
514-
configmap_name = f"{job_name}-scripts"
514+
configmap_name = f"{job_name}-files"
515515
return {
516516
"apiVersion": "v1",
517517
"kind": "ConfigMap",
@@ -521,27 +521,27 @@ def build_script_configmap_spec(
521521
"labels": {
522522
"ray.io/job-name": job_name,
523523
"app.kubernetes.io/managed-by": "codeflare-sdk",
524-
"app.kubernetes.io/component": "rayjob-scripts",
524+
"app.kubernetes.io/component": "rayjob-files",
525525
},
526526
},
527-
"data": scripts,
527+
"data": files,
528528
}
529529

530-
def build_script_volume_specs(
530+
def build_file_volume_specs(
531531
self, configmap_name: str, mount_path: str = MOUNT_PATH
532532
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
533533
"""
534-
Build volume and mount specifications for scripts
534+
Build volume and mount specifications for files
535535
536536
Args:
537-
configmap_name: Name of the ConfigMap containing scripts
538-
mount_path: Where to mount scripts in containers
537+
configmap_name: Name of the ConfigMap containing files
538+
mount_path: Where to mount files in containers
539539
540540
Returns:
541541
Tuple of (volume_spec, mount_spec) as dictionaries
542542
"""
543-
volume_spec = {"name": "ray-job-scripts", "configMap": {"name": configmap_name}}
543+
volume_spec = {"name": "ray-job-files", "configMap": {"name": configmap_name}}
544544

545-
mount_spec = {"name": "ray-job-scripts", "mountPath": mount_path}
545+
mount_spec = {"name": "ray-job-files", "mountPath": mount_path}
546546

547547
return volume_spec, mount_spec

0 commit comments

Comments
 (0)