-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathman-jobs-submit
executable file
·110 lines (89 loc) · 3.73 KB
/
man-jobs-submit
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
#
# Template for submitting lots of jobs to GridPP DIRAC or LHCb DIRAC
# Lots of inline comments. Please edit to suit your situation.
#
# This script uses DIRAC parametric jobs:
# https://github.com/DIRACGrid/DIRAC/wiki/JobManagementAdvanced
import sys
import time
from DIRAC.Core.Base import Script
Script.parseCommandLine()
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
from DIRAC.Interfaces.API.Dirac import Dirac
# We construct the DIRAC Job Description Language as string in jdl:
jdl = ''
# Something descriptive for the name! Like 'FastRawMerging'.
jdl += 'JobName = "tarJob";\n'
# One job will be created for each parameter in the list
jdl += """Parameters = { "LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/0.tar",
"LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/1.tar",
"LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/2.tar",
"LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/3.tar",
"LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/4.tar",
"LFN:/skatelescope.eu/user/a/andrew.mcnab/skatest/5.tar" };\n"""
# Only run the jobs at Manchester
jdl += 'Site = "LCG.UKI-NORTHGRID-MAN-HEP.uk";\n' # in GridPP DIRAC
#jdl += 'Site = "LCG.Manchester.uk";\n' # in LHCb DIRAC
#jdl += 'Site = "VAC.UKI-NORTHGRID-MAN-HEP.uk";\n' # in GridPP DIRAC
#jdl += 'Site = "VAC.Manchester.uk";\n' # in LHCb DIRAC
# Allows job to run on local queues (must correspond to tags in DIRAC CS!)
# jdl += 'Tags = "manchester";\n'
# The script you want to run.
jdl += 'Executable = "tarJob.sh";\n'
# tarJob.sh will be run with these command line arguments
# %n is a counter increasing by one for each job in the list
# %s is the parameter taken from the list given in Parameters = { ... }
# %j is the unique DIRAC Job ID number
# something is just a value to show you can add other things too
jdl += 'Arguments = "%n %s %j something";\n'
# Send the script you want to run (in this directory where you run man-job-submit
# or give the full path to it)
jdl += 'InputSandbox = { "tarJob.sh" };\n'
# Tell DIRAC where to get your big input data files from
# %s is the parameter taken from the list given in Parameters = { ... }
jdl += 'InputData = "%s";\n'
# Direct stdout and stderr to files
jdl += 'StdOutput = "StdOut";\n';
jdl += 'StdOutput = "StdErr";\n';
# Small files can be put in the output sandbox
jdl += 'OutputSandbox = {"StdOut", "StdErr", "%j.wc.log"};\n'
# Files to be saved to your grid storage area in case they are large
# %j is the unique DIRAC Job ID number.
# DIRAC looks for this output file in the working directory.
# jdl += 'OutputData = "LFN:/skatelescope.eu/user/a/andrew.mcnab/tmp/%j.wc.log";\n'
# Give the OutputSE too if using OutputData:
# jdl += 'OutputSE = "UKI-NORTHGRID-MAN-HEP-disk";\n' # storage in GridPP DIRAC
# jdl += 'OutputSE = "CERN-USER";\n' # storage in LHCb DIRAC
# Tell DIRAC how many seconds your job might run for
jdl += 'MaxCPUTime = 1000;\n'
# Create a unique Job Group for this set of jobs
try:
diracUsername = getProxyInfo()['Value']['username']
except:
print 'Failed to get DIRAC username. No proxy set up?'
sys.exit(1)
jobGroup = diracUsername + time.strftime('.%Y%m%d%H%M%S')
jdl += 'JobGroup = "' + jobGroup + '";\n'
print 'Will submit this DIRAC JDL:'
print '====='
print jdl
print '====='
print
# Submit the job(s)
print 'Attempting to submit job(s) in JobGroup ' + jobGroup
print
dirac = Dirac()
result = dirac.submit(jdl)
print
print '====='
print
print 'Submission Result: ',result
print
print '====='
print
if result['OK']:
print 'Retrieve output with dirac-wms-job-get-output --JobGroup ' + jobGroup
else:
print 'There was a problem submitting your job(s) - see above!!!'
print