ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/DBTools/scripts/osusub
(Generate patch)

Comparing UserCode/OSUT3Analysis/DBTools/scripts/osusub (file contents):
Revision 1.13 by ahart, Fri Feb 8 09:17:45 2013 UTC vs.
Revision 1.19 by ahart, Thu Jun 6 20:53:32 2013 UTC

# Line 5 | Line 5 | use Mysql;
5   use File::Copy;
6   use Getopt::Long;
7   use POSIX;
8 + use Term::ANSIColor;
9  
10   sub printHelp;
11   sub outputPset;
# Line 16 | Line 17 | our $db = Mysql->connect ("cmshead", "nt
17  
18   my %opt;
19   Getopt::Long::Configure ("bundling");
20 < GetOptions (\%opt, "maxEvents|m=s", "help|h");
20 > GetOptions (\%opt, "label|l=s", "maxEvents|m=s", "help|h");
21   my $argc = @ARGV;
22  
23   printHelp () if $opt{"help"};
# Line 58 | Line 59 | my $eventsPerJob = -1;
59   $eventsPerJob = ceil ($opt{"maxEvents"} / $realNJobs) if $opt{"maxEvents"} && $opt{"maxEvents"} >= 0;
60   my $realMaxEvents = $eventsPerJob * $realNJobs;
61   outputPset ($directory, $dataset, $opt{"maxEvents"}, $eventsPerJob);
62 < outputCondor ($directory, $realNJobs, $dataset);
62 > outputCondor ("$ENV{'CMSSW_BASE'}/src/OSUT3Analysis/DBTools/data/condor.sub", $directory, $realNJobs, $dataset, $opt{"label"});
63   copy ($config, "$directory/userConfig_cfg.py");
64   chdir $directory;
65   print "Submitting $realNJobs jobs to run on $realMaxEvents events in $nFiles files.\n" if $realMaxEvents >= 0;
66   print "Submitting $realNJobs jobs to run on all events in $nFiles files.\n" if $realMaxEvents < 0;
67 < system ("condor_submit condor.sub");
67 > system ("LD_LIBRARY_PATH=/usr/lib64/condor:\$LD_LIBRARY_PATH condor_submit condor.sub");
68  
69   sub
70   outputPset
# Line 177 | Line 178 | getLocation
178    my $queryDataset = $dataset;
179    $queryDataset =~ s/\*/%/g;
180    $queryDataset =~ s/(.*)/%$1%/g;
181 <  my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn from ntuple where dataset like '$queryDataset' order by creationTime";
181 >  my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn,higherOrderCrossSectionInPicobarn from ntuple where dataset like '$queryDataset' order by creationTime";
182    $db->selectdb ("ntuple");
183    $results = $db->query ($query);
184    if ($results->numrows () == 1)
185      {
186        my @row = $results->fetchrow ();
187 <      return ($row[3], $row[4], $row[5], $row[6]);
187 >      return ($row[3], $row[4], $row[5], $row[7]) if $row[7];
188 >      return ($row[3], $row[4], $row[5], $row[6]) if !$row[7];
189      }
190    if ($results->numrows () == 0)
191      {
# Line 196 | Line 198 | getLocation
198    for (my $i = 1; $i <= $results->numrows (); $i++)
199      {
200        my @row = $results->fetchrow ();
201 <      $map{"$i"} = [$row[3], $row[4], $row[5], $row[6]];
201 >      $row[2] =~ s/([^ ]*) [^ ]*/$1/g;
202 >      $map{"$i"} = [$row[3], $row[4], $row[5], $row[7]] if $row[7];
203 >      $map{"$i"} = [$row[3], $row[4], $row[5], $row[6]] if !$row[7];
204        printf "(%2d) $row[0]\n", $i;
205 <      print "     created by $row[1] on $row[2]\n";
205 >      print "     (";
206 >      print color "green" if $row[5] eq "present";
207 >      print color "bold yellow" if $row[5] eq "submitted";
208 >      print color "bold red" if $row[5] eq "created" or $row[5] eq "cancelled" or $row[5] eq "deprecated";
209 >      print $row[5];
210 >      print color "reset";
211 >      print ") created by $row[1] on $row[2]\n";
212      }
213    print "\nWhich dataset would you like to use?: ";
214    my $response = <STDIN>;
# Line 215 | Line 225 | getLocation
225   sub
226   outputCondor
227   {
228 +  my $condorFileName = shift;
229    my $workingDir = shift;
230    my $nJobs = shift;
231    my $dataset = shift;
232 +  my $label = shift;
233  
234    my $cmsRun = `which cmsRun`;
235 <  open (SUB, ">$workingDir/condor.sub");
235 >  my $condorFile = "";
236  
237 <  print SUB "Executable              = $cmsRun\n";
238 <  print SUB "Universe                = vanilla\n";
239 <  print SUB "Getenv                  = True\n";
240 <  print SUB "Arguments               = config_cfg.py True $nJobs \$(Process) $dataset\n" if $dataset;
241 <  print SUB "Arguments               = config_cfg.py True $nJobs \$(Process) NULL\n" if !$dataset;
242 <  print SUB "\n";
243 <  print SUB "Output                  = condor_\$(Process).out\n";
244 <  print SUB "Error                   = condor_\$(Process).err\n";
245 <  print SUB "Log                     = condor_\$(Process).log\n";
246 <  print SUB "\n";
247 <  print SUB "+IsLocalJob             = true\n";
248 <  print SUB "Rank                    = TARGET.IsLocalSlot\n";
249 <  print SUB "\n";
250 <  print SUB "Queue $nJobs\n";
237 >  if (!(-e $condorFileName))
238 >    {
239 >      my $arguments = "Arguments               = config_cfg.py True $nJobs \$(Process)";
240 >      $arguments .= " $dataset" if $dataset;
241 >      $arguments .= " NULL" if !$dataset;
242 >      $arguments .= " $label" if $label;
243 >      $arguments .= " NULL" if !$label;
244 >      $arguments .= "\n";
245 >
246 >      $condorFile .= "Executable              = $cmsRun\n";
247 >      $condorFile .= "Universe                = vanilla\n";
248 >      $condorFile .= "Getenv                  = True\n";
249 >      $condorFile .= $arguments;
250 >      $condorFile .= "\n";
251 >      $condorFile .= "Output                  = condor_\$(Process).out\n";
252 >      $condorFile .= "Error                   = condor_\$(Process).err\n";
253 >      $condorFile .= "Log                     = condor_\$(Process).log\n";
254 >      $condorFile .= "\n";
255 >      $condorFile .= "+IsLocalJob             = true\n";
256 >      $condorFile .= "Rank                    = TARGET.IsLocalSlot\n";
257 >      $condorFile .= "\n";
258 >      $condorFile .= "Queue $nJobs\n";
259 >    }
260 >  else
261 >    {
262 >      open (SUB, "<$condorFileName");
263 >      my @condorFile = <SUB>;
264 >      close (SUB);
265 >      $condorFile = join ("", @condorFile);
266 >      $condorFile =~ s/\$cmsRun/$cmsRun/g;
267 >      $condorFile =~ s/\$nJobs/$nJobs/g;
268 >      $condorFile =~ s/\$dataset/$dataset/g if $dataset;
269 >      $condorFile =~ s/\$dataset/NULL/g if !$dataset;
270 >      $condorFile =~ s/\$label/$label/g if $label;
271 >      $condorFile =~ s/\$label/NULL/g if !$label;
272 >    }
273  
274 +  open (SUB, ">$workingDir/condor.sub");
275 +  print SUB $condorFile;
276    close (SUB);
277   }
278  
# Line 250 | Line 286 | printHelp
286    print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n";
287    print "\n";
288    printf "%-29s%s\n", "  -h, --help", "print this help message";
289 +  printf "%-29s%s\n", "  -l, --label LABEL", "give the dataset a short label";
290    printf "%-29s%s\n", "  -m, --maxEvents N", "only run over N events in the dataset; default is";
291    printf "%-29s%s\n", " ", "to run over all events";
292    print "\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines