@@ -60,7 +60,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
60
60
61
61
def print_no_resources_found():
62
62
console = Console()
63
- console.print(Panel("[red]No resources found"))
63
+ console.print(Panel("[red]No resources found, have you run cluster.up() yet? "))
64
64
65
65
66
66
def print_app_wrappers_status(app_wrappers: List[AppWrapper]):
@@ -69,22 +69,66 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
69
69
return # shortcircuit
70
70
71
71
console = Console()
72
+ table = Table(
73
+ box=box.ASCII_DOUBLE_HEAD,
74
+ title="[bold] :rocket: Cluster Queue Status :rocket:",
75
+ )
76
+ table.add_column("Name", style="cyan", no_wrap=True)
77
+ table.add_column("Status", style="magenta")
78
+
72
79
for app_wrapper in app_wrappers:
73
80
name = app_wrapper.name
74
81
status = app_wrapper.status.value
75
-
76
- table = Table(
77
- box=box.ASCII_DOUBLE_HEAD,
78
- title="[bold] :rocket: List of CodeFlare clusters in queue:rocket:",
79
- )
80
- table.add_column("Name", style="cyan", no_wrap=True)
81
- table.add_column("Status", style="magenta")
82
82
table.add_row(name, status)
83
83
table.add_row("") # empty row for spacing
84
- console.print(Panel.fit(table))
85
84
85
+ console.print(Panel.fit(table))
86
+
87
+
88
+ def print_cluster_status(cluster: RayCluster):
89
+ "Pretty prints the status of a passed-in cluster"
90
+ if not cluster:
91
+ print_no_resources_found
92
+ return
86
93
87
- def print_clusters(clusters: List[RayCluster], verbose=True):
94
+ console = Console()
95
+ status = (
96
+ "Active :white_heavy_check_mark:"
97
+ if cluster.status == RayClusterStatus.READY
98
+ else "Inactive :x:"
99
+ )
100
+ name = cluster.name
101
+ dashboard = cluster.dashboard
102
+ # owned = bool(cluster["userOwned"])
103
+ owned = True
104
+
105
+ #'table0' to display the cluster name, status, url, and dashboard link
106
+ table0 = Table(box=None, show_header=False)
107
+ if owned:
108
+ table0.add_row("[white on green][bold]Name")
109
+ else:
110
+ table0.add_row("")
111
+ table0.add_row("[bold underline]" + name, status)
112
+ table0.add_row()
113
+ # fixme harcded to default for now
114
+ table0.add_row(
115
+ f"[bold]URI:[/bold] ray://{cluster.name}-head-svc.{cluster.namespace}.svc:10001"
116
+ ) # format that is used to generate the name of the service
117
+ table0.add_row()
118
+ table0.add_row(f"[link={dashboard} blue underline]Dashboard:link:[/link]")
119
+ table0.add_row("") # empty row for spacing
120
+
121
+ # table4 to display table0 and table3, one below the other
122
+ table4 = Table(box=None, show_header=False)
123
+ table4.add_row(table0)
124
+
125
+ # Encompass all details of the cluster in a single panel
126
+ table5 = Table(box=None, title="[bold] :rocket: CodeFlare Cluster Status :rocket:")
127
+ table5.add_row(Panel.fit(table4))
128
+ console.print(table5)
129
+
130
+
131
+ def print_clusters(clusters: List[RayCluster]):
88
132
if not clusters:
89
133
print_no_resources_found()
90
134
return # shortcircuit
@@ -96,13 +140,13 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
96
140
status = (
97
141
"Active :white_heavy_check_mark:"
98
142
if cluster.status == RayClusterStatus.READY
99
- else "InActive :x:"
143
+ else "Inactive :x:"
100
144
)
101
145
name = cluster.name
102
146
dashboard = cluster.dashboard
103
147
mincount = str(cluster.min_workers)
104
148
maxcount = str(cluster.max_workers)
105
- memory = cluster.worker_mem_min + "~" + cluster.worker_mem_max
149
+ memory = str( cluster.worker_mem_min) + "~" + str( cluster.worker_mem_max)
106
150
cpu = str(cluster.worker_cpu)
107
151
gpu = str(cluster.worker_gpu)
108
152
# owned = bool(cluster["userOwned"])
@@ -111,7 +155,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
111
155
#'table0' to display the cluster name, status, url, and dashboard link
112
156
table0 = Table(box=None, show_header=False)
113
157
if owned:
114
- table0.add_row("[white on green][bold]Owner ")
158
+ table0.add_row("[white on green][bold]Name ")
115
159
else:
116
160
table0.add_row("")
117
161
table0.add_row("[bold underline]" + name, status)
@@ -162,7 +206,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
162
206
# than being center aligned on the console/terminal if we simply use console.print(title)
163
207
164
208
table5 = Table(
165
- box=None, title="[bold] :rocket: List of CodeFlare clusters :rocket:"
209
+ box=None, title="[bold] :rocket: CodeFlare Cluster Details :rocket:"
166
210
)
167
211
table5.add_row(Panel.fit(table4))
168
212
console.print(table5)
@@ -193,31 +237,84 @@ <h2 class="section-title" id="header-functions">Functions</h2>
193
237
return # shortcircuit
194
238
195
239
console = Console()
240
+ table = Table(
241
+ box=box.ASCII_DOUBLE_HEAD,
242
+ title="[bold] :rocket: Cluster Queue Status :rocket:",
243
+ )
244
+ table.add_column("Name", style="cyan", no_wrap=True)
245
+ table.add_column("Status", style="magenta")
246
+
196
247
for app_wrapper in app_wrappers:
197
248
name = app_wrapper.name
198
249
status = app_wrapper.status.value
199
-
200
- table = Table(
201
- box=box.ASCII_DOUBLE_HEAD,
202
- title="[bold] :rocket: List of CodeFlare clusters in queue:rocket:",
203
- )
204
- table.add_column("Name", style="cyan", no_wrap=True)
205
- table.add_column("Status", style="magenta")
206
250
table.add_row(name, status)
207
251
table.add_row("") # empty row for spacing
208
- console.print(Panel.fit(table))</ code > </ pre >
252
+
253
+ console.print(Panel.fit(table))</ code > </ pre >
254
+ </ details >
255
+ </ dd >
256
+ < dt id ="codeflare_sdk.utils.pretty_print.print_cluster_status "> < code class ="name flex ">
257
+ < span > def < span class ="ident "> print_cluster_status</ span > </ span > (< span > cluster: < a title ="codeflare_sdk.cluster.model.RayCluster " href ="../cluster/model.html#codeflare_sdk.cluster.model.RayCluster "> RayCluster</ a > )</ span >
258
+ </ code > </ dt >
259
+ < dd >
260
+ < div class ="desc "> < p > Pretty prints the status of a passed-in cluster</ p > </ div >
261
+ < details class ="source ">
262
+ < summary >
263
+ < span > Expand source code</ span >
264
+ </ summary >
265
+ < pre > < code class ="python "> def print_cluster_status(cluster: RayCluster):
266
+ "Pretty prints the status of a passed-in cluster"
267
+ if not cluster:
268
+ print_no_resources_found
269
+ return
270
+
271
+ console = Console()
272
+ status = (
273
+ "Active :white_heavy_check_mark:"
274
+ if cluster.status == RayClusterStatus.READY
275
+ else "Inactive :x:"
276
+ )
277
+ name = cluster.name
278
+ dashboard = cluster.dashboard
279
+ # owned = bool(cluster["userOwned"])
280
+ owned = True
281
+
282
+ #'table0' to display the cluster name, status, url, and dashboard link
283
+ table0 = Table(box=None, show_header=False)
284
+ if owned:
285
+ table0.add_row("[white on green][bold]Name")
286
+ else:
287
+ table0.add_row("")
288
+ table0.add_row("[bold underline]" + name, status)
289
+ table0.add_row()
290
+ # fixme harcded to default for now
291
+ table0.add_row(
292
+ f"[bold]URI:[/bold] ray://{cluster.name}-head-svc.{cluster.namespace}.svc:10001"
293
+ ) # format that is used to generate the name of the service
294
+ table0.add_row()
295
+ table0.add_row(f"[link={dashboard} blue underline]Dashboard:link:[/link]")
296
+ table0.add_row("") # empty row for spacing
297
+
298
+ # table4 to display table0 and table3, one below the other
299
+ table4 = Table(box=None, show_header=False)
300
+ table4.add_row(table0)
301
+
302
+ # Encompass all details of the cluster in a single panel
303
+ table5 = Table(box=None, title="[bold] :rocket: CodeFlare Cluster Status :rocket:")
304
+ table5.add_row(Panel.fit(table4))
305
+ console.print(table5)</ code > </ pre >
209
306
</ details >
210
307
</ dd >
211
308
< dt id ="codeflare_sdk.utils.pretty_print.print_clusters "> < code class ="name flex ">
212
- < span > def < span class ="ident "> print_clusters</ span > </ span > (< span > clusters: List[< a title ="codeflare_sdk.cluster.model.RayCluster " href ="../cluster/model.html#codeflare_sdk.cluster.model.RayCluster "> RayCluster</ a > ], verbose=True )</ span >
309
+ < span > def < span class ="ident "> print_clusters</ span > </ span > (< span > clusters: List[< a title ="codeflare_sdk.cluster.model.RayCluster " href ="../cluster/model.html#codeflare_sdk.cluster.model.RayCluster "> RayCluster</ a > ])</ span >
213
310
</ code > </ dt >
214
311
< dd >
215
312
< div class ="desc "> </ div >
216
313
< details class ="source ">
217
314
< summary >
218
315
< span > Expand source code</ span >
219
316
</ summary >
220
- < pre > < code class ="python "> def print_clusters(clusters: List[RayCluster], verbose=True ):
317
+ < pre > < code class ="python "> def print_clusters(clusters: List[RayCluster]):
221
318
if not clusters:
222
319
print_no_resources_found()
223
320
return # shortcircuit
@@ -229,13 +326,13 @@ <h2 class="section-title" id="header-functions">Functions</h2>
229
326
status = (
230
327
"Active :white_heavy_check_mark:"
231
328
if cluster.status == RayClusterStatus.READY
232
- else "InActive :x:"
329
+ else "Inactive :x:"
233
330
)
234
331
name = cluster.name
235
332
dashboard = cluster.dashboard
236
333
mincount = str(cluster.min_workers)
237
334
maxcount = str(cluster.max_workers)
238
- memory = cluster.worker_mem_min + "~" + cluster.worker_mem_max
335
+ memory = str( cluster.worker_mem_min) + "~" + str( cluster.worker_mem_max)
239
336
cpu = str(cluster.worker_cpu)
240
337
gpu = str(cluster.worker_gpu)
241
338
# owned = bool(cluster["userOwned"])
@@ -244,7 +341,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
244
341
#'table0' to display the cluster name, status, url, and dashboard link
245
342
table0 = Table(box=None, show_header=False)
246
343
if owned:
247
- table0.add_row("[white on green][bold]Owner ")
344
+ table0.add_row("[white on green][bold]Name ")
248
345
else:
249
346
table0.add_row("")
250
347
table0.add_row("[bold underline]" + name, status)
@@ -295,7 +392,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
295
392
# than being center aligned on the console/terminal if we simply use console.print(title)
296
393
297
394
table5 = Table(
298
- box=None, title="[bold] :rocket: List of CodeFlare clusters :rocket:"
395
+ box=None, title="[bold] :rocket: CodeFlare Cluster Details :rocket:"
299
396
)
300
397
table5.add_row(Panel.fit(table4))
301
398
console.print(table5)
@@ -315,7 +412,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
315
412
</ summary >
316
413
< pre > < code class ="python "> def print_no_resources_found():
317
414
console = Console()
318
- console.print(Panel("[red]No resources found"))</ code > </ pre >
415
+ console.print(Panel("[red]No resources found, have you run cluster.up() yet? "))</ code > </ pre >
319
416
</ details >
320
417
</ dd >
321
418
</ dl >
@@ -337,6 +434,7 @@ <h1>Index</h1>
337
434
< li > < h3 > < a href ="#header-functions "> Functions</ a > </ h3 >
338
435
< ul class ="">
339
436
< li > < code > < a title ="codeflare_sdk.utils.pretty_print.print_app_wrappers_status " href ="#codeflare_sdk.utils.pretty_print.print_app_wrappers_status "> print_app_wrappers_status</ a > </ code > </ li >
437
+ < li > < code > < a title ="codeflare_sdk.utils.pretty_print.print_cluster_status " href ="#codeflare_sdk.utils.pretty_print.print_cluster_status "> print_cluster_status</ a > </ code > </ li >
340
438
< li > < code > < a title ="codeflare_sdk.utils.pretty_print.print_clusters " href ="#codeflare_sdk.utils.pretty_print.print_clusters "> print_clusters</ a > </ code > </ li >
341
439
< li > < code > < a title ="codeflare_sdk.utils.pretty_print.print_no_resources_found " href ="#codeflare_sdk.utils.pretty_print.print_no_resources_found "> print_no_resources_found</ a > </ code > </ li >
342
440
</ ul >
0 commit comments