mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
[Job submission] Improve job submission docs (#23115)
I am following job submission docs here https://docs.ray.io/en/latest/cluster/job-submission.html and run some examples. I notice there're few minor issues. 1. some required libraries are not imported in any code snippets 2. Get job api returns `{'status': 'SUCCEEDED'}` instead of `job_status` so code snippet here doesn't work https://docs.ray.io/en/latest/cluster/job-submission.html#rest-api
This commit is contained in:
parent
42ebc0a4f6
commit
158ff3394f
1 changed files with 6 additions and 1 deletions
|
@ -203,6 +203,7 @@ Now we can have a simple polling loop that checks the job status until it reache
|
|||
.. code-block:: python
|
||||
|
||||
from ray.job_submission import JobStatus
|
||||
import time
|
||||
|
||||
def wait_until_finish(job_id):
|
||||
start = time.time()
|
||||
|
@ -264,6 +265,10 @@ Under the hood, both the Job Client and the CLI make HTTP calls to the job serve
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
|
||||
resp = requests.post(
|
||||
"http://127.0.0.1:8265/api/jobs/",
|
||||
json={
|
||||
|
@ -286,7 +291,7 @@ Under the hood, both the Job Client and the CLI make HTTP calls to the job serve
|
|||
"http://127.0.0.1:8265/api/jobs/<job_id>"
|
||||
)
|
||||
rst = json.loads(resp.text)
|
||||
status = rst["job_status"]
|
||||
status = rst["status"]
|
||||
print(f"status: {status}")
|
||||
if status in {JobStatus.SUCCEEDED, JobStatus.STOPPED, JobStatus.FAILED}:
|
||||
break
|
||||
|
|
Loading…
Add table
Reference in a new issue