- Timestamp:
- May 20, 2010, 10:02:51 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_checkdependent.pl (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_checkdependent.pl
r27921 r28047 135 135 print "skipping $command\n"; 136 136 } 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 146 143 if ($stage eq 'chip') { 147 # queue_update_chip takes an array so that queue_update_warp can pass it set of chips144 # check_states_chip takes an array so that check_states_warp can pass it set of chips 148 145 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); 150 147 } 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); 152 149 } 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); 154 151 } else { 155 152 my_die("Unexpected stage found $stage", $PS_EXIT_PROG_ERROR); 156 153 } 157 154 } else { 158 # update for this component has been queued by hasn't completed yet or the state is an error state159 # XXX: in this state we aren't checking the dependents anymore. If something goes wrong this160 # will never complete. Consider calling the 'queue_update' functions again just to check. They are relatively cheap161 162 163 155 print "${stage}Run $stage_id state is $it->{state} $component data_state is $it->{data_state}\n"; 164 156 … … 170 162 my $job_fault = 0; 171 163 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 164 if (0) { 174 165 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 175 168 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)) { 177 171 print STDERR "chip $it->{chip_id} $it->{class_id} has burntool_state $burntool_state. Not avaiable.\n"; 178 172 $job_fault = $PSTAMP_NOT_AVAILABLE; 179 173 } 180 174 } 175 } 181 176 if ($state eq 'error_cleaned') { 182 177 $job_fault = $PSTAMP_NOT_AVAILABLE; … … 191 186 if (!$job_fault and ($stage eq 'chip')) { 192 187 # 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}); 194 189 } 195 190 if ($job_fault) { … … 201 196 202 197 203 sub queue_update_chip {198 sub check_states_chip { 204 199 my $chip_id = shift; 205 200 my $whole_run = shift; # if true queue entire run for update … … 216 211 $raw_all_magicked &= ($chip->{raw_magicked} > 0); 217 212 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"; 219 215 faultJobs('stop', undef, undef, $PSTAMP_GONE); 216 return; 220 217 } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) { 221 218 my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id -class_id $chip->{class_id}"; … … 237 234 $dsRun_state = $run->{dsRun_state}; 238 235 $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 } 239 242 240 243 # providing no -class_id arguments changes all imfiles with data_state = 'cleaned' to 'update' … … 253 256 } 254 257 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); 256 259 257 260 return $status; 258 261 } 259 262 260 sub queue_update_warp {263 sub check_states_warp { 261 264 # check status of input chips. If state is not updatable set error code for job 262 265 263 # if chipProcessedImfile.state is cleaned call queue_update_chip266 # if chipProcessedImfile.state is cleaned call check_states_chip 264 267 265 268 # need to code warptool -setskyfiletoupdate … … 301 304 } 302 305 303 if ($chips_ready ) {306 if ($chips_ready and $skycell->{data_state} ne 'update') { 304 307 # the reason we defer setting the warp to update is so that we can handle error conditions at previous 305 308 # stages more easily. … … 317 320 } 318 321 } 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); 320 323 } 321 324 } else { … … 354 357 (($chipRun->{state} eq 'full') and ($need_magic and ($chipRun->{magicked} < 0) and ($chipRun->{dsRun_state} ne 'new')))) { 355 358 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); 357 360 } 358 361 } … … 361 364 return 0; 362 365 } 363 sub queue_update_diff {366 sub check_states_diff { 364 367 my $metadata = shift; 365 368 my $whole_run = shift; # if true queue entire run for update … … 392 395 393 396 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); 395 398 } 396 399 # warps are ready fall through and queue the diff update … … 404 407 if ($warp1->{data_state} ne 'full') { 405 408 $warps_ready = 0; 406 $status = queue_update_warp($warp1, 0, $rlabel, $need_magic);409 $status = check_states_warp($warp1, 0, $rlabel, $need_magic); 407 410 if ($status) { 408 411 return $status; … … 415 418 if ($warp2->{data_state} ne 'full') { 416 419 $warps_ready = 0; 417 $status = queue_update_warp($warp2, 0, $rlabel, $need_magic);420 $status = check_states_warp($warp2, 0, $rlabel, $need_magic); 418 421 } 419 422 … … 467 470 468 471 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); 470 473 } 471 474 # warps are ready fall through and queue the diff update … … 474 477 } 475 478 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 } 487 492 } 488 493 } else { … … 599 604 } 600 605 601 sub queue_update_magicDSRun {606 sub check_states_magicDSRun { 602 607 my $stage = shift; 603 608 my $stage_id = shift; … … 608 613 609 614 # 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. 613 618 if (!$dsRun_state) { 614 619 my $command = "$chiptool -listrun -chip_id $stage_id";
Note:
See TracChangeset
for help on using the changeset viewer.
