Skip to content

Cluster

geneva.cluster.mgr.GenevaCluster

A Geneva Cluster represents the backend compute infrastructure for the execution environment.

cluster_type

cluster_type: GenevaClusterType = field(
    metadata={"pa_type": string()}
)

name

name: str = field()

kuberay

kuberay: Optional[KubeRayConfig] = field(
    default=None, metadata={"pa_type": "string"}
)

created_at

created_at: datetime = field(
    factory=lambda: now(utc),
    metadata={"pa_type": timestamp("us", tz="UTC")},
)

created_by

created_by: str = field(factory=current_user)

ray_address

ray_address: Optional[str] = field(default=None)

validate

validate() -> None

to_ray_cluster

to_ray_cluster() -> RayCluster

Convert the persisted cluster definition into internal RayCluster model

as_dict

as_dict() -> dict

geneva.cluster.builder.GenevaClusterBuilder

Fluent builder for GenevaCluster. name is required, all optional fields will use defaults. example usage:

 GenevaClusterBuilder
    .name("my-cluster")
    .head_group_builder(HeadGroupBuilder().cpus(8).memory("16Gi"))
    .add_worker_group(WorkerGroupBuilder()
                          .gpu_worker(memory="8Gi", gpus=1))
    .build()

name

name(name: str) -> GenevaClusterBuilder

Set the cluster name.

cluster_type

cluster_type(
    cluster_type: GenevaClusterType,
) -> GenevaClusterBuilder

Set the cluster type. This can be one of:

  • GenevaClusterType.KUBE_RAY (default): Launches a Ray cluster in Kubernetes using KubeRay.
  • GenevaClusterType.LOCAL_RAY: Starts a local Ray cluster in the current process.
  • GenevaClusterType.EXTERNAL_RAY: Connects to an existing Ray cluster. ray_address must be provided for this option.

namespace

namespace(namespace: str) -> GenevaClusterBuilder

Set the Kubernetes namespace.

config_method

config_method(
    method: K8sConfigMethod,
) -> GenevaClusterBuilder

Set the Kubernetes config method.

portforwarding

portforwarding(
    enabled: bool = True,
) -> GenevaClusterBuilder

Enable or disable port forwarding.

aws_config

aws_config(
    region: str | None = None, role_name: str | None = None
) -> GenevaClusterBuilder

Configure AWS settings.

ray_address

ray_address(addr: str) -> GenevaClusterBuilder

Set the Ray address for external Ray clusters. i.e. ray://{ray_ip}:{ray_port} This must be provided when using cluster type EXTERNAL_RAY

ray_init_kwargs

ray_init_kwargs(kwargs: dict) -> GenevaClusterBuilder

Set arbitrary kwargs to pass to ray.init() when starting the cluster.

Commonly used for runtime_env configuration with conda or pip dependencies.

Example:

builder.ray_init_kwargs({
    "runtime_env": {
        "conda": {
            "channels": ["conda-forge"],
            "dependencies": [
                "python=3.10", "ffmpeg<8", "torchvision=0.22.1"
            ]
        },
        "config": {"eager_install": True}
    }
})

WARNING: This accepts arbitrary kwargs without validation allowing for injection of fault or potentially malicious configuration. Use with caution.

head_group

head_group(
    *,
    image: str | None = None,
    cpus: int | None = None,
    memory: str | None = None,
    gpus: int | None = None,
    service_account: str | None = None,
    node_selector: dict[str, str] | None = None,
    labels: dict[str, str] | None = None,
    tolerations: list[dict[str, str]] | None = None,
) -> GenevaClusterBuilder

Configure the head group with optional parameters.

head_group_builder

head_group_builder(
    builder: HeadGroupBuilder,
) -> GenevaClusterBuilder

Configure the head group using a HeadGroupBuilder.

add_cpu_worker_group

add_cpu_worker_group(
    *,
    image: str | None = None,
    cpus: int = 4,
    memory: str = "8Gi",
    service_account: str | None = None,
    node_selector: dict[str, str] | None = None,
    labels: dict[str, str] | None = None,
    tolerations: list[dict[str, str]] | None = None,
) -> GenevaClusterBuilder

Add a CPU worker group.

add_gpu_worker_group

add_gpu_worker_group(
    *,
    image: str | None = None,
    cpus: int = 4,
    memory: str = "8Gi",
    gpus: int = 1,
    service_account: str | None = None,
    node_selector: dict[str, str] | None = None,
    labels: dict[str, str] | None = None,
    tolerations: list[dict[str, str]] | None = None,
) -> GenevaClusterBuilder

Add a GPU worker group.

add_worker_group

add_worker_group(
    builder: WorkerGroupBuilder,
) -> GenevaClusterBuilder

Add a worker group using a WorkerGroupBuilder.

build

build() -> GenevaCluster

Build the GenevaCluster with the configured settings.

create

create(name: str) -> GenevaClusterBuilder

Create a new builder with the given cluster name.

external_cluster

external_cluster(
    name: str, ray_address: str
) -> GenevaClusterBuilder

Create a new builder configured for an external Ray cluster.

local_cpu_cluster

local_cpu_cluster(
    name: str, namespace: str = "geneva"
) -> GenevaClusterBuilder

Create a builder for a local CPU-only cluster with good defaults.

gpu_cluster

gpu_cluster(
    name: str, namespace: str = "geneva"
) -> GenevaClusterBuilder

Create a builder for a GPU cluster with good defaults.

geneva.cluster.builder.HeadGroupBuilder

Builder for HeadGroupConfig. This can be used to build the configuration for a Ray head group with reasonable defaults. See GenevaClusterBuilder for examples

image

image(image: str) -> HeadGroupBuilder

Set the container image.

cpus

cpus(cpus: int) -> HeadGroupBuilder

Set the number of CPUs.

memory

memory(memory: str) -> HeadGroupBuilder

Set the memory allocation (e.g., '4Gi', '8Gi').

gpus

gpus(gpus: int) -> HeadGroupBuilder

Set the number of GPUs.

service_account

service_account(service_account: str) -> HeadGroupBuilder

Set the Kubernetes service account.

node_selector

node_selector(
    node_selector: dict[str, str],
) -> HeadGroupBuilder

Set the node selector for pod placement.

labels

labels(labels: dict[str, str]) -> HeadGroupBuilder

Set the pod labels.

tolerations

tolerations(
    tolerations: list[dict[str, str]],
) -> HeadGroupBuilder

Set the pod tolerations.

add_label

add_label(key: str, value: str) -> HeadGroupBuilder

Add a single label.

add_toleration

add_toleration(
    key: str,
    operator: str = "Equal",
    value: str = "",
    effect: str = "",
) -> HeadGroupBuilder

Add a single toleration.

build

build() -> HeadGroupConfig

Build the HeadGroupConfig.

create

create() -> HeadGroupBuilder

Create a new head group builder with defaults.

cpu_head

cpu_head(
    cpus: int = 2, memory: str = "4Gi"
) -> HeadGroupBuilder

Create a CPU-only head group.

geneva.cluster.builder.WorkerGroupBuilder

Builder for WorkerGroupConfig. This can be used to build the configuration for a Ray worker group with reasonable defaults. See GenevaClusterBuilder for examples

image

image(image: str) -> WorkerGroupBuilder

Set the container image.

cpus

cpus(cpus: int) -> WorkerGroupBuilder

Set the number of CPUs.

replicas

replicas(replicas: int) -> WorkerGroupBuilder

Set the number of replicas.

min_replicas

min_replicas(min_replicas: int) -> WorkerGroupBuilder

Set the minimum number of replicas for autoscaling.

max_replicas

max_replicas(max_replicas: int) -> WorkerGroupBuilder

Set the maximum number of replicas for autoscaling.

memory

memory(memory: str) -> WorkerGroupBuilder

Set the memory allocation (e.g., '8Gi', '16Gi').

gpus

gpus(gpus: int) -> WorkerGroupBuilder

Set the number of GPUs.

service_account

service_account(service_account: str) -> WorkerGroupBuilder

Set the Kubernetes service account.

node_selector

node_selector(
    node_selector: dict[str, str],
) -> WorkerGroupBuilder

Set the node selector for pod placement.

labels

labels(labels: dict[str, str]) -> WorkerGroupBuilder

Set the pod labels.

tolerations

tolerations(
    tolerations: list[dict[str, str]],
) -> WorkerGroupBuilder

Set the pod tolerations.

add_label

add_label(key: str, value: str) -> WorkerGroupBuilder

Add a single label.

add_toleration

add_toleration(
    key: str,
    operator: str = "Equal",
    value: str = "",
    effect: str = "",
) -> WorkerGroupBuilder

Add a single toleration.

build

build() -> WorkerGroupConfig

Build the WorkerGroupConfig.

create

create() -> WorkerGroupBuilder

Create a new worker group builder with defaults.

cpu_worker

cpu_worker(
    cpus: int = 4, memory: str = "8Gi"
) -> WorkerGroupBuilder

Create a CPU worker group.

gpu_worker

gpu_worker(
    cpus: int = 8, memory: str = "16Gi", gpus: int = 1
) -> WorkerGroupBuilder

Create a GPU worker group.

geneva.cluster.mgr.HeadGroupConfig

Bases: RayGroupConfig

Configuration for Ray Head pod

k8s_spec_override

k8s_spec_override: dict[str, Any] | None = field(
    default=None,
    metadata={"pa_type": "string", "nullable": True},
)

geneva.cluster.mgr.WorkerGroupConfig

Bases: RayGroupConfig

Configuration for Ray Worker pods

k8s_spec_override

k8s_spec_override: dict[str, Any] | None = field(
    default=None
)

replicas

replicas: int = field(default=1)

min_replicas

min_replicas: int = field(default=0)

max_replicas

max_replicas: int = field(
    default=DEFAULT_MAX_WORKER_REPLICAS
)

geneva.cluster.mgr.KubeRayConfig

namespace

namespace: str = field()

head_group

head_group: HeadGroupConfig = field()

worker_groups

worker_groups: list[WorkerGroupConfig] = field()

config_method

config_method: K8sConfigMethod = field(default=LOCAL)

use_portforwarding

use_portforwarding: bool = field(default=True)

aws_region

aws_region: Optional[str] = field(default=None)

aws_role_name

aws_role_name: Optional[str] = field(default=None)

ray_init_kwargs

ray_init_kwargs: Optional[dict[str, Any]] = field(
    factory=dict
)

geneva.cluster.mgr.ClusterConfigManager

Bases: BaseManager

get_table_name

get_table_name() -> str

get_model

get_model() -> Any

upsert

upsert(cluster: GenevaCluster) -> None

list

list(limit: int = 1000) -> list[GenevaCluster]

load

load(name: str) -> GenevaCluster | None

delete

delete(name: str) -> None

geneva.cluster.GenevaClusterType

Bases: Enum

Type of Geneva Cluster

KUBE_RAY

KUBE_RAY = 'KUBE_RAY'

LOCAL_RAY

LOCAL_RAY = 'LOCAL_RAY'

EXTERNAL_RAY

EXTERNAL_RAY = 'EXTERNAL_RAY'

geneva.cluster.K8sConfigMethod

Bases: Enum

Method for retrieving kubernetes config:

  • LOCAL: Load the kube config from the local environment.
  • EKS_AUTH: Load the kube config from AWS EKS service (requires AWS credentials).
  • IN_CLUSTER: Load the kube config when running inside a pod in the cluster.

EKS_AUTH

EKS_AUTH = 'EKS_AUTH'

IN_CLUSTER

IN_CLUSTER = 'IN_CLUSTER'

LOCAL

LOCAL = 'LOCAL'