Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Submit remote RayJobs to a Ray cluster with the CodeFlare SDK

July 24, 2025
Pat O'Connor
Related topics:
Artificial intelligenceData Science
Related products:
Red Hat AIRed Hat OpenShift AI

Share:

    One of the chief benefits of the CodeFlare SDK within Red Hat OpenShift AI is its ability to provide Ray features to a data scientist, abstracting away many infrastructure requirements. A user of the CodeFlare SDK simply needs to execute a small number of Python cells to get access to a Ray cluster running on OpenShift. 

    While this is relatively simple, some users might wish to abstract this further and have a cluster administrator manage the Ray cluster custom resources. The admin might provide a data scientist with access to the Ray dashboard and allow them to submit their jobs directly. 

    To demonstrate how to achieve this functionally, the CodeFlare SDK GitHub repository features a guided Jupyter notebook to help get users started when attempting this. This blog post walks through that notebook in detail, explaining each step.

    Set up the remote RayJobClient

    Note

    Before you begin, you will need a Ray dashboard URL from your cluster admin. Then, simply open a Jupyter notebook to get started.

    The first step is to import the CodeFlare SDK Python package. To do this, you can paste the following code into a cell and execute it. Alternatively, you can simply copy the guided notebook as a template and change cells as needed.

    # Import dependencies from codeflare-sdk
    from codeflare_sdk import RayJobClient

    Next, we'll need to declare some authorization-related variables. To do this, you'll need to get an OpenShift auth token from your cluster administrator. Once you have this token, create a new cell matching the below snippet and paste your token into the auth_token placeholder.

    # Setup Authentication Configuration 
    auth_token = "XXXX" # Replace with the actual token
    header = {
        'Authorization': f'Bearer {auth_token}'
    }

    Connect to the Ray dashboard

    We need to authenticate the Ray dashboard to use the CodeFlare SDK in this way. You'll also need to declare the dashboard URL itself. Replace the placeholder in the below with your Ray dashboard URL and execute the cell.

    # Gather the dashboard URL (provided by the creator of the RayCluster)
    ray_dashboard = "XXXX" # Replace with the Ray dashboard URL

    Now we need to pass all of these variables to the CodeFlare SDK's RayJobClient. Execute the following cell to perform this final piece of setup.

    # Initialize the RayJobClient
    client = RayJobClient(address=ray_dashboard, headers=header, verify=True)

    Submit and monitor your Ray job

    You're now ready to submit a job on the Ray cluster. To do this, we'll need:

    • An entrypoint_command that refers to the execution command for your job script (i.e, python <your_job_script_name>).
    • A runtime_env that declares the directory in which your script is located and any prerequisites such as installing requirements, etc.

    With the above, we'll invoke the client.submit_job() function with a variable declaration for submission_id. This lets us easily pass the job's submission_id to other client functions to observe the job results within the notebook itself. Replace the placeholders within the following snippet and execute the cell to submit the job.

    # Submit a job using the RayJobClient
    entrypoint_command = "python XXXX" # Replace with the training script name
    submission_id = client.submit_job(
        entrypoint=entrypoint_command,
        runtime_env={"working_dir": "./","pip": "requirements.txt"},
    )

    With the job submitted, you can visit the Ray dashboard URL and go to the Jobs tab to observe it. Alternately, you can execute the following cell to use the client to check the job status.

    # Get the job's status
    client.get_job_status(submission_id)

    You can also surface the job logs within your Jupyter notebook by executing the following cell.

    # Get the job's logs
    client.get_job_logs(submission_id)

    Summary

    The example in this article is just a quick example of some of the ways you can leverage the CodeFlare SDK within OpenShift AI. You can find additional examples in the demo notebooks directory of the CodeFlare SDK GitHub repository. 

    For additional information, check out the CodeFlare SDK documentation.

    Related Posts

    • How to fine-tune Llama 3.1 with Ray on OpenShift AI

    • Python performance optimizations with RHEL 9.5

    • Llama 4 herd is here with Day 0 inference support in vLLM

    • Managing Python dependencies with the Thoth JupyterLab extension

    • Introduction to machine learning with Jupyter notebooks

    • Learn how to build, train, and run a PyTorch model

    Recent Posts

    • Cloud bursting with confidential containers on OpenShift

    • Reach native speed with MacOS llama.cpp container inference

    • A deep dive into Apache Kafka's KRaft protocol

    • Staying ahead of artificial intelligence threats

    • Strengthen privacy and security with encrypted DNS in RHEL

    What’s up next?

    Open source AI for developers introduces and covers key features of Red Hat OpenShift AI, including Jupyter Notebooks, PyTorch, and enhanced monitoring and observability tools, along with MLOps and continuous integration/continuous deployment (CI/CD) workflows.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue