[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:
Jiaxin Shan 2022-03-16 10:20:33 +08:00 committed by GitHub
parent 42ebc0a4f6
commit 158ff3394f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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