-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit_visit.py
73 lines (56 loc) · 2.42 KB
/
submit_visit.py
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
#!/usr/bin/env python
# Submits a single visit (or a subset of a visit) to the grid for processing.
# This does not integrate with the infrastructure used by jobmanager.py. Instead
# the jobs must be checked on manually.
# First argument is name of visit to submit, as an 8 digit number.
# Further arguments are optional. If any are given, they are indices (0-47) of jobs
# within that visit that should be submitted.
# If none are given, all 48 jobs are submitted.
# The job IDs are recorded in a file named 'visit_jobs_<visit>.txt'.
import sys
from DIRAC.Core.Base import Script
Script.parseCommandLine()
from DIRAC.Interfaces.API.Job import Job
from DIRAC.Interfaces.API.Dirac import Dirac
dirac = Dirac()
if len(sys.argv) < 2:
print "Usage: submit_visit.py <visit number> [<index> <index> ...]"
sys.exit(1)
visit = sys.argv[1]
print "Submitting jobs for visit", visit
indices = []
for i in range(2, len(sys.argv)):
indices.append(int(sys.argv[i]))
if len(indices) == 0:
for i in range(0, 48):
indices.append(i)
# open a file to record a list of jobs for this visit
joblistfile = open('visit_jobs_' + visit + '.txt', 'w')
for idx in indices:
j = Job()
j.setName("ImSim_" + visit + "_" + str(idx));
instcatname = visit + ".tar.gz"
insidename = 'phosim_cat_' + str(int(visit)) + '.txt'
startsensor = idx * 4
numsensors = 4
if idx == 47:
numsensors = 1
args = visit + ' ' + insidename + ' ' + str(startsensor) + ' ' + str(numsensors) + ' ' + str(idx)
outputname = 'fits_' + visit + '_' + str(idx) + '.tar'
j.setCPUTime(1209600)
j.setExecutable('runimsim2.1.sh', arguments=args)
j.stderr="std.err"
j.stdout="std.out"
#!!! May need the 2.1i directory here depending on visit number !!!
j.setInputSandbox(["runimsim2.1.sh","run_imsim_nersc.py","LFN:/lsst/user/j/james.perry/instcats/2.1i/" + instcatname])
j.setOutputSandbox(["std.out","std.err"])
j.setTag(["4Processors"])
j.setOutputData([visit + "/" + outputname], outputPath="", outputSE=["UKI-NORTHGRID-LANCS-HEP-disk"])
j.setPlatform("AnyPlatform")
# FIXME: remove these once those sites are working again
j.setBannedSites(["VAC.UKI-NORTHGRID-MAN-HEP.uk", "LCG.IN2P3-CC.fr"])
jobID = dirac.submitJob(j)
print("Submitted job as ID " + str(jobID))
print "Status is:", dirac.status(jobID['JobID'])
joblistfile.write(str(jobID['JobID']) + '\n')
joblistfile.close()