codeflare_sdk.vendored.python_client.utils package
Submodules
codeflare_sdk.vendored.python_client.utils.kuberay_cluster_builder module
Set of helper methods to manage rayclusters. Requires Python 3.9 and higher
- class codeflare_sdk.vendored.python_client.utils.kuberay_cluster_builder.ClusterBuilder[source]
Bases:
IClusterBuilder
ClusterBuilder implements the abstract methods of IClusterBuilder to build a cluster.
- build_head(ray_image: str = 'rayproject/ray:2.46.0', service_type: str = 'ClusterIP', cpu_requests: str = '2', memory_requests: str = '3G', cpu_limits: str = '2', memory_limits: str = '3G', ray_start_params: dict = {'dashboard-host': '0.0.0.0'})[source]
Build head node of the ray cluster.
Parameters: - ray_image (str): Docker image for the head node. Default value is “rayproject/ray:2.46.0”. - service_type (str): Service type of the head node. Default value is “ClusterIP”, which creates a headless ClusterIP service. - cpu_requests (str): CPU requests for the head node. Default value is “2”. - memory_requests (str): Memory requests for the head node. Default value is “3G”. - cpu_limits (str): CPU limits for the head node. Default value is “2”. - memory_limits (str): Memory limits for the head node. Default value is “3G”. - ray_start_params (dict): Dictionary of start parameters for the head node. Default values is “dashboard-host”: “0.0.0.0”.
- build_meta(name: str, k8s_namespace: str = 'default', labels: dict = None, ray_version: str = '2.46.0')[source]
Builds the metadata and ray version of the cluster.
Parameters: - name (str): The name of the cluster. - k8s_namespace (str, optional): The namespace in which the Ray cluster exists. Defaults to “default”. - labels (dict, optional): A dictionary of key-value pairs to add as labels to the cluster. Defaults to None. - ray_version (str, optional): The version of Ray to use for the cluster. Defaults to “2.46.0”.
- build_worker(group_name: str, ray_image: str = 'rayproject/ray:2.46.0', ray_command: Any = ['/bin/bash', '-lc'], init_image: str = 'busybox:1.28', cpu_requests: str = '1', memory_requests: str = '1G', cpu_limits: str = '2', memory_limits: str = '2G', replicas: int = 1, min_replicas: int = -1, max_replicas: int = -1, ray_start_params: dict = {})[source]
Build worker specifications of the cluster.
This function sets the worker configuration of the cluster, including the Docker image, CPU and memory requirements, number of replicas, and other parameters.
Parameters: - group_name (str): name of the worker group. - ray_image (str, optional): Docker image for the Ray process. Default is “rayproject/ray:2.46.0”. - ray_command (Any, optional): Command to run in the Docker container. Default is [“/bin/bash”, “-lc”]. - init_image (str, optional): Docker image for the init container. Default is “busybox:1.28”. - cpu_requests (str, optional): CPU requests for the worker pods. Default is “1”. - memory_requests (str, optional): Memory requests for the worker pods. Default is “1G”. - cpu_limits (str, optional): CPU limits for the worker pods. Default is “2”. - memory_limits (str, optional): Memory limits for the worker pods. Default is “2G”. - replicas (int, optional): Number of worker pods to run. Default is 1. - min_replicas (int, optional): Minimum number of worker pods to run. Default is -1. - max_replicas (int, optional): Maximum number of worker pods to run. Default is -1. - ray_start_params (dict, optional): Additional parameters to pass to the ray start command. Default is {}.
- class codeflare_sdk.vendored.python_client.utils.kuberay_cluster_builder.Director[source]
Bases:
object
- build_basic_cluster(name: str, k8s_namespace: str = 'default', labels: dict = None) dict [source]
Builds a basic cluster with the given name and k8s_namespace parameters.
Parameters: - name (str): The name of the cluster. - k8s_namespace (str, optional): The kubernetes namespace for the cluster, with a default value of “default”.
Returns: dict: The basic cluster as a dictionary.
- build_large_cluster(name: str, k8s_namespace: str = 'default', labels: dict = None) dict [source]
Builds a medium cluster with the given name and k8s_namespace parameters. with 1 workergroup, the workgroup has 6 replicas with 6 cpu and 6G memory limits
Parameters: - name (str): The name of the cluster. - k8s_namespace (str, optional): The kubernetes namespace for the cluster, with a default value of “default”.
Returns: dict: The small cluster as a dictionary.
- build_medium_cluster(name: str, k8s_namespace: str = 'default', labels: str = None) dict [source]
Builds a medium cluster with the given name and k8s_namespace parameters with 1 workergroup, the workgroup has 3 replicas with 4 cpu and 4G memory limits
Parameters: - name (str): The name of the cluster. - k8s_namespace (str, optional): The kubernetes namespace for the cluster, with a default value of “default”.
Returns: dict: The small cluster as a dictionary.
- build_small_cluster(name: str, k8s_namespace: str = 'default', labels: dict = None) dict [source]
Builds a small cluster with the given name and k8s_namespace parameters with 1 workergroup, the workgroup has 1 replica with 2 cpu and 2G memory limits
Parameters: - name (str): The name of the cluster. - k8s_namespace (str, optional): The kubernetes namespace for the cluster, with a default value of “default”.
Returns: dict: The small cluster as a dictionary.
codeflare_sdk.vendored.python_client.utils.kuberay_cluster_utils module
Set of helper methods to manage rayclusters. Requires Python 3.6 and higher
- class codeflare_sdk.vendored.python_client.utils.kuberay_cluster_utils.ClusterUtils[source]
Bases:
object
ClusterUtils - Utility class for populating cluster information
Methods: - populate_meta(cluster: dict, name: str, k8s_namespace: str, labels: dict, ray_version: str) -> dict: - populate_ray_head(cluster: dict, ray_image: str,service_type: str, cpu_requests: str, memory_requests: str, cpu_limits: str, memory_limits: str, ray_start_params: dict) -> Tuple[dict, bool]: - populate_worker_group(cluster: dict, group_name: str, ray_image: str, ray_command: Any, init_image: str, cpu_requests: str, memory_requests: str, cpu_limits: str, memory_limits: str, replicas: int, min_replicas: int, max_replicas: int, ray_start_params: dict) -> Tuple[dict, bool]: - update_worker_group_replicas(cluster: dict, group_name: str, max_replicas: int, min_replicas: int, replicas: int) -> Tuple[dict, bool]:
- delete_worker_group(cluster: dict, group_name: str) Tuple[dict, bool] [source]
Deletes a worker group in the cluster.
Parameters: - cluster (dict): The cluster definition. - group_name (str): The name of the worker group to be duplicated.
Returns: Tuple[dict, bool]: A tuple containing the updated cluster definition and a boolean indicating the success of the operation.
- duplicate_worker_group(cluster: dict, group_name: str, new_group_name: str) Tuple[dict, bool] [source]
Duplicate a worker group in the cluster.
Parameters: - cluster (dict): The cluster definition. - group_name (str): The name of the worker group to be duplicated. - new_group_name (str): The name for the duplicated worker group.
Returns: Tuple[dict, bool]: A tuple containing the updated cluster definition and a boolean indicating the success of the operation.
- populate_meta(cluster: dict, name: str, k8s_namespace: str, labels: dict, ray_version: str) dict [source]
Populate the metadata and ray version of the cluster.
Parameters: - cluster (dict): A dictionary representing a cluster. - name (str): The name of the cluster. - k8s_namespace (str): The namespace of the cluster. - labels (dict): A dictionary of labels to be applied to the cluster. - ray_version (str): The version of Ray to use in the cluster.
- Returns:
dict: The updated cluster dictionary with metadata and ray version populated.
- populate_ray_head(cluster: dict, ray_image: str, service_type: str, cpu_requests: str, memory_requests: str, cpu_limits: str, memory_limits: str, ray_start_params: dict) Tuple[dict, bool] [source]
Populate the ray head specs of the cluster Parameters: - cluster (dict): The dictionary representation of the cluster. - ray_image (str): The name of the ray image to use for the head node. - service_type (str): The type of service to run for the head node. - cpu_requests (str): The CPU resource requests for the head node. - memory_requests (str): The memory resource requests for the head node. - cpu_limits (str): The CPU resource limits for the head node. - memory_limits (str): The memory resource limits for the head node. - ray_start_params (dict): The parameters for starting the Ray cluster.
Returns: - Tuple (dict, bool): The updated cluster, and a boolean indicating whether the update was successful.
- populate_worker_group(group_name: str, ray_image: str, ray_command: Any, init_image: str, cpu_requests: str, memory_requests: str, cpu_limits: str, memory_limits: str, replicas: int, min_replicas: int, max_replicas: int, ray_start_params: dict) Tuple[dict, bool] [source]
Populate the worker group specification in the cluster dictionary.
Parameters: - cluster (dict): Dictionary representing the cluster spec. - group_name (str): The name of the worker group. - ray_image (str): The image to use for the Ray worker containers. - ray_command (Any): The command to run in the Ray worker containers. - init_image (str): The init container image to use. - cpu_requests (str): The requested CPU resources for the worker containers. - memory_requests (str): The requested memory resources for the worker containers. - cpu_limits (str): The limit on CPU resources for the worker containers. - memory_limits (str): The limit on memory resources for the worker containers. - replicas (int): The desired number of replicas for the worker group. - min_replicas (int): The minimum number of replicas for the worker group. - max_replicas (int): The maximum number of replicas for the worker group. - ray_start_params (dict): The parameters to pass to the Ray worker start command.
Returns: - Tuple[dict, bool]: A tuple of the cluster specification and a boolean indicating
whether the worker group was successfully populated.
- update_worker_group_replicas(cluster: dict, group_name: str, max_replicas: int, min_replicas: int, replicas: int) Tuple[dict, bool] [source]
Update the number of replicas for a worker group in the cluster.
Parameters: - cluster (dict): The cluster to update. - group_name (str): The name of the worker group to update. - max_replicas (int): The maximum number of replicas for the worker group. - min_replicas (int): The minimum number of replicas for the worker group. - replicas (int): The desired number of replicas for the worker group.
Returns: Tuple[dict, bool]: A tuple containing the updated cluster and a flag indicating whether the update was successful.
- update_worker_group_resources(cluster: dict, group_name: str, cpu_requests: str, memory_requests: str, cpu_limits: str, memory_limits: str, container_name='unspecified') Tuple[dict, bool] [source]
Update the resources for a worker group pods in the cluster.
Parameters: - cluster (dict): The cluster to update. - group_name (str): The name of the worker group to update. - cpu_requests (str): CPU requests for the worker pods. - memory_requests (str): Memory requests for the worker pods. - cpu_limits (str): CPU limits for the worker pods. - memory_limits (str): Memory limits for the worker pods.
Returns: Tuple[dict, bool]: A tuple containing the updated cluster and a flag indicating whether the update was successful.