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
74 changes: 74 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,74 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Submit a job using an authorized Ray dashboard and the Job Submission Client remotely"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import pieces from codeflare-sdk\n",
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, RayJobClient\n",
"\n",
"# Gather the dashboard URL\n",
Copy link
Contributor

@chipspeak chipspeak May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of clarity might we say:

# Gather the dashboard URL (provided by the RayCluster creator)

"ray_dashboard = \"<Ray-Dashboard-Route>\"\n",
"\n",
"# Setup Authentication Configuration \n",
"\n",
"header = {\n",
" 'Authorization': f'Bearer {\"<auth-token>\"}'\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this would be clearer:

auth_token = "XXXX" # Your OpenShift authentication token

header = {
    'Authorization': f'Bearer {auth_token}'
}

"}\n",
"\n",
"#Initialize the RayJobClient\n",
"client = RayJobClient(address=ray_dashboard, headers=header, verify=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Submit an a job using the RayJobClient\n",
Copy link
Contributor

@chipspeak chipspeak May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Submit a job using the RayJobClient

"entrypoint_command = \"python <training-script>\"\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
}
Loading