Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

    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

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    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

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.