Skip to content

Commit 66333e8

Browse files
laurafitzgeraldkryanbeanechipspeakBobbins228
committed
remote ray client example
Co-authored-by: bkeane <bkeane@redhat.com> Co-authored-by: chipspeak <paoconno@redhat.com> Co-authored-by: Bobbins <mcampbel@redhat.com>
1 parent 68d1f6c commit 66333e8

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Submit a job using an authorized Ray dashboard and the Job Submission Client remotely\n",
8+
"In this notebook, we will demonstrate how to submit Ray jobs to an existing Raycluster, using the CodeFlare SDK.\n",
9+
"\n",
10+
"### Requirements\n",
11+
"* Your administrator has created a RayCluster.\n",
12+
"* They have provided you with its dashboard URL.\n",
13+
"* You been provided an OpenShift authorization token."
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": null,
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"# Import pieces from codeflare-sdk\n",
23+
"from codeflare_sdk import RayJobClient"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"metadata": {},
30+
"outputs": [],
31+
"source": [
32+
"# Setup Authentication Configuration \n",
33+
"auth_token = \"<your-openshit-auth-token>\"\n",
34+
"header = {\n",
35+
" 'Authorization': f'Bearer {auth_token}'\n",
36+
"}"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"\n",
46+
"# Gather the dashboard URL (provided by the creator of the RayCluster)\n",
47+
"ray_dashboard = \"<Ray-Dashboard-Route>\""
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"#Initialize the RayJobClient\n",
57+
"client = RayJobClient(address=ray_dashboard, headers=header, verify=True)"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"# Submit a job using the RayJobClient\n",
67+
"entrypoint_command = \"python <training-script>\"\n",
68+
"submission_id = client.submit_job(\n",
69+
" entrypoint=entrypoint_command,\n",
70+
" runtime_env={\"working_dir\": \"./\",\"pip\": \"requirements.txt\"},\n",
71+
")"
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": null,
77+
"metadata": {},
78+
"outputs": [],
79+
"source": [
80+
"# Get the job's status\n",
81+
"client.get_job_status(submission_id)"
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"metadata": {},
88+
"outputs": [],
89+
"source": [
90+
"# Get the job's logs\n",
91+
"client.get_job_logs(submission_id)"
92+
]
93+
}
94+
],
95+
"metadata": {
96+
"language_info": {
97+
"name": "python"
98+
}
99+
},
100+
"nbformat": 4,
101+
"nbformat_minor": 2
102+
}

0 commit comments

Comments
 (0)