Skip to content
Snippets Groups Projects
Commit ff87eeec authored by Sophie King's avatar Sophie King
Browse files

Add hello word tests using API

parent 0c8b9e99
Branches
Tags
No related merge requests found
5267595
Submission Result:
{'JobID': 5267595,
'OK': True,
'Value': 5267595,
'requireProxyUpload': False,
'rpcStub': (('WorkloadManagement/JobManager',
{'delegatedDN': '/C=UK/O=eScience/OU=QueenMaryLondon/L=Physics/CN=sophie king',
'delegatedGroup': 't2k.org_user',
'keepAliveLapse': 150,
'skipCACheck': False,
'timeout': 600}),
'submitJob',
('[ \n Origin = DIRAC;\n Executable = "$DIRACROOT/scripts/dirac-jobexec";\n OutputSandbox = \n {\n Script1_CodeOutput.log,\n Script2_hostname.log,\n Script3_test1.sh.log,\n std.err,\n std.out\n };\n StdError = std.err;\n LogLevel = info;\n Site = ANY;\n CPUTime = 500;\n JobName = test1;\n Priority = 1;\n InputSandbox = \n {\n "/bin/hostname",\n "test1.sh",\n "SB:GridPPSandboxSE|/SandBox/s/sophie.king.t2k.org_user/4a6/059/4a60591569a872c95b3f72917428b8a5.tar.bz2"\n };\n Arguments = "jobDescription.xml -o LogLevel=info";\n JobGroup = t2k.org;\n MaxCPUTime = 500;\n StdOutput = std.out;\n JobType = User;\n]',))}
The current status of this job is:
{'OK': True,
'Value': {5267595: {'MinorStatus': 'Pilot Agent Submission',
'Site': 'ANY',
'Status': 'Waiting'}}}
The current status of all jobs is:
{'OK': True,
'Value': {5267595: {'MinorStatus': 'Pilot Agent Submission',
'Site': 'ANY',
'Status': 'Waiting'}}}
#!/usr/bin/env python
# submits a 'hello world' style job via the dirac api
# requires a DIRAC UI to be set up (source bashrc)
# and a valid proxy: dirac-proxy-init -g [your vo here]_user -M
# DIRAC does not work otherwise
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = True )
# end of DIRAC setup
from DIRAC.Interfaces.API.Job import Job
from DIRAC.Interfaces.API.Dirac import Dirac
import pprint
dirac = Dirac()
j = Job()
j.setCPUTime(500)
j.setExecutable('/bin/echo hello')
j.setExecutable('/bin/hostname')
j.setExecutable('test1.sh')
j.setName('test1')
result = dirac.submit(j)
print 'Submission Result: '
pprint.pprint(result)
jobid = result['JobID']
# print job id to file for future reference
joblog = open("jobid.log", "a")
joblog.write(str(jobid)+'\n')
joblog.close()
# to interactively check on job status do:
# dirac-wms-job-status -f jobid.log
print "\nThe current status of this job is:"
pprint.pprint(dirac.status(jobid))
joblog = open("jobid.log", "r")
# list comprehension :-D
all_jobids = [jobid.strip() for jobid in joblog.readlines()]
print "\nThe current status of all jobs is:"
all_status = dirac.status(all_jobids)
pprint.pprint(all_status)
#!/bin/bash
echo 'aghhhh' > file1.txt
ls
echo $PWD
ls $PWD
pwd
## SE=se03.esc.qmul.ac.uk
## SE=SRM://se03.esc.qmul.ac.uk
## SE=DIRAC
## SE=DIRAC-USER
SE=UKI-LT2-QMUL2-disk
#FILE=./file.txt
FILE=file1.txt
# this works when i run the job locally
#FILE=${PWD}/filei1.txt
LFN=/t2k.org/soph/file1.txt
dirac-dms-add-file ${LFN} ${FILE} ${SE}
5267597
#!/usr/bin/env python
# submits a 'hello world' style job via the dirac api
# requires a DIRAC UI to be set up (source bashrc)
# and a valid proxy: dirac-proxy-init -g [your vo here]_user -M
# DIRAC does not work otherwise
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = True )
# end of DIRAC setup
from DIRAC.Interfaces.API.Job import Job
from DIRAC.Interfaces.API.Dirac import Dirac
import pprint
dirac = Dirac()
j = Job()
j.setCPUTime(50)
j.setExecutable('/bin/echo hello')
j.setExecutable('/bin/hostname')
j.setExecutable('test2.sh')
j.setName('test2')
result = dirac.submit(j)
print 'Submission Result: '
pprint.pprint(result)
jobid = result['JobID']
# print job id to file for future reference
joblog = open("jobid.log", "a")
joblog.write(str(jobid)+'\n')
joblog.close()
# to interactively check on job status do:
# dirac-wms-job-status -f jobid.log
print "\nThe current status of this job is:"
pprint.pprint(dirac.status(jobid))
joblog = open("jobid.log", "r")
# list comprehension :-D
all_jobids = [jobid.strip() for jobid in joblog.readlines()]
print "\nThe current status of all jobs is:"
all_status = dirac.status(all_jobids)
pprint.pprint(all_status)
#!/bin/bash
echo 'aghhhh' > file2.txt
ls
echo $PWD
ls $PWD
pwd
## SE=se03.esc.qmul.ac.uk
## SE=SRM://se03.esc.qmul.ac.uk
## SE=DIRAC
## SE=DIRAC-USER
SE=UKI-LT2-QMUL2-disk
#FILE=./file.txt
FILE=file2.txt
# this works when i run the job locally
#FILE=${PWD}/filei1.txt
LFN=/t2k.org/soph/test2/file2.txt
dirac-dms-add-file ${LFN} ${FILE} ${SE}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment