IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28047


Ignore:
Timestamp:
May 20, 2010, 10:02:51 AM (16 years ago)
Author:
bills
Message:

Handle case where warp is in update state, but the dependent chips are not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_checkdependent.pl

    r27921 r28047  
    135135        print "skipping $command\n";
    136136    }
    137 } elsif (($it->{state} eq 'cleaned') or ($it->{state} eq 'update') and
    138         ($whole_run or ($it->{data_state} eq 'cleaned'))) {
    139 
    140     # Update has not been queued for this component yet. 
    141 
    142     # XXX: if $whole_run this is going to repeatedly call -setimfiletoupdate. This will be a no-op
    143     # but is wasteful.
    144     # Maybe we should deal with having three states for pstampDependent.state. 'new', 'run', 'full'
    145     # need to queue the updates
     137} elsif (($it->{state} eq 'cleaned') or ($it->{state} eq 'update')) {
     138    #       For warp and diff stages we need to call the 'queue_update' subroutines even if the
     139    #       data_state is update in order to check the earlier stages in the pipeline
     140    #       For example if warpSkyfile is in update state but the chip run that it depends on hasn't
     141    #       been updated we need to go and queue it.
     142
    146143    if ($stage eq 'chip') {
    147         # queue_update_chip takes an array so that queue_update_warp can pass it set of chips
     144        # check_states_chip takes an array so that check_states_warp can pass it set of chips
    148145        my $chips = [$it];
    149         $status = queue_update_chip($it->{chip_id}, $whole_run, $chips, $rlabel, $need_magic);
     146        $status = check_states_chip($it->{chip_id}, $whole_run, $chips, $rlabel, $need_magic);
    150147    } elsif ($stage eq 'warp') {
    151         $status = queue_update_warp($it, $whole_run, $rlabel, $need_magic);
     148        $status = check_states_warp($it, $whole_run, $rlabel, $need_magic);
    152149    } elsif ($stage eq 'diff') {
    153         $status = queue_update_diff($it, $whole_run, $rlabel, $need_magic);
     150        $status = check_states_diff($it, $whole_run, $rlabel, $need_magic);
    154151    } else {
    155152        my_die("Unexpected stage found $stage", $PS_EXIT_PROG_ERROR);
    156153    }
    157154} else {
    158     # update for this component has been queued by hasn't completed yet or the state is an error state
    159     # XXX: in this state we aren't checking the dependents anymore. If something goes wrong this
    160     # will never complete. Consider calling the 'queue_update' functions again just to check. They are relatively cheap
    161 
    162 
    163155    print "${stage}Run $stage_id state is $it->{state} $component data_state is $it->{data_state}\n";
    164156
     
    170162    my $job_fault = 0;
    171163
    172     # temporary hack to deal with data with old burntool tables. This check is now done by pstampparse.pl
    173     # so runs in this state should not get queued
     164if (0) {
    174165    if ($stage eq 'chip') {
     166        # XXX: There is no need to check this anymore. All magicked chipRuns have abs(burntool_state) >= 13
     167        # If something changes that causes an error, we will figure that out from the chip failure
    175168        my $burntool_state = $it->{burntool_state};
    176         if ($burntool_state and (abs($burntool_state) < 14)) {
     169        # XXX: get the value of 13 from the ppImage recipe
     170        if ($burntool_state and (abs($burntool_state) < 13)) {
    177171            print STDERR "chip $it->{chip_id} $it->{class_id} has burntool_state $burntool_state. Not avaiable.\n";
    178172            $job_fault = $PSTAMP_NOT_AVAILABLE;
    179173        }
    180174    }
     175}
    181176    if ($state eq 'error_cleaned') {
    182177        $job_fault = $PSTAMP_NOT_AVAILABLE;
     
    191186    if (!$job_fault and ($stage eq 'chip')) {
    192187        # chip processing is done, start destreaking.
    193         $job_fault = queue_update_magicDSRun($stage, $stage_id, $rlabel, $need_magic, $it->{raw_magicked}, $it->{dsRun_state});
     188        $job_fault = check_states_magicDSRun($stage, $stage_id, $rlabel, $need_magic, $it->{raw_magicked}, $it->{dsRun_state});
    194189    }
    195190    if ($job_fault) {
     
    201196
    202197
    203 sub queue_update_chip {
     198sub check_states_chip {
    204199    my $chip_id = shift;
    205200    my $whole_run = shift;  # if true queue entire run for update
     
    216211            $raw_all_magicked &= ($chip->{raw_magicked} > 0);
    217212
    218             if ($chip->{state} =~ /error/) {
     213            if (($chip->{state} =~ /error/) or ($chip->{state} =~ /purged/) or ($chip->{state} =~ /scrubbed/)) {
     214                print "chipRun state is $chip->{chip_id} is in state $chip->{state} cannot update\n";
    219215                faultJobs('stop', undef, undef, $PSTAMP_GONE);
     216                return;
    220217            } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) {
    221218                my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id -class_id $chip->{class_id}";
     
    237234        $dsRun_state = $run->{dsRun_state};
    238235        $raw_all_magicked = ($run->{raw_magicked} > 0);
     236        my $state = $run->{state};
     237        if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/)) {
     238            print "chipRun state is $run->{chip_id} is in state $state cannot update\n";
     239            faultJobs('stop', undef, undef, $PSTAMP_GONE);
     240            return;
     241        }
    239242
    240243        # providing no -class_id arguments changes all imfiles with data_state = 'cleaned' to 'update'
     
    253256    }
    254257
    255     my $status = queue_update_magicDSRun('chip', $chip_id, $rlabel, $need_magic, $raw_all_magicked, $dsRun_state);
     258    my $status = check_states_magicDSRun('chip', $chip_id, $rlabel, $need_magic, $raw_all_magicked, $dsRun_state);
    256259
    257260    return $status;
    258261}
    259262
    260 sub queue_update_warp {
     263sub check_states_warp {
    261264    # check status of input chips. If state is not updatable set error code for job
    262265
    263     # if chipProcessedImfile.state is cleaned call queue_update_chip
     266    # if chipProcessedImfile.state is cleaned call check_states_chip
    264267
    265268    # need to code warptool -setskyfiletoupdate
     
    301304        }
    302305
    303         if ($chips_ready) {
     306        if ($chips_ready and $skycell->{data_state} ne 'update') {
    304307            # the reason we defer setting the warp to update is so that we can handle error conditions at previous
    305308            # stages more easily.
     
    317320            }
    318321        } elsif (scalar @chipsToUpdate > 0) {
    319             return queue_update_chip($chip_id, 0, \@chipsToUpdate, $rlabel, $need_magic);
     322            return check_states_chip($chip_id, 0, \@chipsToUpdate, $rlabel, $need_magic);
    320323        }
    321324    } else {
     
    354357            (($chipRun->{state} eq 'full') and ($need_magic and ($chipRun->{magicked} < 0) and ($chipRun->{dsRun_state} ne 'new')))) {
    355358            my $data = [$chipRun];
    356             return queue_update_chip($chipRun->{chip_id}, 1, $data, $rlabel, $need_magic);
     359            return check_states_chip($chipRun->{chip_id}, 1, $data, $rlabel, $need_magic);
    357360        }
    358361    }
     
    361364    return 0;
    362365}
    363 sub queue_update_diff {
     366sub check_states_diff {
    364367    my $metadata = shift;
    365368    my $whole_run = shift;  # if true queue entire run for update
     
    392395
    393396            if ($warp->{data_state} ne 'full') {
    394                 return queue_update_warp($warp, 0, $rlabel, $need_magic);
     397                return check_states_warp($warp, 0, $rlabel, $need_magic);
    395398            }
    396399            # warps are ready fall through and queue the diff update
     
    404407            if ($warp1->{data_state} ne 'full') {
    405408                $warps_ready = 0;
    406                 $status = queue_update_warp($warp1, 0, $rlabel, $need_magic);
     409                $status = check_states_warp($warp1, 0, $rlabel, $need_magic);
    407410                if ($status) {
    408411                    return $status;
     
    415418            if ($warp2->{data_state} ne 'full') {
    416419                $warps_ready = 0;
    417                 $status = queue_update_warp($warp2, 0, $rlabel, $need_magic);
     420                $status = check_states_warp($warp2, 0, $rlabel, $need_magic);
    418421            }
    419422
     
    467470
    468471            if ($warp->{data_state} ne 'full') {
    469                 return queue_update_warp($warp, 0, $rlabel, $need_magic);
     472                return check_states_warp($warp, 0, $rlabel, $need_magic);
    470473            }
    471474            # warps are ready fall through and queue the diff update
     
    474477        }
    475478
    476         my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id";
    477         $command .= " -set_label $rlabel" if $rlabel;
    478 
    479         if (!$no_update) {
    480             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    481                         run(command => $command, verbose => $verbose);
    482             unless ($success) {
    483                 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    484             }
    485         } else {
    486             print "skipping $command\n";
     479        if ($skycell->{data_state} ne 'update') {
     480            my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id";
     481            $command .= " -set_label $rlabel" if $rlabel;
     482
     483            if (!$no_update) {
     484                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     485                            run(command => $command, verbose => $verbose);
     486                unless ($success) {
     487                    my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
     488                }
     489            } else {
     490                print "skipping $command\n";
     491            }
    487492        }
    488493    } else {
     
    599604}
    600605
    601 sub queue_update_magicDSRun {
     606sub check_states_magicDSRun {
    602607    my $stage = shift;
    603608    my $stage_id = shift;
     
    608613
    609614    # XXX: this code assumes that destreaking is handled at the chip stage
    610     my_die ("queue_update_magicDSRun only works for stage chip", $PS_EXIT_PROG_ERROR) if $stage ne 'chip';
    611 
    612     # if called from queue_update_warp dsRun_state is unknown. Go find it.
     615    my_die ("check_states_magicDSRun only works for stage chip", $PS_EXIT_PROG_ERROR) if $stage ne 'chip';
     616
     617    # if called from check_states_warp dsRun_state is unknown. Go find it.
    613618    if (!$dsRun_state) {
    614619        my $command = "$chiptool -listrun -chip_id $stage_id";
Note: See TracChangeset for help on using the changeset viewer.