Skip to content

Commit d1e2d9c

Browse files
committed
Changed min/max workers to single field
1 parent cf0f990 commit d1e2d9c

File tree

6 files changed

+90
-100
lines changed

6 files changed

+90
-100
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def create_app_wrapper(self):
8383
min_memory = self.config.min_memory
8484
max_memory = self.config.max_memory
8585
gpu = self.config.gpu
86-
workers = self.config.max_worker
86+
workers = self.config.worker
8787
template = self.config.template
8888
image = self.config.image
8989
instascale = self.config.instascale
@@ -318,8 +318,7 @@ def from_k8_cluster_object(rc):
318318
name=rc["metadata"]["name"],
319319
namespace=rc["metadata"]["namespace"],
320320
machine_types=machine_types,
321-
min_worker=rc["spec"]["workerGroupSpecs"][0]["minReplicas"],
322-
max_worker=rc["spec"]["workerGroupSpecs"][0]["maxReplicas"],
321+
worker=rc["spec"]["workerGroupSpecs"][0]["minReplicas"],
323322
min_cpus=rc["spec"]["workerGroupSpecs"][0]["template"]["spec"][
324323
"containers"
325324
][0]["resources"]["requests"]["cpu"],
@@ -545,8 +544,7 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
545544
name=rc["metadata"]["name"],
546545
status=status,
547546
# for now we are not using autoscaling so same replicas is fine
548-
min_workers=rc["spec"]["workerGroupSpecs"][0]["replicas"],
549-
max_workers=rc["spec"]["workerGroupSpecs"][0]["replicas"],
547+
workers=rc["spec"]["workerGroupSpecs"][0]["replicas"],
550548
worker_mem_max=rc["spec"]["workerGroupSpecs"][0]["template"]["spec"][
551549
"containers"
552550
][0]["resources"]["limits"]["memory"],
@@ -575,8 +573,7 @@ def _copy_to_ray(cluster: Cluster) -> RayCluster:
575573
ray = RayCluster(
576574
name=cluster.config.name,
577575
status=cluster.status(print_to_console=False)[0],
578-
min_workers=cluster.config.min_worker,
579-
max_workers=cluster.config.max_worker,
576+
workers=cluster.config.worker,
580577
worker_mem_min=cluster.config.min_memory,
581578
worker_mem_max=cluster.config.max_memory,
582579
worker_cpu=cluster.config.min_cpus,

src/codeflare_sdk/cluster/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class ClusterConfiguration:
3737
machine_types: list = field(default_factory=list) # ["m4.xlarge", "g4dn.xlarge"]
3838
min_cpus: int = 1
3939
max_cpus: int = 1
40-
min_worker: int = 1
41-
max_worker: int = 1
40+
worker: int = 1
4241
min_memory: int = 2
4342
max_memory: int = 2
4443
gpu: int = 0

src/codeflare_sdk/cluster/model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class RayCluster:
6767

6868
name: str
6969
status: RayClusterStatus
70-
min_workers: int
71-
max_workers: int
70+
workers: int
7271
worker_mem_min: str
7372
worker_mem_max: str
7473
worker_cpu: int

src/codeflare_sdk/job/jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
self.workspace = workspace
9292

9393
def _dry_run(self, cluster: "Cluster"):
94-
j = f"{cluster.config.max_worker}x{max(cluster.config.gpu, 1)}" # # of proc. = # of gpus
94+
j = f"{cluster.config.worker}x{max(cluster.config.gpu, 1)}" # # of proc. = # of gpus
9595
return torchx_runner.dryrun(
9696
app=ddp(
9797
*self.script_args,

src/codeflare_sdk/utils/pretty_print.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def print_clusters(clusters: List[RayCluster]):
115115
)
116116
name = cluster.name
117117
dashboard = cluster.dashboard
118-
mincount = str(cluster.min_workers)
119-
maxcount = str(cluster.max_workers)
118+
workers = str(cluster.workers)
120119
memory = str(cluster.worker_mem_min) + "~" + str(cluster.worker_mem_max)
121120
cpu = str(cluster.worker_cpu)
122121
gpu = str(cluster.worker_gpu)
@@ -142,10 +141,10 @@ def print_clusters(clusters: List[RayCluster]):
142141
#'table1' to display the worker counts
143142
table1 = Table(box=None)
144143
table1.add_row()
145-
table1.add_column("Min", style="cyan", no_wrap=True)
146-
table1.add_column("Max", style="magenta")
144+
# table1.add_column("Min", style="cyan", no_wrap=True)
145+
table1.add_column("# Workers", style="magenta")
147146
table1.add_row()
148-
table1.add_row(mincount, maxcount)
147+
table1.add_row(workers)
149148
table1.add_row()
150149

151150
#'table2' to display the worker resources

0 commit comments

Comments
 (0)