Skip to content

Commit fb49dc5

Browse files
authored
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>

0 commit comments

Comments
 (0)