Skip to content

remote ray client example #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions demo-notebooks/additional-demos/remote_ray_job_client.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Submit a training job remotely to Ray Dashboard protected by oAuth.\n",
"This notebook will demonstrate how to submit Ray jobs to an existing Raycluster, using the CodeFlare SDK.\n",
"\n",
"### Requirements\n",
"* Ray Cluster running in OpenShift protected by oAuth.\n",
"* The Ray Dashboard URL for the Ray Cluster.\n",
"* An OpenShift authorization token with permissions to access the Route."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import dependencies from codeflare-sdk\n",
"from codeflare_sdk import RayJobClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Setup Authentication Configuration \n",
"auth_token = \"XXXX\" # Replace with the actual token\n",
"header = {\n",
" 'Authorization': f'Bearer {auth_token}'\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Gather the dashboard URL (provided by the creator of the RayCluster)\n",
"ray_dashboard = \"XXXX\" # Replace with the Ray dashboard URL"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Initialize the RayJobClient\n",
"client = RayJobClient(address=ray_dashboard, headers=header, verify=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Submit a job using the RayJobClient\n",
"entrypoint_command = \"python XXXX\" # Replace with the training script name\n",
"submission_id = client.submit_job(\n",
" entrypoint=entrypoint_command,\n",
" runtime_env={\"working_dir\": \"./\",\"pip\": \"requirements.txt\"},\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get the job's status\n",
"client.get_job_status(submission_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get the job's logs\n",
"client.get_job_logs(submission_id)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}