Using APIs to Connect to a RayCluster Endpoint and Submit Jobs
If you need to integrate data processing capabilities into your service system, or to submit Ray jobs and query job status automatically, you can use APIs to connect to a RayCluster endpoint and submit jobs. AI DataLake provides standard RESTful APIs that you can call programmatically.
Prerequisites
A RayCluster endpoint has been created and is in the Running state. For details, see Creating a Ray Engine Endpoint.
Related APIs
Procedure
- Use an API tool, such as Postman, to call the API to connect to the RayCluster endpoint and submit a job.
For details about calling APIs, see Calling APIs.
An example request is as follows:
POST /v2/workspaces/{workspace_id}/ray-jobs { "name": "xd-test-010-0906", "endpoint_name": "ray-federation-1hri", "config": { "entrypoint": "python3 -c \"import ray,time; time.sleep(30); ray.init(); print(ray.cluster_resources())\"", } }Table 1 describes the key parameters. For more information, see Running a Job.
Table 1 Parameter description Parameter
Description
workspace_id
Enter the workspace ID. For details about how to obtain a workspace ID, see Managing Workspaces.
name
Enter the job name.
endpoint_name
Enter the RayCluster endpoint name. For details about how to obtain the endpoint name, see Managing a Ray Engine Endpoint.
entrypoint
Enter the main script for running the job.
- Check the returned response. A response similar to the following indicates that the RayCluster endpoint is connected and the job is submitted:
{ "job_id" : "ac8111bf-3601-4905-8ddd-b41d3e63****" }
Related Operations
- For details about how to use APIs to connect to a RayCluster endpoint and submit jobs, see Data Processing Using RayCluster.
- After jobs are executed, you can use an API to query the job list. For details, see Listing Ray Jobs – ListRayJobs.
- After a job is executed, you can use an API to query job details. For details, see Querying Job Details – ShowRayJob.
- While a job is running, you can use an API to cancel the job. For details, see Canceling a Job – CancelRayJob.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot