Skip to content

Commit dcbe579

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 dcbe579

File tree

1 file changed

+90
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)