[Bio] / FortyEight / batch_rast.pl Repository:
ViewVC logotype

Diff of /FortyEight/batch_rast.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7, Tue Jan 19 17:05:06 2010 UTC revision 1.11, Wed Jan 27 17:35:29 2010 UTC
# Line 49  Line 49 
49    
50  my $job_dir = shift;  my $job_dir = shift;
51    
52    if (-f "$job_dir/CANCEL")
53    {
54        die "Job exiting due to earlier CANCEL\n";
55    }
56    
57  my $job = new Job48($job_dir);  my $job = new Job48($job_dir);
58    
59  my $sims_data_dir = $FIG_Config::rast_sims_data;  my $sims_data_dir = $FIG_Config::rast_sims_data;
# Line 117  Line 122 
122      &do_pchs($job);      &do_pchs($job);
123      &do_scenario($job);      &do_scenario($job);
124      &do_export($job);      &do_export($job);
125        &mark_job_user_complete($job);
126  }  }
127    
128  sub do_upload  sub do_upload
# Line 260  Line 266 
266      &run("$FIG_Config::bin/rp_write_exports", $job->dir);      &run("$FIG_Config::bin/rp_write_exports", $job->dir);
267  }  }
268    
269    sub mark_job_user_complete
270    {
271        my($job) = @_;
272    
273        my $job_dir = $job->dir;
274        my $meta = $job->meta;
275        my $job_id = $job->id;
276    
277        system("$FIG_Config::bin/send_job_completion_email", $job_dir);
278    
279        $meta->set_metadata("status.final", "complete");
280    
281        #
282        # If the job is a SEED candidate, send VV email.
283        #
284    
285        if ($meta->get_metadata("import.suggested") or
286            $meta->get_metadata("import.candidate"))
287        {
288            my $gname = $job->genome_name;
289            my $mail = Mail::Mailer->new();
290            $mail->open({
291                To => 'Veronika Vonstein <veronika@thefig.info>, Robert Olson<olson@mcs.anl.gov>, Andreas Wilke<wilke@mcs.anl.gov>',
292                From => 'Annotation Server <rast@mcs.anl.gov>',
293                Subject => "RAST job $job_id marked for SEED inclusion",
294            });
295    
296            print $mail <<END;
297    RAST job #$job_id ($gname) was submitted for inclusion into the SEED, and has finished its processing.
298    END
299            $mail->close();
300    
301            #
302            # We also mark the job as ACTIVE again so that the
303            # normal post-seed-acceptance pipeline stages may execute.
304            #
305            open(F, ">$job_dir/ACTIVE");
306            close(F);
307        }
308        else
309        {
310            #
311            # Otherwise it is completely done.
312            #
313            &mark_job_done($job);
314        }
315    }
316    
317    sub mark_job_done
318    {
319        my($job) = @_;
320    
321        #
322        # If we spooled the job out onto the lustre disk, we need to
323        # spool it back.
324        #
325    
326        my $meta = $job->meta;
327        my $job_dir = $job->dir;
328    
329        if ($meta->get_metadata("lustre_required"))
330        {
331            &run("$FIG_Config::bin/rp_lustre_finish", $job_dir);
332        }
333        if (open(D, ">$job_dir/DONE"))
334        {
335            print D time . "\n";
336            close(D);
337        }
338        else
339        {
340            warn "Error opening $job_dir/DONE: $!\n";
341        }
342    
343        unlink("$job_dir/ACTIVE");
344    }
345    
346  sub run  sub run
347  {  {
348      my(@cmd) = @_;      my(@cmd) = @_;
349    
350      print "Start: @cmd\n";      my $cmd_str = join(" ", @cmd);
351        print "Start: $cmd_str\n";
352        $meta->add_log_entry($0, ['Start', $cmd_str]);
353      my $rc = system(@cmd);      my $rc = system(@cmd);
354      if ($rc != 0)      if ($rc != 0)
355      {      {
356          confess "Cmd failed with rc=$rc: @cmd\n";          $meta->add_log_entry($0, ['Failed', $rc, $cmd_str]);
357            if (open(FH, ">$job_dir/CANCEL"))
358            {
359                print FH "Cancel job due to error in $0 @cmd\n";
360                close(FH);
361            }
362            #
363            # Attempt to qdel any other parts of this job that are queued or running.
364            #
365            my @jobs;
366            for my $k ($meta->get_metadata_keys())
367            {
368                if ($k  =~ /ph_.*\.sge_job_id/)
369                {
370                    my $job_id = $meta->get_metadata($k);
371                    #
372                    # Don't qdel this job.
373                    #
374                    if ($job_id =~ /^\d+$/ && $job_id != $ENV{JOB_ID})
375                    {
376                        push(@jobs, $job_id);
377                    }
378    
379                }
380            }
381            if (@jobs)
382            {
383                my $rc2 = system("qdel", @jobs);
384                print "qdel @jobs returned $rc2\n";
385                $meta->add_log_entry($0, "Qdel @jobs due to failure returned status $rc2");
386            }
387    
388            confess "Cmd failed with rc=$rc: $cmd_str\n";
389      }      }
390      print "Done: @cmd\n";      $meta->add_log_entry($0, ['Done', $cmd_str]);
391        print "Done: $cmd_str\n";
392  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3