Skip to content

Commit 7a38136

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 028d0d5 commit 7a38136

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"# Import pieces from codeflare-sdk\n",
17+
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, RayJobClient\n",
18+
"\n",
19+
"# Gather the dashboard URL\n",
20+
"ray_dashboard = \"<Ray-Dashboard-Route>\"\n",
21+
"\n",
22+
"# Setup Authentication Configuration \n",
23+
"\n",
24+
"header = {\n",
25+
" 'Authorization': f'Bearer {\"<auth-token>\"}'\n",
26+
"}\n",
27+
"\n",
28+
"#Initialize the RayJobClient\n",
29+
"client = RayJobClient(address=ray_dashboard, headers=header, verify=True)"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"# Submit an a job using the RayJobClient\n",
39+
"entrypoint_command = \"python <training-script>\"\n",
40+
"submission_id = client.submit_job(\n",
41+
" entrypoint=entrypoint_command,\n",
42+
" runtime_env={\"working_dir\": \"./\",\"pip\": \"requirements.txt\"},\n",
43+
")"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {},
50+
"outputs": [],
51+
"source": [
52+
"# Get the job's status\n",
53+
"client.get_job_status(submission_id)"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"# Get the job's logs\n",
63+
"client.get_job_logs(submission_id)"
64+
]
65+
}
66+
],
67+
"metadata": {
68+
"language_info": {
69+
"name": "python"
70+
}
71+
},
72+
"nbformat": 4,
73+
"nbformat_minor": 2
74+
}

0 commit comments

Comments
 (0)