1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/bin/env python3
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from openapi_client.models import V0036JobSubmission as jobSubmission
from openapi_client.models import V0036JobProperties as jobProperties
from openapi_client.api import SlurmApi as slurm
from pprint import pprint
s = slurm(openapi_client.ApiClient(openapi_client.Configuration()))
env = {
"PATH": os.getenv("PATH", "/usr/local/bin:/bin:/usr/bin/:/usr/local/bin/"),
"LD_LIBRARY_PATH": os.getenv("LD_LIBRARY_PATH", "/usr/local/lib64:/usr/local/lib/:/lib/:/lib64/:/usr/local/lib"),
"SHELL": os.getenv("SHELL", "/bin/sh")
}
script = "#!/bin/env sh\nsrun uptime"
job = jobSubmission(script=script)
job.job = jobProperties(
environment=env,
current_working_directory=os.getcwd(),
nodes=[2,9999],
standard_error="/tmp/job.log",
)
try:
njob = s.slurmctld_submit_job(job)
pprint(njob)
except ApiException as e:
print("Exception when calling: %s\n" % e)
os._exit(1)
os._exit(0)
|