4 |
|
use Mysql; |
5 |
|
use File::Copy; |
6 |
|
use Getopt::Long; |
7 |
< |
sub printHelp; |
7 |
> |
use POSIX; |
8 |
|
|
9 |
+ |
sub printHelp; |
10 |
|
sub outputPset; |
11 |
|
sub outputRunList; |
12 |
|
sub getLocation; |
13 |
|
sub outputCondor; |
14 |
|
|
15 |
< |
our $db; |
15 |
> |
our $db = Mysql->connect ("cmshead", "ntuple", "osuT3User"); |
16 |
|
|
17 |
|
my %opt; |
18 |
|
Getopt::Long::Configure ("bundling"); |
33 |
|
exit; |
34 |
|
} |
35 |
|
mkdir $ARGV[2]; |
36 |
< |
outputRunList ($ARGV[0], $ARGV[2]); |
36 |
> |
my $nFiles = outputRunList ($ARGV[0], $ARGV[2]); |
37 |
> |
my $nJobs = $ARGV[3]; |
38 |
> |
my $realNJobs = ceil ($nFiles / ceil ($nFiles / $nJobs)); |
39 |
|
outputPset ($ARGV[2]); |
40 |
< |
outputCondor ($ARGV[2], $ARGV[3]); |
40 |
> |
outputCondor ($ARGV[2], $realNJobs, $ARGV[0]); |
41 |
|
copy ($ARGV[1], "$ARGV[2]/userConfig_cfg.py"); |
42 |
|
chdir $ARGV[2]; |
43 |
+ |
print "Submitting $realNJobs jobs to run on $nFiles files.\n"; |
44 |
|
system ("condor_submit condor.sub"); |
45 |
|
|
46 |
|
sub |
74 |
|
my $dataset = shift; |
75 |
|
my $workingDir = shift; |
76 |
|
|
77 |
< |
my ($location, $nFiles, $status) = getLocation ($dataset); |
78 |
< |
if ($status ne "present") |
79 |
< |
{ |
80 |
< |
print "This dataset is not marked as present on the Tier 3!\n"; |
81 |
< |
exit; |
77 |
> |
my $location; |
78 |
> |
my $nFiles; |
79 |
> |
my $status; |
80 |
> |
my $crossSection; |
81 |
> |
my $isLocation = 0; |
82 |
> |
$isLocation = 1 if -e $dataset; |
83 |
> |
if (!$isLocation) |
84 |
> |
{ |
85 |
> |
($location, $nFiles, $status, $crossSection) = getLocation ($dataset); |
86 |
> |
if ($status ne "present") |
87 |
> |
{ |
88 |
> |
print "This dataset is not marked as present on the Tier 3!\n"; |
89 |
> |
print "Continue anyway? (y/N): "; |
90 |
> |
my $response = <STDIN>; |
91 |
> |
$response =~ s/\n//g; |
92 |
> |
exit if !$response || lc ($response) ne "y"; |
93 |
> |
} |
94 |
> |
if (!(-e $location)) |
95 |
> |
{ |
96 |
> |
print "The database does not know where this dataset is!\n"; |
97 |
> |
exit; |
98 |
> |
} |
99 |
|
} |
100 |
< |
if (!(-e $location)) |
100 |
> |
else |
101 |
|
{ |
102 |
< |
print "The database does not know where this dataset is!\n"; |
82 |
< |
exit; |
102 |
> |
$location = $dataset; |
103 |
|
} |
104 |
|
opendir (LOCATION, $location); |
105 |
|
my @files = readdir (LOCATION); |
106 |
|
closedir (LOCATION); |
107 |
< |
if (@files - 2 != $nFiles) |
107 |
> |
if (!$isLocation && @files - 2 != $nFiles) |
108 |
|
{ |
109 |
|
print "Number of files does not match database entry!\n"; |
110 |
< |
exit; |
110 |
> |
print "Continue anyway? (y/N): "; |
111 |
> |
my $response = <STDIN>; |
112 |
> |
$response =~ s/\n//g; |
113 |
> |
exit if !$response || lc ($response) ne "y"; |
114 |
> |
} |
115 |
> |
elsif ($isLocation) |
116 |
> |
{ |
117 |
> |
$nFiles = @files - 2; |
118 |
|
} |
119 |
|
open (RUNLIST, ">$workingDir/runList.py"); |
120 |
|
print RUNLIST "runList = [\n"; |
128 |
|
} |
129 |
|
print RUNLIST "]"; |
130 |
|
close (RUNLIST); |
131 |
+ |
if ($crossSection && $crossSection >= 0.0) |
132 |
+ |
{ |
133 |
+ |
open (CROSS_SECTION, ">$workingDir/crossSectionInPicobarn.txt"); |
134 |
+ |
print CROSS_SECTION "$crossSection\n"; |
135 |
+ |
close (CROSS_SECTION); |
136 |
+ |
} |
137 |
+ |
|
138 |
+ |
return $nFiles; |
139 |
|
} |
140 |
|
|
141 |
|
sub |
144 |
|
my $dataset = shift; |
145 |
|
|
146 |
|
my $results; |
147 |
< |
$db = Mysql->connect ("cmshead", "ntuple", "osuT3User"); |
148 |
< |
my $query = "select user,creationTime,location,nFiles,status from ntuple where dataset='$dataset' order by lastUpdateTime"; |
147 |
> |
my $queryDataset = $dataset; |
148 |
> |
$queryDataset =~ s/\*/%/g; |
149 |
> |
$queryDataset =~ s/(.*)/%$1%/g; |
150 |
> |
my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn from ntuple where dataset like '$queryDataset' order by creationTime"; |
151 |
|
$db->selectdb ("ntuple"); |
152 |
|
$results = $db->query ($query); |
153 |
|
if ($results->numrows () == 1) |
154 |
|
{ |
155 |
|
my @row = $results->fetchrow (); |
156 |
< |
return ($row[2], $row[3], $row[4]); |
156 |
> |
return ($row[3], $row[4], $row[5], $row[6]); |
157 |
|
} |
158 |
|
if ($results->numrows () == 0) |
159 |
|
{ |
166 |
|
for (my $i = 1; $i <= $results->numrows (); $i++) |
167 |
|
{ |
168 |
|
my @row = $results->fetchrow (); |
169 |
< |
$map{"$i"} = [$row[2], $row[3], $row[4]]; |
170 |
< |
print "($i) created by $row[0] on $row[1]\n"; |
169 |
> |
$map{"$i"} = [$row[3], $row[4], $row[5], $row[6]]; |
170 |
> |
printf "(%2d) $row[0]\n", $i; |
171 |
> |
print " created by $row[1] on $row[2]\n"; |
172 |
|
} |
173 |
|
print "\nWhich dataset would you like to use?: "; |
174 |
|
my $response = <STDIN>; |
179 |
|
exit; |
180 |
|
} |
181 |
|
|
182 |
< |
return ($map{$response}[0], $map{$response}[1], $map{$response}[2]); |
182 |
> |
return ($map{$response}[0], $map{$response}[1], $map{$response}[2], $map{$response}[3]); |
183 |
|
} |
184 |
|
|
185 |
|
sub |
187 |
|
{ |
188 |
|
my $workingDir = shift; |
189 |
|
my $nJobs = shift; |
190 |
+ |
my $dataset = shift; |
191 |
|
|
192 |
|
my $cmsRun = `which cmsRun`; |
193 |
|
open (SUB, ">$workingDir/condor.sub"); |
195 |
|
print SUB "Executable = $cmsRun\n"; |
196 |
|
print SUB "Universe = vanilla\n"; |
197 |
|
print SUB "Getenv = True\n"; |
198 |
< |
print SUB "Arguments = config_cfg.py $nJobs \$(Process)\n"; |
198 |
> |
print SUB "Arguments = config_cfg.py True $nJobs \$(Process) $dataset\n"; |
199 |
|
print SUB "\n"; |
200 |
|
print SUB "Output = condor_\$(Process).out\n"; |
201 |
|
print SUB "Error = condor_\$(Process).err\n"; |
202 |
|
print SUB "Log = condor_\$(Process).log\n"; |
203 |
|
print SUB "\n"; |
204 |
+ |
print SUB "+IsLocalJob = true\n"; |
205 |
+ |
print SUB "Rank = TARGET.IsLocalSlot\n"; |
206 |
+ |
print SUB "\n"; |
207 |
|
print SUB "Queue $nJobs\n"; |
208 |
|
|
209 |
|
close (SUB); |
215 |
|
my $exeName = $0; |
216 |
|
$exeName =~ s/^.*\/([^\/]*)$/$1/; |
217 |
|
|
218 |
< |
print "Usage: $exeName [OPTION] DATASET CONFIG DIRECTORY NJOBS\n"; |
218 |
> |
print "Usage: $exeName [OPTION]... DATASET CONFIG DIRECTORY NJOBS\n"; |
219 |
> |
print " or: $exeName [OPTION]... LOCATION CONFIG DIRECTORY NJOBS\n"; |
220 |
|
print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n"; |
221 |
|
print "\n"; |
222 |
|
printf "%-29s%s\n", " -h, --help", "print this help message"; |
223 |
|
print "\n"; |
224 |
< |
print "The DATASET must exist in the Tier 3 ntuple database, and CONFIG must be a valid\n"; |
225 |
< |
print "CMSSW python configuration which can be used with cmsRun. DIRECTORY is a working\n"; |
224 |
> |
print "The first argument must be either a DATASET registered in the Tier 3 ntuple\n"; |
225 |
> |
print "database or a LOCATION which exists on disk. CONFIG must be a valid CMSSW\n"; |
226 |
> |
print "python configuration which can be used with cmsRun. DIRECTORY is a working\n"; |
227 |
|
print "directory that is created and in which all output, both from the CMSSW jobs and\n"; |
228 |
|
print "from Condor, is placed. Finally, NJOBS is the number of Condor jobs that will\n"; |
229 |
|
print "be created.\n"; |