Changeset 37784 for trunk/pstamp/scripts/pstamp_checkdependent.pl
- Timestamp:
- Jan 5, 2015, 2:10:23 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_checkdependent.pl (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_checkdependent.pl
r37772 r37784 24 24 my $ra_max_3PI_hours = 22.5; # disable updates for skycells with ra greater than this (hours) 25 25 my $ra_max_3PI = $ra_max_3PI_hours * 15 * 3.14149 / 180.; # rawExp.ra is in radians 26 27 # verbose flag for parse commands 28 my $parse_verbose = 0; 26 29 27 30 # XXX: put this in a module somewhere … … 49 52 'dbserver=s' => \$ps_dbserver, # postage stamp server dbserver 50 53 'verbose' => \$verbose, 54 'parse-verbose' => \$parse_verbose, 51 55 'save-temps' => \$save_temps, 52 56 'no-update' => \$no_update, … … 78 82 } 79 83 84 print "\n==== Starting dependency checking for $dep_id $stage $stage_id $component at " . (scalar localtime) . ". ====\n"; 85 80 86 if ($label) { 81 87 # rlabel is deprecated. Use one based on the supplied label parameter which is the current label … … 84 90 # (and formerly in pstampparse.pl) is not particularly clean but it's simple. 85 91 my $new_rlabel = 'ps_ud_' . $label; 92 $rlabel = "undefined" if !defined $rlabel; 86 93 if ($new_rlabel ne $rlabel) { 87 94 print "Notice: using $new_rlabel instead of $rlabel for update label.\n"; … … 120 127 } 121 128 122 my $it = runToolAndParseExpectOne($cmd, $ verbose);129 my $it = runToolAndParseExpectOne($cmd, $parse_verbose); 123 130 124 131 my_die("no components found", $PS_EXIT_PROG_ERROR) if ( !$it); … … 136 143 } 137 144 145 138 146 # magic is no longer rquired 139 147 $need_magic = 0; … … 142 150 if ((($it->{state} eq 'full') or ($it->{state} eq 'update')) and ($it->{data_state} eq 'full')) { 143 151 152 print "\nDependency Satisfied for $stage $stage_id $component\n"; 144 153 # This Dependency is satisfied. All done. Release the pstampJobs 145 154 # … … 178 187 } 179 188 180 # assume the fault is transient.189 # hope the fault is transient. 181 190 # fault the dependent to give the fault a chance to correct itself 182 191 my_die("Component faulted on update dep_id: $dep_id", $PS_EXIT_SYS_ERROR); … … 279 288 ($fault eq $PSTAMP_GONE)) { 280 289 281 print "chipRun state is $chip->{chip_id} has state: $state data_state: $data_state fault: $fault cannot update\n";290 print "chipRun state is $chip->{chip_id} has state: $state class_id $chip->{class_id} data_state: $data_state fault: $fault cannot update.\n"; 282 291 my $error_code; 283 292 if (($state eq 'error_cleaned') or ($data_state ='error_cleaned')) { … … 291 300 } elsif ($chip->{state} eq 'goto_cleaned') { 292 301 293 # we don't need to check for full data_state294 # if ($chip->{data_state} eq 'full') {295 302 { 303 print "dependent chip is in state goto_cleaned, changing state to update.\n"; 304 296 305 # cleanup must not be running. Set state to update. If this chip is not 'full' it will be 297 306 # set to be updated the next time this script is invoked 298 # XXX: In the very rarecase that this chip run is actually in the running cleanup pantasks307 # XXX: In the very unlikely case that this chip run is actually in the running cleanup pantasks 299 308 # queue things may get confused but we can live with that 300 309 my $command = "$chiptool -updaterun -set_state update -chip_id $chip_id"; … … 313 322 } 314 323 } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) { 324 325 print "Setting chip imfile $chip_id $chip->{class_id} to be updated.\n"; 315 326 316 327 # chiptool does more state checking to insure this isn't done prematurely. … … 343 354 # we've had a number of runs in this limbo state 344 355 356 print "Changing chip run $chip_id to state update for $chip->{class_id} which is in data_state update.\n"; 345 357 my $command = "$chiptool -updaterun -set_state update -chip_id $chip_id"; 346 358 $command .= " -set_label $rlabel" if $rlabel; … … 364 376 return $PSTAMP_GONE; 365 377 } elsif ($fault_count > $max_fault_count) { 366 print " $stage $stage_id has faulted $fault_count times. Giving up\n";378 print "Dependency for $stage $stage_id has been found in fault state $fault_count times. Giving up. Fault: $fault\n"; 367 379 # XXX: stop faulting chips for now 368 380 # $fault = $PSTAMP_GONE; … … 421 433 if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or 422 434 ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/) or ($data_state eq 'drop')) { 423 print STDERR "warpRun $warp_id $skycell_id has state $state $data_state faulting jobs \n";435 print STDERR "warpRun $warp_id $skycell_id has state $state $data_state faulting jobs.\n"; 424 436 my $error_code; 425 437 if (($state eq 'error_cleaned') or ($data_state eq 'error_cleaned')) { … … 430 442 return $error_code 431 443 } 432 if (( $data_state eq 'full') and ($metadata->{fault})) {444 if ((($data_state eq 'full') or ($data_state eq 'update')) and ($metadata->{fault})) { 433 445 # fault dependent. 434 446 my $fault = $metadata->{fault}; 435 print STDERR "warp $warp_id $skycell_id faulted: $fault"; 447 print STDERR "warp $warp_id $skycell_id faulted with code: $fault."; 448 # XXX: TODO maybe: If ($fault != 2 and $fault != $PSTAMP_GONE) revert the skycell. The warp task only reverts fault 2 449 # and sometimes warps will fault due to nfs problems that end up with fault = 4;. 436 450 return $fault; 437 451 } 438 452 if ($metadata->{quality} ne 0) { 439 print STDERR "warp $warp_id $skycell_id bad quality on update: $metadata->{quality} \n";453 print STDERR "warp $warp_id $skycell_id bad quality on update: $metadata->{quality}.\n"; 440 454 return $PSTAMP_GONE; 441 455 } … … 448 462 # It's "safe" to set the state to update. If the skycell is not full it will be set to update 449 463 # the next time this task runs 464 print "Change state of warp $warp_id to update.\n"; 450 465 my $command = "$warptool -updaterun -set_state update -warp_id $warp_id"; 451 466 $command .= " -set_label $rlabel" if $rlabel; … … 465 480 # get the list of input chips for this skycell 466 481 my $command = "$warptool -scmap -warp_id $warp_id -skycell_id $skycell_id"; 467 my $data = runToolAndParse($command, $ verbose);482 my $data = runToolAndParse($command, $parse_verbose); 468 483 if (!$data or scalar @$data == 0) { 469 484 # This happens if the chipProcessedImfile disappears which happened when earlier 470 485 # versions of chiptool -revertprocessedimfile didn't check the chipRun.state before 471 486 # deleting the row. 472 print STDERR "failed to find warpSkyCell lMap for warpRun $warp_id skycell_id $skycell_id";487 print STDERR "failed to find warpSkyCellMap for warpRun $warp_id skycell_id $skycell_id"; 473 488 return $PSTAMP_GONE; 474 489 } … … 478 493 my $chip_id; 479 494 foreach my $chip (@$data) { 495 # XXX: change tools to include cam_state (camRun.state). If it is not full the warp updates will never run. 480 496 my $cam_fault = $chip->{cam_fault}; 481 497 if (defined $cam_fault and $cam_fault > 0) { … … 488 504 $chip->{decl} = $metadata->{decl}; 489 505 506 if (0) { 490 507 # if chip has been magicked before require it to be magicked again 491 508 # because the warp pending query requires it. 492 if (0) {493 509 if ($chip->{magicked} < 0) { 494 510 print "Input has been destreaked so we must destreak before warping\n"; … … 514 530 # the reason we defer setting the warp to update is so that we can handle error conditions at previous 515 531 # stages more easily. 532 print "Chips are ready for warp $warp_id $skycell->{skycell_id}. Setting skycell to be updated.\n"; 516 533 my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}"; 517 534 $command .= " -set_label $rlabel" if $rlabel; … … 527 544 } 528 545 } elsif ($chips_ready and $skycell->{data_state} eq 'update' and $skycell->{state} ne 'update') { 546 print "Chips are ready for warp $warp_id $skycell->{skycell_id} but run state is $skycell->{state}. Changing state to update.\n"; 529 547 my $command = "$warptool -updaterun -warp_id $warp_id -set_state update"; 530 548 $command .= " -set_label $rlabel" if $rlabel; … … 566 584 my $skycell_id = $skycell->{skycell_id}; 567 585 568 # if ($metadata->{state} eq 'goto_cleaned' and $metadata->{data_state} eq 'full') {569 586 if ($metadata->{state} eq 'goto_cleaned') { 570 587 # cleanup must not be running. Set state to update. If the skycell is not 'full' it will be 571 # set to be updated the next time this script is invoked 572 print " changing state of diffRun $diff_id from goto_cleaned to update. skycell $skycell_id is full\n";588 # set to be updated the next time this script is invoked. 589 print "Changing state of diffRun $diff_id from goto_cleaned to update.\n"; 573 590 my $command = "$difftool -updaterun -set_state update -diff_id $diff_id"; 574 591 $command .= " -set_label $rlabel" if $rlabel; … … 589 606 # check the state of the template stack 590 607 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}"; 591 my $stack = runToolAndParseExpectOne($command, $ verbose);608 my $stack = runToolAndParseExpectOne($command, $parse_verbose); 592 609 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack; 593 610 … … 597 614 return $PSTAMP_GONE; 598 615 } 616 print " Stack $skycell->{stack2} is ready.\n"; 599 617 600 618 # now check the warp 601 619 $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id"; 602 my $warp = runToolAndParseExpectOne($command, $ verbose);620 my $warp = runToolAndParseExpectOne($command, $parse_verbose); 603 621 my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp; 604 622 … … 615 633 } 616 634 # warps are ready fall through and queue the diff update 635 print " Warp $skycell->{warp1} $skycell_id is ready.\n"; 617 636 } elsif ($diff_mode eq $IPP_DIFF_MODE_WARP_WARP) { 618 637 my $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id"; 619 my $warp1 = runToolAndParseExpectOne($command, $ verbose);638 my $warp1 = runToolAndParseExpectOne($command, $parse_verbose); 620 639 my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp1; 621 640 … … 637 656 } 638 657 $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id"; 639 my $warp2 = runToolAndParseExpectOne($command, $ verbose);658 my $warp2 = runToolAndParseExpectOne($command, $parse_verbose); 640 659 my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp2; 641 660 … … 661 680 # check the state of the input stack 662 681 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}"; 663 my $stack1 = runToolAndParseExpectOne($command, $ verbose);682 my $stack1 = runToolAndParseExpectOne($command, $parse_verbose); 664 683 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1; 665 684 … … 671 690 # check the state of the template stack 672 691 $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}"; 673 my $stack2 = runToolAndParseExpectOne($command, $ verbose);692 my $stack2 = runToolAndParseExpectOne($command, $parse_verbose); 674 693 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack2; 675 694 … … 684 703 # check the state of the input stack 685 704 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}"; 686 my $stack = runToolAndParseExpectOne($command, $ verbose);705 my $stack = runToolAndParseExpectOne($command, $parse_verbose); 687 706 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack; 688 707 … … 695 714 # now check the template warp 696 715 $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id"; 697 my $warp = runToolAndParseExpectOne($command, $ verbose);716 my $warp = runToolAndParseExpectOne($command, $parse_verbose); 698 717 my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp; 699 718 … … 736 755 print "skipping $command\n"; 737 756 } 757 } else { 758 print " diff is in update state\n"; 738 759 } 739 760 … … 763 784 my $now = DateTime->now->mjd; 764 785 my $dtime_tool = (DateTime->now->mjd - $start_tool) * 86400.; 765 print "Time to run $program: $dtime_tool\n"; 786 if ($dtime_tool > 0.1) { 787 print "Time to run $program: $dtime_tool\n"; 788 } 766 789 767 790 my $buf = join "", @$stdout_buf; … … 777 800 778 801 my $dtime_parse = (DateTime->now->mjd - $start_parse) * 86400.; 779 print "Time to parse results from $program: $dtime_parse\n"; 802 if ($dtime_parse > 0.1) { 803 print "Time to parse results from $program: $dtime_parse\n"; 804 } 780 805 781 806 return $results; … … 848 873 if (!$dsRun_state) { 849 874 my $command = "$chiptool -listrun -chip_id $stage_id"; 850 my $data = runToolAndParse($command, $ verbose);875 my $data = runToolAndParse($command, $parse_verbose); 851 876 my $chipRun = $data->[0]; 852 877 $dsRun_state = $chipRun->{dsRun_state}; … … 862 887 foreach my $c (@$components) { 863 888 my $command = "$magicdstool -destreakedfile -magic_ds_id $magic_ds_id -component $c"; 864 my $dsfile = runToolAndParseExpectOne($command, $ verbose);889 my $dsfile = runToolAndParseExpectOne($command, $parse_verbose); 865 890 if (!$dsfile) { 866 891 my_die("failed to find magicDSFile for ${stage}Run $stage_id $c", $PS_EXIT_UNKNOWN_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.
