Skip to content

Commit 1dc3343

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 07bdade commit 1dc3343

File tree

1 file changed

+103
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)