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); |
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 |
105 |
|
} |
106 |
|
print RUNLIST "]"; |
107 |
|
close (RUNLIST); |
108 |
+ |
|
109 |
+ |
return $nFiles; |
110 |
|
} |
111 |
|
|
112 |
|
sub |
115 |
|
my $dataset = shift; |
116 |
|
|
117 |
|
my $results; |
118 |
< |
$db = Mysql->connect ("cmshead", "ntuple", "osuT3User"); |
119 |
< |
my $query = "select user,creationTime,location,nFiles,status from ntuple where dataset='$dataset' order by lastUpdateTime"; |
118 |
> |
my $queryDataset = $dataset; |
119 |
> |
$queryDataset =~ s/\*/%/g; |
120 |
> |
$queryDataset =~ s/(.*)/%$1%/g; |
121 |
> |
my $query = "select dataset,user,creationTime,location,nFiles,status from ntuple where dataset like '$queryDataset' and status='present' order by creationTime"; |
122 |
|
$db->selectdb ("ntuple"); |
123 |
|
$results = $db->query ($query); |
124 |
|
if ($results->numrows () == 1) |
125 |
|
{ |
126 |
|
my @row = $results->fetchrow (); |
127 |
< |
return ($row[2], $row[3], $row[4]); |
127 |
> |
return ($row[3], $row[4], $row[5]); |
128 |
|
} |
129 |
|
if ($results->numrows () == 0) |
130 |
|
{ |
137 |
|
for (my $i = 1; $i <= $results->numrows (); $i++) |
138 |
|
{ |
139 |
|
my @row = $results->fetchrow (); |
140 |
< |
$map{"$i"} = [$row[2], $row[3], $row[4]]; |
141 |
< |
print "($i) created by $row[0] on $row[1]\n"; |
140 |
> |
$map{"$i"} = [$row[3], $row[4], $row[5]]; |
141 |
> |
printf "(%2d) $row[0]\n", $i; |
142 |
> |
print " created by $row[1] on $row[2]\n"; |
143 |
|
} |
144 |
|
print "\nWhich dataset would you like to use?: "; |
145 |
|
my $response = <STDIN>; |
182 |
|
my $exeName = $0; |
183 |
|
$exeName =~ s/^.*\/([^\/]*)$/$1/; |
184 |
|
|
185 |
< |
print "Usage: $exeName [OPTION] DATASET CONFIG DIRECTORY NJOBS\n"; |
185 |
> |
print "Usage: $exeName [OPTION]... DATASET CONFIG DIRECTORY NJOBS\n"; |
186 |
|
print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n"; |
187 |
|
print "\n"; |
188 |
|
printf "%-29s%s\n", " -h, --help", "print this help message"; |