Ticket 9625

Summary: Request for Information: How to use the /job/submit REST endpoint
Product: Slurm Reporter: Rusty Davis <rustyd>
Component: slurmrestdAssignee: Nate Rini <nate>
Status: RESOLVED INFOGIVEN QA Contact:
Severity: 4 - Minor Issue    
Priority: --- CC: fullop, mcoyne, nate, ndobson, sts
Version: 20.02.3   
Hardware: Linux   
OS: Linux   
Site: LANL Slinky Site: ---
Alineos Sites: --- Atos/Eviden Sites: ---
Confidential Site: --- Coreweave sites: ---
Cray Sites: --- DS9 clusters: ---
Google sites: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- NoveTech Sites: ---
Nvidia HWinf-CS Sites: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Tzag Elita Sites: ---
Linux Distro: --- Machine Name:
CLE Version: Version Fixed:
Target Release: --- DevPrio: ---
Emory-Cloud Sites: ---
Attachments: PEARC presentation

Description Rusty Davis 2020-08-19 17:54:00 MDT
Hello,
I'm looking to use the "/job/submit" endpoint with the REST API. I have an API documentation json file, but it doesn't seem to state how to include the sbatch script I want to use for the job. I found a demo of the job submit in the presentation you guys gave at SLUG2019, but the paramaters look different from the current API. I was wondering if you all have any examples or further documentation on how to use it. Thanks!
Comment 1 Nate Rini 2020-08-19 18:08:03 MDT
Created attachment 15521 [details]
PEARC presentation

(In reply to Rusty Davis from comment #0)
> I'm looking to use the "/job/submit" endpoint with the REST API. I have an
> API documentation json file, but it doesn't seem to state how to include the
> sbatch script I want to use for the job.

Here is an example Job (job.json):
> {
>        "job": {
>                        "tasks": 1,
>                        "name": "test",
>                        "nodes": 1,
>                        "current_working_directory": "/tmp/",
>                        "environment": {
>                                "PATH": "/bin:/usr/bin/:/usr/local/bin/",
>                                "LD_LIBRARY_PATH": "/lib/:/lib64/:/usr/local/lib"
>                        }
>        },
>        "script": "#!/bin/bash\nsrun hostname"
> }
The "script" field is where the contents of the script are to be placed. In the above example, it is a pretty simple script but anything sbatch accepts should be accepted by slurmrestd.

Example call with curl:
> export $(scontrol token lifespan=99999)
> curl -s -H X-SLURM-USER-NAME:$(whoami) -H X-SLURM-USER-TOKEN:$SLURM_JWT -X POST 'http://rest/slurm/v0.0.35/job/submit' -H "Content-Type: application/json" -d @job.json
.

> I found a demo of the job submit in
> the presentation you guys gave at SLUG2019, but the paramaters look
> different from the current API. 

The SLUG slides are little out of date. I have attached the more recent PEARC20 presentation slides. Slide 30 has an example too.

> I was wondering if you all have any examples
> or further documentation on how to use it.
The main documentation is here:
> https://slurm.schedmd.com/rest.html
I have been adding to it as we get more questions from sites. Questions are welcome.
Comment 2 Rusty Davis 2020-08-20 10:28:43 MDT
That's exactly what I was looking for. Thanks! I'll be sure to let you know if I have any more questions.
Comment 3 Nate Rini 2020-08-20 10:33:35 MDT
(In reply to Rusty Davis from comment #2)
> That's exactly what I was looking for. Thanks! I'll be sure to let you know
> if I have any more questions.

Closing per your response. Please reply if you have any more questions.