IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ippScripts/scripts/automate_stacks.pl

    r27631 r28003  
    5656# Grab options
    5757my ( $date, $camera, $dbname, $logfile, $verbose, $manual);
    58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only);
     58my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode);
    5959my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips);
    6060my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old);
     
    6767    'logfile=s'            => \$logfile,
    6868    'verbose'              => \$verbose,
     69    'debug'                => \$debug,
    6970    'isburning'            => \$isburning,
    7071    'force_stack_count'    => \$force_stack_count,
     72    'check'                => \$check_mode,
    7173    'test_mode'            => \$test_mode,
    7274    'this_target_only=s'   => \$this_target_only,
     
    115117    defined $queue_chips or defined $queue_stacks or
    116118    defined $check_chips or defined $check_stacks or
    117     defined $test_mode or defined $clean_old;
     119    defined $test_mode or defined $clean_old or defined $check_mode;
    118120
    119121# Configurable parameters from our config file.
     
    126128my %stackable_list = ();
    127129my %reduction_class = ();
    128 my $retention_time = 9000;
    129 
     130my %clean_commands = ();
     131my %clean_retention = ();
     132my %noclean_list = ();
    130133# Grab the configuration data.
    131134my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -";
     
    140143my $metadata = $mdcParser->parse(join "", @$stdout_buf);
    141144foreach my $entry (@{ $metadata }) {
    142     if (${ $entry }{name} eq 'RETENTION_TIME') {
    143         $retention_time = ${ $entry }{value};
    144     }
     145    if (@{ $entry }{name} eq 'CLEAN_MODES') {
     146        my @mode_data = @{ ${ $entry }{value} };
     147        my $this_mode = '';
     148        foreach my $mentry (@mode_data) {
     149            if (${ $mentry }{name} eq 'MODE') {
     150                $this_mode = ${ $mentry }{value};
     151            }
     152            elsif (${ $mentry }{name} eq 'COMMAND') {
     153                $clean_commands{$this_mode} = ${ $mentry }{value};
     154            }
     155            elsif (${ $mentry }{name} eq 'RETENTION_TIME') {
     156                $clean_retention{$this_mode} = ${ $mentry }{value};
     157            }
     158        }
     159    }
     160#    if (${ $entry }{name} eq 'RETENTION_TIME') {
     161#        $retention_time = ${ $entry }{value};
     162#    }
    145163    elsif (${ $entry }{name} eq 'FILTERS') {
    146164        push @filter_list, ${ $entry }{value};
     
    172190                $reduction_class{$this_target} = ${ $tentry }{value};
    173191            }
     192            elsif (${ $tentry }{name} eq 'NOCLEAN') {
     193                $noclean_list{$this_target} = ${ $tentry }{value};
     194            }
    174195        }
    175196    }
     
    217238if (defined($test_mode)) {
    218239    $debug = 1;
    219 }
    220 
    221 if (defined($check_registration) || defined($test_mode)) {
     240    my $z;
     241    foreach $z (@target_list) {
     242        print "TARGET: $z $tessID_list{$z} $obsmode_list{$z} $object_list{$z} $comment_list{$z} $stackable_list{$z} $reduction_class{$z}\n";
     243    }
     244    foreach $z (@filter_list) {
     245        print "FILTER: $z\n";
     246    }
     247    foreach $z (keys (%clean_commands)) {
     248        print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n";
     249    }
     250   
     251}
     252
     253if (defined($check_registration) || defined($test_mode) || defined($check_mode)) {
    222254    $metadata_out{nsState} = 'NEW';
    223255    my ($Nsummit_exp,$Nfaults) = check_summit_copy($date);
    224256    return_metadata($date);
    225     unless (defined($test_mode)) { exit(0); }
     257    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    226258}
    227259if (defined($define_burntool) || defined($test_mode)) {
     
    236268    unless (defined($test_mode)) { exit(0); }
    237269}
    238 if (defined($check_chips) || defined($test_mode)) {
     270if (defined($check_chips) || defined($test_mode) || defined($check_mode)) {
    239271    $metadata_out{nsState} = 'QUEUECHIPS';
    240272    &execute_chips($date,"pretend");
     
    243275    }
    244276    return_metadata($date);
    245     unless (defined($test_mode)) { exit(0); }
     277    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    246278}
    247279if (defined($queue_chips)) {
     
    251283    exit(0);
    252284}
    253 if (defined($check_stacks) || defined($test_mode)) {
     285if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) {
    254286    $metadata_out{nsState} = 'TOWARP';
    255287    &execute_stacks($date,"pretend");
     
    258290    }
    259291    return_metadata($date);
    260     unless (defined($test_mode)) { exit(0); }
     292    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    261293}
    262294if (defined($queue_stacks)) {
    263295    $metadata_out{nsState} = 'STACKING';
    264296    &execute_stacks($date);
     297    if ($metadata_out{nsState} eq 'QUEUESTACKING') {
     298        $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR';
     299    }
    265300    return_metadata($date);
    266301    exit(0);
     
    420455    }
    421456
    422     if ($#{ $stderr_buf } > -1) {
    423         $metadata_out{nsState} = 'ERROR';
    424         return(1);
    425     }
     457#    if ($#{ $stderr_buf } > -1) {
     458#        $metadata_out{nsState} = 'ERROR';
     459#        return(1);
     460#    }
    426461
    427462    my $N = 0;
     
    429464    foreach my $row (@burntool_entries) {
    430465        my ($trash,$start,$end);
    431         ($trash,$trash,$start,$end) = (split /\s+/,$row);
    432 
     466        (undef,$trash,$start,$end) = (split /\s+/,$row);
     467        if ($trash ne 'burntool') {
     468            $metadata_out{nsState} = 'ERROR';
     469            return(1);
     470        }
    433471        for (my $class_counter = 0; $class_counter < 60; $class_counter++) {
    434472            $metadata_out{"bt${N}Begin"} = $start;
     
    650688    my @input_exposures = split /\n/, (join '', @$stdout_buf);
    651689    foreach my $entry (@input_exposures) {
    652         my ($skycell, @trash) = split /\s+/, $entry;
     690        my ($warp_tess_id,$skycell, @trash) = split /\s+/, $entry;
    653691        @trash = verify_uniqueness_stack($skycell,$date,$target,$filter);
    654692        $Nalready += $trash[0];
     
    681719                my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter);
    682720                if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :(
    683                     # print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n";
     721                    if ($debug == 1) {
     722                        print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n";
     723                    }
    684724                    $metadata_out{nsState} = 'FORCETOWARP';
    685725                    next;
    686726                }
    687727                if ($Nexposures == 0) {
    688                     # print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n";
     728                    if ($debug == 1) {
     729                        print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n";
     730                    }
    689731                    next;
    690732                }
    691733                if ($Nalready != 0) {
    692                     # print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n";
     734                    if ($debug == 1) {
     735                        print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n";
     736                    }
     737                    unless ($metadata_out{nsState} eq 'FORCETOWARP') {
     738                        $metadata_out{nsState} = 'STACKING';
     739                    }
    693740                    next;
    694741                }
    695                 unless ($metadata_out{nsState} eq 'FORCETOWARP') {
     742                unless (($metadata_out{nsState} eq 'FORCETOWARP')||($metadata_out{nsState} eq 'STACKING')) {
    696743                    $metadata_out{nsState} = 'QUEUESTACKS';
    697744                }
    698745                unless(defined($pretend)) {
    699                     # print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n";
     746                    if ($debug == 1) {
     747                        print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n";
     748                    }
    700749                    stack_queue($date,$target,$filter);
    701750                }
     
    716765    my $date = shift;
    717766    my $target = shift;
     767    my $mode = shift;
     768
     769    my $command = $clean_commands{$mode};
     770    my $retention_time = $clean_retention{$mode};
    718771
    719772    my ($year,$month,$day) = split /-/,$date;
     
    725778
    726779    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target);
    727 
    728     my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group ";
     780    my $args = $command;
     781    $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group ";
    729782    if ($debug == 1) {
    730783        $args .= ' -pretend ';
     
    737790    my $pretend = shift;
    738791
    739     foreach my $target (@target_list) {
    740         my ($cleaning_date,$args) = construct_cleantool_args($date,$target);
    741 
    742         my $command = $chiptool . $args;
    743         print STDERR "$command\n";
    744         if (!(defined($pretend) || $debug == 1)) {
     792    foreach my $mode (keys (%clean_commands)) {
     793        foreach my $target (@target_list) {
     794            if (exists($noclean_list{$target})) {
     795                next;
     796            }
     797            my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode);
     798
     799            print STDERR "$command\n";
     800            if (!(defined($pretend) || $debug == 1)) {
    745801#           print STDERR "BEAR IS DRIVING!?\n";
    746             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    747                 run ( command => $command, verbose => $verbose );
    748             unless ($success) {
    749                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    750                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    751             }
    752         }
    753         $command = $warptool . $args;
    754         print STDERR "$command\n";
    755         if (!(defined($pretend) || $debug == 1)) {
    756 #           print STDERR "BEAR IS DRIVING $pretend $debug!?\n";
    757             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    758                 run ( command => $command, verbose => $verbose );
    759             unless ($success) {
    760                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    761                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    762             }
    763         }
     802                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     803                    run ( command => $command, verbose => $verbose );
     804                unless ($success) {
     805                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     806                    &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     807                }
     808            }
     809        }
    764810    }
    765811    return(0);
Note: See TracChangeset for help on using the changeset viewer.