Skip to content

Commit ed39723

Browse files
laurafitzgeraldkryanbeanechipspeakBobbins228
committed
remote ray client example
Co-authored-by: bkeane <[email protected]> Co-authored-by: chipspeak <[email protected]> Co-authored-by: Bobbins <[email protected]>
1 parent 68d1f6c commit ed39723

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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 = \"XXXX\" # Replace with your actual 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+
"# Gather the dashboard URL (provided by the creator of the RayCluster)\n",
46+
"ray_dashboard = \"XXXX\" # Replace with your Ray dashboard URL"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
55+
"#Initialize the RayJobClient\n",
56+
"client = RayJobClient(address=ray_dashboard, headers=header, verify=True)"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": null,
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"# Submit a job using the RayJobClient\n",
66+
"entrypoint_command = \"python XXXX\" # Replace with your training script name\n",
67+
"submission_id = client.submit_job(\n",
68+
" entrypoint=entrypoint_command,\n",
69+
" runtime_env={\"working_dir\": \"./\",\"pip\": \"requirements.txt\"},\n",
70+
")"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"# Get the job's status\n",
80+
"client.get_job_status(submission_id)"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"# Get the job's logs\n",
90+
"client.get_job_logs(submission_id)"
91+
]
92+
}
93+
],
94+
"metadata": {
95+
"language_info": {
96+
"name": "python"
97+
}
98+
},
99+
"nbformat": 4,
100+
"nbformat_minor": 2
101+
}

0 commit comments

Comments
 (0)