Skip to content

Commit fb49dc5

Browse files
authoredMar 6, 2023
Update docs, demos, and version (#71)
1 parent a49602e commit fb49dc5

File tree

9 files changed

+721
-298
lines changed

9 files changed

+721
-298
lines changed
 

‎demo-notebooks/batch-job/batch_mnist.ipynb

+47-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
" token = \"XXXX\",\n",
2525
" server = \"XXXX\",\n",
2626
" skip_tls=True\n",
27-
")"
27+
")\n",
28+
"auth.login()"
2829
]
2930
},
3031
{
@@ -43,7 +44,7 @@
4344
"outputs": [],
4445
"source": [
4546
"# Create our cluster and submit appwrapper\n",
46-
"cluster = Cluster(ClusterConfiguration(name='mnisttest', min_worker=2, max_worker=2, min_cpus=8, max_cpus=8, min_memory=16, max_memory=16, gpu=4, instascale=True, machine_types=[\"m5.xlarge\", \"p3.8xlarge\"], auth=auth))"
47+
"cluster = Cluster(ClusterConfiguration(name='mnisttest', min_worker=2, max_worker=2, min_cpus=8, max_cpus=8, min_memory=16, max_memory=16, gpu=4, instascale=True, machine_types=[\"m5.xlarge\", \"p3.8xlarge\"]))"
4748
]
4849
},
4950
{
@@ -66,11 +67,12 @@
6667
]
6768
},
6869
{
70+
"attachments": {},
6971
"cell_type": "markdown",
7072
"id": "657ebdfb",
7173
"metadata": {},
7274
"source": [
73-
"Now, we want to check on the status of our resource cluster, until it is finally ready for use."
75+
"Now, we want to check on the status of our resource cluster, and wait until it is finally ready for use."
7476
]
7577
},
7678
{
@@ -122,7 +124,36 @@
122124
}
123125
],
124126
"source": [
125-
"cluster.is_ready()"
127+
"cluster.status()"
128+
]
129+
},
130+
{
131+
"cell_type": "code",
132+
"execution_count": null,
133+
"id": "a99d5aff",
134+
"metadata": {},
135+
"outputs": [],
136+
"source": [
137+
"cluster.wait_ready()"
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"execution_count": null,
143+
"id": "df71c1ed",
144+
"metadata": {},
145+
"outputs": [],
146+
"source": [
147+
"cluster.status()"
148+
]
149+
},
150+
{
151+
"attachments": {},
152+
"cell_type": "markdown",
153+
"id": "b3a55fe4",
154+
"metadata": {},
155+
"source": [
156+
"Let's quickly verify that the specs of the cluster are as expected."
126157
]
127158
},
128159
{
@@ -190,7 +221,7 @@
190221
}
191222
],
192223
"source": [
193-
"cluster.status()"
224+
"cluster.details()"
194225
]
195226
},
196227
{
@@ -1994,6 +2025,16 @@
19942025
"source": [
19952026
"cluster.down()"
19962027
]
2028+
},
2029+
{
2030+
"cell_type": "code",
2031+
"execution_count": null,
2032+
"id": "0d41b90e",
2033+
"metadata": {},
2034+
"outputs": [],
2035+
"source": [
2036+
"auth.logout()"
2037+
]
19972038
}
19982039
],
19992040
"metadata": {
@@ -2012,7 +2053,7 @@
20122053
"name": "python",
20132054
"nbconvert_exporter": "python",
20142055
"pygments_lexer": "ipython3",
2015-
"version": "3.9.7"
2056+
"version": "3.9.13"
20162057
},
20172058
"vscode": {
20182059
"interpreter": {

‎demo-notebooks/interactive/hf_interactive.ipynb

+48-7
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
56-
"# Create authentication object for oc user permissions\n",
56+
"# Create authentication object for oc user permissions and login\n",
5757
"auth = TokenAuthentication(\n",
5858
" token = \"XXXX\",\n",
5959
" server = \"XXXX\",\n",
6060
" skip_tls = True\n",
61-
")"
61+
")\n",
62+
"auth.login()"
6263
]
6364
},
6465
{
@@ -85,7 +86,7 @@
8586
],
8687
"source": [
8788
"# Create our cluster and submit appwrapper\n",
88-
"cluster = Cluster(ClusterConfiguration(name='hfgputest', min_worker=1, max_worker=1, min_cpus=8, max_cpus=8, min_memory=16, max_memory=16, gpu=4, instascale=True, machine_types=[\"m5.xlarge\", \"p3.8xlarge\"], auth=auth))"
89+
"cluster = Cluster(ClusterConfiguration(name='hfgputest', min_worker=1, max_worker=1, min_cpus=8, max_cpus=8, min_memory=16, max_memory=16, gpu=4, instascale=True, machine_types=[\"m5.xlarge\", \"p3.8xlarge\"]))"
8990
]
9091
},
9192
{
@@ -107,11 +108,12 @@
107108
]
108109
},
109110
{
111+
"attachments": {},
110112
"cell_type": "markdown",
111113
"id": "657ebdfb",
112114
"metadata": {},
113115
"source": [
114-
"Now, we want to check on the status of our resource cluster, until it is finally ready for use."
116+
"Now, we want to check on the initial status of our resource cluster, then wait until it is finally ready for use."
115117
]
116118
},
117119
{
@@ -163,7 +165,36 @@
163165
}
164166
],
165167
"source": [
166-
"cluster.is_ready()"
168+
"cluster.status()"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": null,
174+
"id": "1d26275e",
175+
"metadata": {},
176+
"outputs": [],
177+
"source": [
178+
"cluster.wait_ready()"
179+
]
180+
},
181+
{
182+
"cell_type": "code",
183+
"execution_count": null,
184+
"id": "d2969a4b",
185+
"metadata": {},
186+
"outputs": [],
187+
"source": [
188+
"cluster.status()"
189+
]
190+
},
191+
{
192+
"attachments": {},
193+
"cell_type": "markdown",
194+
"id": "477ac246",
195+
"metadata": {},
196+
"source": [
197+
"Let's quickly verify that the specs of the cluster are as expected."
167198
]
168199
},
169200
{
@@ -231,7 +262,7 @@
231262
}
232263
],
233264
"source": [
234-
"cluster.status()"
265+
"cluster.details()"
235266
]
236267
},
237268
{
@@ -1379,6 +1410,16 @@
13791410
"cluster.down()"
13801411
]
13811412
},
1413+
{
1414+
"cell_type": "code",
1415+
"execution_count": null,
1416+
"id": "61bf4946",
1417+
"metadata": {},
1418+
"outputs": [],
1419+
"source": [
1420+
"auth.logout()"
1421+
]
1422+
},
13821423
{
13831424
"cell_type": "markdown",
13841425
"id": "2b7a183b-5e8e-4adb-b9a6-a349e13512a0",
@@ -1416,7 +1457,7 @@
14161457
"name": "python",
14171458
"nbconvert_exporter": "python",
14181459
"pygments_lexer": "ipython3",
1419-
"version": "3.9.7"
1460+
"version": "3.9.13"
14201461
},
14211462
"vscode": {
14221463
"interpreter": {

‎docs/cluster/auth.html

+28-19
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
9292
self.server = server
9393
self.skip_tls = skip_tls
9494

95-
def login(self):
95+
def login(self) -&gt; str:
9696
&#34;&#34;&#34;
9797
This function is used to login to an OpenShift cluster using the user&#39;s API token and API server address.
9898
Depending on the cluster, a user can choose to login in with &#34;--insecure-skip-tls-verify` by setting `skip_tls`
@@ -107,15 +107,18 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
107107
error_msg = osp.result.err()
108108
if &#34;The server uses a certificate signed by unknown authority&#34; in error_msg:
109109
return &#34;Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication&#34;
110+
elif &#34;invalid&#34; in error_msg:
111+
raise PermissionError(error_msg)
110112
else:
111113
return error_msg
112114
return response.out()
113115

114-
def logout(self):
116+
def logout(self) -&gt; str:
115117
&#34;&#34;&#34;
116118
This function is used to logout of an OpenShift cluster.
117119
&#34;&#34;&#34;
118-
response = oc.invoke(&#34;logout&#34;)
120+
args = [f&#34;--token={self.token}&#34;, f&#34;--server={self.server}:6443&#34;]
121+
response = oc.invoke(&#34;logout&#34;, args)
119122
return response.out()
120123

121124

@@ -137,14 +140,14 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
137140
self.username = username
138141
self.password = password
139142

140-
def login(self):
143+
def login(self) -&gt; str:
141144
&#34;&#34;&#34;
142145
This function is used to login to an OpenShift cluster using the user&#39;s `username` and `password`.
143146
&#34;&#34;&#34;
144147
response = oc.login(self.username, self.password)
145148
return response.out()
146149

147-
def logout(self):
150+
def logout(self) -&gt; str:
148151
&#34;&#34;&#34;
149152
This function is used to logout of an OpenShift cluster.
150153
&#34;&#34;&#34;
@@ -261,14 +264,14 @@ <h3>Methods</h3>
261264
self.username = username
262265
self.password = password
263266

264-
def login(self):
267+
def login(self) -&gt; str:
265268
&#34;&#34;&#34;
266269
This function is used to login to an OpenShift cluster using the user&#39;s `username` and `password`.
267270
&#34;&#34;&#34;
268271
response = oc.login(self.username, self.password)
269272
return response.out()
270273

271-
def logout(self):
274+
def logout(self) -&gt; str:
272275
&#34;&#34;&#34;
273276
This function is used to logout of an OpenShift cluster.
274277
&#34;&#34;&#34;
@@ -282,15 +285,15 @@ <h3>Ancestors</h3>
282285
<h3>Methods</h3>
283286
<dl>
284287
<dt id="codeflare_sdk.cluster.auth.PasswordUserAuthentication.login"><code class="name flex">
285-
<span>def <span class="ident">login</span></span>(<span>self)</span>
288+
<span>def <span class="ident">login</span></span>(<span>self)> str</span>
286289
</code></dt>
287290
<dd>
288291
<div class="desc"><p>This function is used to login to an OpenShift cluster using the user's <code>username</code> and <code>password</code>.</p></div>
289292
<details class="source">
290293
<summary>
291294
<span>Expand source code</span>
292295
</summary>
293-
<pre><code class="python">def login(self):
296+
<pre><code class="python">def login(self) -&gt; str:
294297
&#34;&#34;&#34;
295298
This function is used to login to an OpenShift cluster using the user&#39;s `username` and `password`.
296299
&#34;&#34;&#34;
@@ -299,15 +302,15 @@ <h3>Methods</h3>
299302
</details>
300303
</dd>
301304
<dt id="codeflare_sdk.cluster.auth.PasswordUserAuthentication.logout"><code class="name flex">
302-
<span>def <span class="ident">logout</span></span>(<span>self)</span>
305+
<span>def <span class="ident">logout</span></span>(<span>self)> str</span>
303306
</code></dt>
304307
<dd>
305308
<div class="desc"><p>This function is used to logout of an OpenShift cluster.</p></div>
306309
<details class="source">
307310
<summary>
308311
<span>Expand source code</span>
309312
</summary>
310-
<pre><code class="python">def logout(self):
313+
<pre><code class="python">def logout(self) -&gt; str:
311314
&#34;&#34;&#34;
312315
This function is used to logout of an OpenShift cluster.
313316
&#34;&#34;&#34;
@@ -346,7 +349,7 @@ <h3>Methods</h3>
346349
self.server = server
347350
self.skip_tls = skip_tls
348351

349-
def login(self):
352+
def login(self) -&gt; str:
350353
&#34;&#34;&#34;
351354
This function is used to login to an OpenShift cluster using the user&#39;s API token and API server address.
352355
Depending on the cluster, a user can choose to login in with &#34;--insecure-skip-tls-verify` by setting `skip_tls`
@@ -361,15 +364,18 @@ <h3>Methods</h3>
361364
error_msg = osp.result.err()
362365
if &#34;The server uses a certificate signed by unknown authority&#34; in error_msg:
363366
return &#34;Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication&#34;
367+
elif &#34;invalid&#34; in error_msg:
368+
raise PermissionError(error_msg)
364369
else:
365370
return error_msg
366371
return response.out()
367372

368-
def logout(self):
373+
def logout(self) -&gt; str:
369374
&#34;&#34;&#34;
370375
This function is used to logout of an OpenShift cluster.
371376
&#34;&#34;&#34;
372-
response = oc.invoke(&#34;logout&#34;)
377+
args = [f&#34;--token={self.token}&#34;, f&#34;--server={self.server}:6443&#34;]
378+
response = oc.invoke(&#34;logout&#34;, args)
373379
return response.out()</code></pre>
374380
</details>
375381
<h3>Ancestors</h3>
@@ -379,7 +385,7 @@ <h3>Ancestors</h3>
379385
<h3>Methods</h3>
380386
<dl>
381387
<dt id="codeflare_sdk.cluster.auth.TokenAuthentication.login"><code class="name flex">
382-
<span>def <span class="ident">login</span></span>(<span>self)</span>
388+
<span>def <span class="ident">login</span></span>(<span>self)> str</span>
383389
</code></dt>
384390
<dd>
385391
<div class="desc"><p>This function is used to login to an OpenShift cluster using the user's API token and API server address.
@@ -389,7 +395,7 @@ <h3>Methods</h3>
389395
<summary>
390396
<span>Expand source code</span>
391397
</summary>
392-
<pre><code class="python">def login(self):
398+
<pre><code class="python">def login(self) -&gt; str:
393399
&#34;&#34;&#34;
394400
This function is used to login to an OpenShift cluster using the user&#39;s API token and API server address.
395401
Depending on the cluster, a user can choose to login in with &#34;--insecure-skip-tls-verify` by setting `skip_tls`
@@ -404,25 +410,28 @@ <h3>Methods</h3>
404410
error_msg = osp.result.err()
405411
if &#34;The server uses a certificate signed by unknown authority&#34; in error_msg:
406412
return &#34;Error: certificate auth failure, please set `skip_tls=True` in TokenAuthentication&#34;
413+
elif &#34;invalid&#34; in error_msg:
414+
raise PermissionError(error_msg)
407415
else:
408416
return error_msg
409417
return response.out()</code></pre>
410418
</details>
411419
</dd>
412420
<dt id="codeflare_sdk.cluster.auth.TokenAuthentication.logout"><code class="name flex">
413-
<span>def <span class="ident">logout</span></span>(<span>self)</span>
421+
<span>def <span class="ident">logout</span></span>(<span>self)> str</span>
414422
</code></dt>
415423
<dd>
416424
<div class="desc"><p>This function is used to logout of an OpenShift cluster.</p></div>
417425
<details class="source">
418426
<summary>
419427
<span>Expand source code</span>
420428
</summary>
421-
<pre><code class="python">def logout(self):
429+
<pre><code class="python">def logout(self) -&gt; str:
422430
&#34;&#34;&#34;
423431
This function is used to logout of an OpenShift cluster.
424432
&#34;&#34;&#34;
425-
response = oc.invoke(&#34;logout&#34;)
433+
args = [f&#34;--token={self.token}&#34;, f&#34;--server={self.server}:6443&#34;]
434+
response = oc.invoke(&#34;logout&#34;, args)
426435
return response.out()</code></pre>
427436
</details>
428437
</dd>

‎docs/cluster/cluster.html

+451-217
Large diffs are not rendered by default.

‎docs/cluster/config.html

+3-10
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.config</code></h1>
7878
template: str = f&#34;{dir}/templates/new-template.yaml&#34;
7979
instascale: bool = False
8080
envs: dict = field(default_factory=dict)
81-
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;
82-
auth: Authentication = Authentication()</code></pre>
81+
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;</code></pre>
8382
</details>
8483
</section>
8584
<section>
@@ -93,7 +92,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9392
<dl>
9493
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration"><code class="flex name class">
9594
<span>class <span class="ident">ClusterConfiguration</span></span>
96-
<span>(</span><span>name: str, namespace: str = 'default', head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, min_cpus: int = 1, max_cpus: int = 1, min_worker: int = 1, max_worker: int = 1, min_memory: int = 2, max_memory: int = 2, gpu: int = 0, template: str = '/home/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/templates/new-template.yaml', instascale: bool = False, envs: dict = &lt;factory&gt;, image: str = 'ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103', auth: <a title="codeflare_sdk.cluster.auth.Authentication" href="auth.html#codeflare_sdk.cluster.auth.Authentication">Authentication</a> = &lt;codeflare_sdk.cluster.auth.Authentication object&gt;)</span>
95+
<span>(</span><span>name: str, namespace: str = 'default', head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, min_cpus: int = 1, max_cpus: int = 1, min_worker: int = 1, max_worker: int = 1, min_memory: int = 2, max_memory: int = 2, gpu: int = 0, template: str = '/home/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/templates/new-template.yaml', instascale: bool = False, envs: dict = &lt;factory&gt;, image: str = 'ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103')</span>
9796
</code></dt>
9897
<dd>
9998
<div class="desc"><p>This dataclass is used to specify resource requirements and other details, and
@@ -122,15 +121,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
122121
template: str = f&#34;{dir}/templates/new-template.yaml&#34;
123122
instascale: bool = False
124123
envs: dict = field(default_factory=dict)
125-
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;
126-
auth: Authentication = Authentication()</code></pre>
124+
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;</code></pre>
127125
</details>
128126
<h3>Class variables</h3>
129127
<dl>
130-
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration.auth"><code class="name">var <span class="ident">auth</span><a title="codeflare_sdk.cluster.auth.Authentication" href="auth.html#codeflare_sdk.cluster.auth.Authentication">Authentication</a></code></dt>
131-
<dd>
132-
<div class="desc"></div>
133-
</dd>
134128
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration.envs"><code class="name">var <span class="ident">envs</span> : dict</code></dt>
135129
<dd>
136130
<div class="desc"></div>
@@ -212,7 +206,6 @@ <h1>Index</h1>
212206
<li>
213207
<h4><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration" href="#codeflare_sdk.cluster.config.ClusterConfiguration">ClusterConfiguration</a></code></h4>
214208
<ul class="two-column">
215-
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.auth" href="#codeflare_sdk.cluster.config.ClusterConfiguration.auth">auth</a></code></li>
216209
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.envs" href="#codeflare_sdk.cluster.config.ClusterConfiguration.envs">envs</a></code></li>
217210
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.gpu" href="#codeflare_sdk.cluster.config.ClusterConfiguration.gpu">gpu</a></code></li>
218211
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.head_info" href="#codeflare_sdk.cluster.config.ClusterConfiguration.head_info">head_info</a></code></li>

‎docs/cluster/model.html

+13-6
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.model</code></h1>
8686
&#34;&#34;&#34;
8787

8888
READY = 1
89-
QUEUED = 2
90-
FAILED = 3
91-
UNKNOWN = 4
89+
STARTING = 2
90+
QUEUED = 3
91+
FAILED = 4
92+
UNKNOWN = 5
9293

9394

9495
@dataclass
@@ -240,9 +241,10 @@ <h3>Class variables</h3>
240241
&#34;&#34;&#34;
241242

242243
READY = 1
243-
QUEUED = 2
244-
FAILED = 3
245-
UNKNOWN = 4</code></pre>
244+
STARTING = 2
245+
QUEUED = 3
246+
FAILED = 4
247+
UNKNOWN = 5</code></pre>
246248
</details>
247249
<h3>Ancestors</h3>
248250
<ul class="hlist">
@@ -262,6 +264,10 @@ <h3>Class variables</h3>
262264
<dd>
263265
<div class="desc"></div>
264266
</dd>
267+
<dt id="codeflare_sdk.cluster.model.CodeFlareClusterStatus.STARTING"><code class="name">var <span class="ident">STARTING</span></code></dt>
268+
<dd>
269+
<div class="desc"></div>
270+
</dd>
265271
<dt id="codeflare_sdk.cluster.model.CodeFlareClusterStatus.UNKNOWN"><code class="name">var <span class="ident">UNKNOWN</span></code></dt>
266272
<dd>
267273
<div class="desc"></div>
@@ -425,6 +431,7 @@ <h4><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus" href="#c
425431
<li><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus.FAILED" href="#codeflare_sdk.cluster.model.CodeFlareClusterStatus.FAILED">FAILED</a></code></li>
426432
<li><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus.QUEUED" href="#codeflare_sdk.cluster.model.CodeFlareClusterStatus.QUEUED">QUEUED</a></code></li>
427433
<li><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus.READY" href="#codeflare_sdk.cluster.model.CodeFlareClusterStatus.READY">READY</a></code></li>
434+
<li><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus.STARTING" href="#codeflare_sdk.cluster.model.CodeFlareClusterStatus.STARTING">STARTING</a></code></li>
428435
<li><code><a title="codeflare_sdk.cluster.model.CodeFlareClusterStatus.UNKNOWN" href="#codeflare_sdk.cluster.model.CodeFlareClusterStatus.UNKNOWN">UNKNOWN</a></code></li>
429436
</ul>
430437
</li>

‎docs/utils/generate_yaml.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
271271
return outfile
272272

273273

274-
def main():
274+
def main(): # pragma: no cover
275275
parser = argparse.ArgumentParser(description=&#34;Generate user AppWrapper&#34;)
276276
parser.add_argument(
277277
&#34;--name&#34;,
@@ -379,7 +379,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.generate_yaml</code></h1>
379379
return outfile
380380

381381

382-
if __name__ == &#34;__main__&#34;:
382+
if __name__ == &#34;__main__&#34;: # pragma: no cover
383383
main()</code></pre>
384384
</details>
385385
</section>
@@ -471,7 +471,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
471471
<summary>
472472
<span>Expand source code</span>
473473
</summary>
474-
<pre><code class="python">def main():
474+
<pre><code class="python">def main(): # pragma: no cover
475475
parser = argparse.ArgumentParser(description=&#34;Generate user AppWrapper&#34;)
476476
parser.add_argument(
477477
&#34;--name&#34;,

‎docs/utils/pretty_print.html

+127-29
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
6060

6161
def print_no_resources_found():
6262
console = Console()
63-
console.print(Panel(&#34;[red]No resources found&#34;))
63+
console.print(Panel(&#34;[red]No resources found, have you run cluster.up() yet?&#34;))
6464

6565

6666
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>
6969
return # shortcircuit
7070

7171
console = Console()
72+
table = Table(
73+
box=box.ASCII_DOUBLE_HEAD,
74+
title=&#34;[bold] :rocket: Cluster Queue Status :rocket:&#34;,
75+
)
76+
table.add_column(&#34;Name&#34;, style=&#34;cyan&#34;, no_wrap=True)
77+
table.add_column(&#34;Status&#34;, style=&#34;magenta&#34;)
78+
7279
for app_wrapper in app_wrappers:
7380
name = app_wrapper.name
7481
status = app_wrapper.status.value
75-
76-
table = Table(
77-
box=box.ASCII_DOUBLE_HEAD,
78-
title=&#34;[bold] :rocket: List of CodeFlare clusters in queue:rocket:&#34;,
79-
)
80-
table.add_column(&#34;Name&#34;, style=&#34;cyan&#34;, no_wrap=True)
81-
table.add_column(&#34;Status&#34;, style=&#34;magenta&#34;)
8282
table.add_row(name, status)
8383
table.add_row(&#34;&#34;) # empty row for spacing
84-
console.print(Panel.fit(table))
8584

85+
console.print(Panel.fit(table))
86+
87+
88+
def print_cluster_status(cluster: RayCluster):
89+
&#34;Pretty prints the status of a passed-in cluster&#34;
90+
if not cluster:
91+
print_no_resources_found
92+
return
8693

87-
def print_clusters(clusters: List[RayCluster], verbose=True):
94+
console = Console()
95+
status = (
96+
&#34;Active :white_heavy_check_mark:&#34;
97+
if cluster.status == RayClusterStatus.READY
98+
else &#34;Inactive :x:&#34;
99+
)
100+
name = cluster.name
101+
dashboard = cluster.dashboard
102+
# owned = bool(cluster[&#34;userOwned&#34;])
103+
owned = True
104+
105+
#&#39;table0&#39; 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(&#34;[white on green][bold]Name&#34;)
109+
else:
110+
table0.add_row(&#34;&#34;)
111+
table0.add_row(&#34;[bold underline]&#34; + name, status)
112+
table0.add_row()
113+
# fixme harcded to default for now
114+
table0.add_row(
115+
f&#34;[bold]URI:[/bold] ray://{cluster.name}-head-svc.{cluster.namespace}.svc:10001&#34;
116+
) # format that is used to generate the name of the service
117+
table0.add_row()
118+
table0.add_row(f&#34;[link={dashboard} blue underline]Dashboard:link:[/link]&#34;)
119+
table0.add_row(&#34;&#34;) # 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=&#34;[bold] :rocket: CodeFlare Cluster Status :rocket:&#34;)
127+
table5.add_row(Panel.fit(table4))
128+
console.print(table5)
129+
130+
131+
def print_clusters(clusters: List[RayCluster]):
88132
if not clusters:
89133
print_no_resources_found()
90134
return # shortcircuit
@@ -96,13 +140,13 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
96140
status = (
97141
&#34;Active :white_heavy_check_mark:&#34;
98142
if cluster.status == RayClusterStatus.READY
99-
else &#34;InActive :x:&#34;
143+
else &#34;Inactive :x:&#34;
100144
)
101145
name = cluster.name
102146
dashboard = cluster.dashboard
103147
mincount = str(cluster.min_workers)
104148
maxcount = str(cluster.max_workers)
105-
memory = cluster.worker_mem_min + &#34;~&#34; + cluster.worker_mem_max
149+
memory = str(cluster.worker_mem_min) + &#34;~&#34; + str(cluster.worker_mem_max)
106150
cpu = str(cluster.worker_cpu)
107151
gpu = str(cluster.worker_gpu)
108152
# owned = bool(cluster[&#34;userOwned&#34;])
@@ -111,7 +155,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
111155
#&#39;table0&#39; to display the cluster name, status, url, and dashboard link
112156
table0 = Table(box=None, show_header=False)
113157
if owned:
114-
table0.add_row(&#34;[white on green][bold]Owner&#34;)
158+
table0.add_row(&#34;[white on green][bold]Name&#34;)
115159
else:
116160
table0.add_row(&#34;&#34;)
117161
table0.add_row(&#34;[bold underline]&#34; + name, status)
@@ -162,7 +206,7 @@ <h1 class="title">Module <code>codeflare_sdk.utils.pretty_print</code></h1>
162206
# than being center aligned on the console/terminal if we simply use console.print(title)
163207

164208
table5 = Table(
165-
box=None, title=&#34;[bold] :rocket: List of CodeFlare clusters :rocket:&#34;
209+
box=None, title=&#34;[bold] :rocket: CodeFlare Cluster Details :rocket:&#34;
166210
)
167211
table5.add_row(Panel.fit(table4))
168212
console.print(table5)
@@ -193,31 +237,84 @@ <h2 class="section-title" id="header-functions">Functions</h2>
193237
return # shortcircuit
194238

195239
console = Console()
240+
table = Table(
241+
box=box.ASCII_DOUBLE_HEAD,
242+
title=&#34;[bold] :rocket: Cluster Queue Status :rocket:&#34;,
243+
)
244+
table.add_column(&#34;Name&#34;, style=&#34;cyan&#34;, no_wrap=True)
245+
table.add_column(&#34;Status&#34;, style=&#34;magenta&#34;)
246+
196247
for app_wrapper in app_wrappers:
197248
name = app_wrapper.name
198249
status = app_wrapper.status.value
199-
200-
table = Table(
201-
box=box.ASCII_DOUBLE_HEAD,
202-
title=&#34;[bold] :rocket: List of CodeFlare clusters in queue:rocket:&#34;,
203-
)
204-
table.add_column(&#34;Name&#34;, style=&#34;cyan&#34;, no_wrap=True)
205-
table.add_column(&#34;Status&#34;, style=&#34;magenta&#34;)
206250
table.add_row(name, status)
207251
table.add_row(&#34;&#34;) # 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+
&#34;Pretty prints the status of a passed-in cluster&#34;
267+
if not cluster:
268+
print_no_resources_found
269+
return
270+
271+
console = Console()
272+
status = (
273+
&#34;Active :white_heavy_check_mark:&#34;
274+
if cluster.status == RayClusterStatus.READY
275+
else &#34;Inactive :x:&#34;
276+
)
277+
name = cluster.name
278+
dashboard = cluster.dashboard
279+
# owned = bool(cluster[&#34;userOwned&#34;])
280+
owned = True
281+
282+
#&#39;table0&#39; 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(&#34;[white on green][bold]Name&#34;)
286+
else:
287+
table0.add_row(&#34;&#34;)
288+
table0.add_row(&#34;[bold underline]&#34; + name, status)
289+
table0.add_row()
290+
# fixme harcded to default for now
291+
table0.add_row(
292+
f&#34;[bold]URI:[/bold] ray://{cluster.name}-head-svc.{cluster.namespace}.svc:10001&#34;
293+
) # format that is used to generate the name of the service
294+
table0.add_row()
295+
table0.add_row(f&#34;[link={dashboard} blue underline]Dashboard:link:[/link]&#34;)
296+
table0.add_row(&#34;&#34;) # 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=&#34;[bold] :rocket: CodeFlare Cluster Status :rocket:&#34;)
304+
table5.add_row(Panel.fit(table4))
305+
console.print(table5)</code></pre>
209306
</details>
210307
</dd>
211308
<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>
213310
</code></dt>
214311
<dd>
215312
<div class="desc"></div>
216313
<details class="source">
217314
<summary>
218315
<span>Expand source code</span>
219316
</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]):
221318
if not clusters:
222319
print_no_resources_found()
223320
return # shortcircuit
@@ -229,13 +326,13 @@ <h2 class="section-title" id="header-functions">Functions</h2>
229326
status = (
230327
&#34;Active :white_heavy_check_mark:&#34;
231328
if cluster.status == RayClusterStatus.READY
232-
else &#34;InActive :x:&#34;
329+
else &#34;Inactive :x:&#34;
233330
)
234331
name = cluster.name
235332
dashboard = cluster.dashboard
236333
mincount = str(cluster.min_workers)
237334
maxcount = str(cluster.max_workers)
238-
memory = cluster.worker_mem_min + &#34;~&#34; + cluster.worker_mem_max
335+
memory = str(cluster.worker_mem_min) + &#34;~&#34; + str(cluster.worker_mem_max)
239336
cpu = str(cluster.worker_cpu)
240337
gpu = str(cluster.worker_gpu)
241338
# owned = bool(cluster[&#34;userOwned&#34;])
@@ -244,7 +341,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
244341
#&#39;table0&#39; to display the cluster name, status, url, and dashboard link
245342
table0 = Table(box=None, show_header=False)
246343
if owned:
247-
table0.add_row(&#34;[white on green][bold]Owner&#34;)
344+
table0.add_row(&#34;[white on green][bold]Name&#34;)
248345
else:
249346
table0.add_row(&#34;&#34;)
250347
table0.add_row(&#34;[bold underline]&#34; + name, status)
@@ -295,7 +392,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
295392
# than being center aligned on the console/terminal if we simply use console.print(title)
296393

297394
table5 = Table(
298-
box=None, title=&#34;[bold] :rocket: List of CodeFlare clusters :rocket:&#34;
395+
box=None, title=&#34;[bold] :rocket: CodeFlare Cluster Details :rocket:&#34;
299396
)
300397
table5.add_row(Panel.fit(table4))
301398
console.print(table5)
@@ -315,7 +412,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
315412
</summary>
316413
<pre><code class="python">def print_no_resources_found():
317414
console = Console()
318-
console.print(Panel(&#34;[red]No resources found&#34;))</code></pre>
415+
console.print(Panel(&#34;[red]No resources found, have you run cluster.up() yet?&#34;))</code></pre>
319416
</details>
320417
</dd>
321418
</dl>
@@ -337,6 +434,7 @@ <h1>Index</h1>
337434
<li><h3><a href="#header-functions">Functions</a></h3>
338435
<ul class="">
339436
<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>
340438
<li><code><a title="codeflare_sdk.utils.pretty_print.print_clusters" href="#codeflare_sdk.utils.pretty_print.print_clusters">print_clusters</a></code></li>
341439
<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>
342440
</ul>

‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "codeflare-sdk"
3-
version = "0.2.2"
3+
version = "0.3.0"
44
description = "Python SDK for codeflare client"
55

66
license = "Apache-2.0"

0 commit comments

Comments
 (0)
Please sign in to comment.