- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/lap_science.pl (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/ippScripts/scripts/lap_science.pl
r32099 r33415 27 27 my ( $camera, $dbname); 28 28 my ( $lap_id ); 29 my ( $queue_list ); 29 30 my ( $chip_mode, $monitor_mode, $cleanup_mode); 30 31 … … 32 33 # Global configuration constants that probably should be read from elsewhere. 33 34 my $qstack_threshold = 0.05; # Only make a quickstack if more than 5% of the exposures require it. 34 my $minimum_stack_inputs = 6; # We can avoid magicking stack inputs if we have more than this number.35 my $minimum_stack_inputs = 4; # We can avoid magicking stack inputs if we have more than this number. 35 36 36 37 GetOptions( … … 44 45 45 46 'lap_id=s' => \$lap_id, 47 'queue_list=s' => \$queue_list, 46 48 47 49 'chip_mode' => \$chip_mode, … … 200 202 return($exposure); 201 203 } 204 205 sub remake_this_exposure_by_update { 206 my $exposure = shift; 207 208 my @utctime = gmtime(); 209 $utctime[5] += 1900; 210 $utctime[4] += 1; 211 212 my $label = $exposure->{label}; 213 214 my $date = sprintf("%4d%02d%02d",$utctime[5],$utctime[4],$utctime[3]); 215 my $workdir_date = sprintf("%4d/%02d/%02d",$utctime[5],$utctime[4],$utctime[3]); 216 my $workdir = "neb://\@HOST\@.0/${dbname}/${label}/${workdir_date}"; 217 my $data_group = "${label}.${date}"; 218 219 my $chiptool_info_cmd = "chiptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 220 $chiptool_info_cmd .= " -dbname $dbname " if defined $dbname; 221 222 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 223 run(command => $chiptool_info_cmd, verbose => $verbose); 224 unless ($success) { 225 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 226 &my_die("Unable to perform chiptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 227 } 228 my $chips = $mdcParser->parse_list(join "", @$stdout_buf) or 229 &my_die("Unable to parse metadata from chiptool -listrun", $exposure->{exp_id}, $data_group); 230 # There should be only one. 231 my $chip = ${ $chips }[0]; 232 my $chip_magicDS_id = 0; 233 if ($chip) { 234 $chip_magicDS_id = $chip->{magic_ds_id}; 235 } 236 if ($chip_magicDS_id == 0) { 237 # return(&remake_this_exposure($exposure)); 238 } 239 240 my $warptool_info_cmd = "warptool -listrun -exp_id $exposure->{exp_id} -chip_id $exposure->{chip_id} "; 241 $warptool_info_cmd .= " -dbname $dbname " if defined $dbname; 242 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 243 run(command => $warptool_info_cmd, verbose => $verbose); 244 unless ($success) { 245 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 246 &my_die("Unable to perform warptool -listrun: $error_code", $exposure->{exp_id}, $data_group); 247 } 248 my $warps = $mdcParser->parse_list(join "", @$stdout_buf) or 249 &my_die("Unable to parse metadata from warptool -listrun", $exposure->{exp_id}, $data_group); 250 # There should be only one. 251 my $warp = ${ $warps }[0]; 252 my $warp_id = 0; 253 if ($warp) { 254 $warp_id = $warp->{warp_id}; 255 } 256 else { 257 $exposure->{data_state} = 'drop'; 258 return($exposure); 259 } 260 if ($warp_id == 0) { 261 # Handle this correctly. Probably want to drop the exposure here. 262 $exposure->{data_state} = 'drop'; 263 return($exposure); 264 } 265 266 if (($chip->{state} eq 'goto_cleaned')|| 267 ($warp->{state} eq 'goto_cleaned')|| 268 ($chip->{dsRun_state} eq 'goto_cleaned')) { 269 $exposure->{data_state} = 'pending_update'; 270 &update_this_exposure($exposure); 271 return($exposure); 272 } 273 274 275 my $chiptool_update_cmd = "chiptool -setimfiletoupdate -chip_id $exposure->{chip_id} -set_label $label"; 276 $chiptool_update_cmd .= " -dbname $dbname " if defined $dbname; 277 my $magicDS_update_cmd = "magicdstool -setfiletoupdate -magic_ds_id $chip_magicDS_id -set_label $label"; 278 $magicDS_update_cmd .= " -dbname $dbname " if defined $dbname; 279 my $warptool_update_cmd = "warptool -setskyfiletoupdate -warp_id $warp_id -set_label $label"; 280 $warptool_update_cmd .= " -dbname $dbname " if defined $dbname; 281 282 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 283 run(command => $chiptool_update_cmd, verbose => $verbose); 284 unless ($success) { 285 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 286 &my_die("Unable to perform chiptool -setimfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 287 } 288 # if ($chip_magicDS_id != 0) { 289 # ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 290 # run(command => $magicDS_update_cmd, verbose => $verbose); 291 # unless ($success) { 292 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 293 # &my_die("Unable to perform magicdstool -setfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 294 # } 295 # } 296 297 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 298 run(command => $warptool_update_cmd, verbose => $verbose); 299 unless ($success) { 300 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 301 &my_die("Unable to perform warptool -setskyfiletoupdate: $error_code", $exposure->{exp_id}, $data_group); 302 } 303 304 $exposure->{active} = 1; 305 return($exposure); 306 } 307 308 sub determine_if_can_update { 309 my $exposure = shift; 310 311 if (S64_IS_NOT_NULL($exposure->{chip_id})) { 312 if (($exposure->{chip_state} eq 'cleaned')|| 313 ($exposure->{chip_state} eq 'goto_cleaned')|| 314 ($exposure->{chip_state} eq 'error_cleaned')) { 315 return(1); 316 } 317 } 318 319 return(0); 320 } 321 202 322 203 323 # This is the "user level" subroutine. … … 240 360 my $comment = $exposure->{comment}; 241 361 242 # This is a hack to fix old exposures that have no object. 362 my $updateable = determine_if_can_update($exposure); 363 364 # This is a hack to fix old exposures that have no usable object/comment data. 243 365 unless(defined($comment)) { 244 366 $comment = ''; … … 247 369 if ($comment =~ /3pi_/) { 248 370 $object = $comment; 249 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/ $1/;371 $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/F1 $1/; 250 372 } 251 373 elsif ($comment =~ / ps1_/) { 252 374 $object = $comment; 253 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/$1/; 254 } 255 else { 256 $exposure->{data_state} = 'new'; 375 $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/F2 $1/; 376 } 377 elsif ($comment =~ /ThreePi.*3pi_/) { 378 $object = $comment; 379 $object =~ s/^ThreePi . (\S+? 3pi_\d\d_\d\d\d\d) .*$/F3 $1/; 380 } 381 elsif ($comment =~ /ThreePi.*ps1_/) { 382 $object = $comment; 383 $object =~ s/^ThreePi . (\S+? ps1_\d\d_\d\d\d\d) .*$/F4 $1/; 384 } 385 elsif ($comment =~ /ThreePi /) { 386 $object = $comment; 387 $object =~ s/^ThreePi . (\S+? \d\d\d\d) .*$/F5 $1/; 388 } 389 elsif (($comment =~ /focus/i)|| 390 ($comment =~ /test/i)|| 391 ($comment =~ /hyster/i)|| 392 ($comment =~ /dither/i)|| 393 ($comment =~ /camera/i) 394 ){ 395 # This is junk that shouldn't exist. 396 $object = 'DROP'; 397 $exposure->{data_state} = 'drop'; 257 398 $exposure->{pairwise} = 0; 258 $exposure->{private} = 1; 259 $exposure->{pair_id} = 9223372036854775807; 260 update_this_exposure($exposure); 261 $exposure = remake_this_exposure($exposure); 262 $counter++; 399 $exposure->{pair_id} = 9223372036854775807; 400 $exposure->{active} = 0; 401 &update_this_exposure($exposure); 402 $counter++; # To ensure everyone else is consistent 263 403 next; 264 404 } 265 405 } 266 406 407 # Determine the current state of chipRuns for these exposures, and update/remake as needed. 267 408 if (S64_IS_NOT_NULL($chip_id)) { # We already have a defined chip_id 268 409 if (($pairwise) && !($pair_id)) { … … 270 411 &my_die("Exposure $exp_id for $lap_id is declared pairwise without a defined pair", $lap_id); 271 412 } 413 $exposure->{data_state} = 'exists'; 414 if ($updateable) { # We know about this run, but the data needs to be regenerated. 415 $exposure->{data_state} = 'update'; 416 $exposure = remake_this_exposure_by_update($exposure); 417 } 418 &update_this_exposure($exposure); 272 419 $matching{$object}{$comment} = $exp_id; 273 420 $indexing{$exp_id} = $counter; 274 421 $counter++; 275 next;276 422 } 277 423 else { # We do not already have a chip_id. 278 424 # Make a chipRun, and update the exposure. 425 $exposure->{data_state} = 'run'; 279 426 $exposure = remake_this_exposure($exposure); 280 281 427 # Save our information for diff pairing. 428 &update_this_exposure($exposure); 282 429 $matching{$object}{$comment} = $exp_id; 283 430 $indexing{$exp_id} = $counter; 284 431 $counter++; 285 432 } 433 286 434 if ($verbose) { 287 435 print "ZZ: $exp_id $object $comment $matching{$object}{$comment}\n"; … … 296 444 print "$object $comment $matching{$object}{$comment} $indexing{$matching{$object}{$comment}} $exp_ids_to_diff[-1]\n"; 297 445 } 298 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; 446 @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff; # This is effectively a sort by dateobs. 299 447 300 448 if (( $#exp_ids_to_diff + 1) % 2 != 0) { # We have an odd number of exposures, even after comment filtering … … 309 457 my $exp_B = ${ $exposures }[$indexing{$exp_id_B}]; 310 458 print "$exp_A $exp_B $exp_id_A $exp_id_B $indexing{$exp_id_A} $indexing{$exp_id_B}\n"; 311 $exp_A->{pairwise} = 1; 312 $exp_A->{private} = 0; 313 $exp_A->{pair_id} = $exp_B->{chip_id}; 314 315 $exp_B->{pairwise} = 1; 316 $exp_B->{private} = 0; 317 $exp_B->{pair_id} = $exp_A->{chip_id}; 318 319 if ($verbose) { 320 print "LAP_DIFFS: $object: $exp_A->{exp_id} and $exp_B->{exp_id} are a pair\n"; 459 if ($exp_A->{diff_id} == $exp_B->{diff_id}) { 460 $exp_A->{pairwise} = 1; 461 $exp_A->{pair_id} = $exp_B->{chip_id}; 462 463 $exp_B->{pairwise} = 1; 464 $exp_B->{pair_id} = $exp_A->{chip_id}; 465 if ($verbose) { 466 print "LAP_DIFFS: $object: $exp_A->{exp_id} and $exp_B->{exp_id} are a pair\n"; 467 } 468 } 469 else { 470 $exp_A->{pairwise} = 0; 471 $exp_B->{pairwise} = 0; 321 472 } 322 473 } … … 331 482 $exposure->{pairwise} = 0; # We marked it for pairwise diffs, but didn't match it. Probably an error. 332 483 } 333 if (!($exposure->{pairwise})) { 334 $exposure->{private} = 1; # If this isn't being pairwise diffed, it needs to be private 335 } 336 484 337 485 update_this_exposure($exposure); 338 486 } … … 403 551 $complete_fstacks++; 404 552 } 553 elsif (($stack->{final_state})&& 554 ($stack->{final_state} eq 'drop')) { 555 $complete_fstacks++; 556 } 405 557 elsif (($stack->{final_state})&&($stack->{final_state} eq 'new')&& 406 558 ($stack->{final_fault} >= 4)&&($stack->{final_fault} != 32767)) { … … 457 609 # Things I want to know before I'm through 458 610 # my $needs_qstack = 0; 459 my $needs_something_remade = 0; 460 my $needs_something_private = 0; 611 my $needs_something_remade = 0; # I never need something remade, because we're committed to one-exp=one-chip 612 my $needs_something_private = 0; # I never need something private, as that is calculated by the difference engine. 461 613 # my $can_qstack = 0; 462 614 my $have_diff = 0; … … 468 620 my $are_warped = 0; 469 621 my $are_magicked = 0; 470 471 622 foreach my $exposure (@$exposures) { 472 623 $total_exposures++; … … 480 631 else { # We claimed to be pairwise, but do not have a valid pair_id. 481 632 $exposure->{pairwise} = 0; 482 $exposure->{private} = 1;483 633 &update_this_exposure($exposure); 484 634 } … … 487 637 if ($exposure->{data_state} eq 'drop') { # This exposure is impossible, so fudge the counts so we get through. 488 638 $are_warped++; 489 # $can_qstack ++;490 639 $can_diff ++; 491 640 $have_diff ++; 492 641 $are_magicked ++; 493 # $can_fstack ++; 642 next; 643 } 644 645 if ($exposure->{data_state} eq 'pending_update') { 646 $exposure->{data_state} = 'update'; 647 $exposure = &remake_this_exposure_by_update($exposure); 648 &update_this_exposure($exposure); 494 649 next; 495 650 } 496 651 497 652 if ($exposure->{private}) { # I've declared this exposure private to this lapRun. 498 # $needs_qstack++;499 653 push @lonely_exposures, $exposure; 500 # $lonely_exposures++;501 654 } 502 655 503 if ($exposure->{needs_remade}) { # This does the check that private = false for other lapRun504 $needs_something_remade = 1;505 $exposure = remake_this_exposure($exposure);506 }656 # if ($exposure->{needs_remade}) { # This does the check that private = false for other lapRun 657 # $needs_something_remade = 1; 658 # $exposure = remake_this_exposure($exposure); 659 # } 507 660 # Do quality checks here 508 661 my $is_bad_quality = 0; … … 536 689 ($exposure->{diffRun_state} eq 'full')) { 537 690 $are_warped++; 538 # $needs_qstack++;539 $needs_something_private = 1;540 691 if ($companion) { 541 $companion->{private} = 1;542 692 $companion->{pairwise} = 0; 543 693 &update_this_exposure($companion); 544 push @lonely_exposures, $companion; 545 # $lonely_exposures++; 694 # push @lonely_exposures, $companion; 546 695 } 547 $exposure->{private} = 1;548 696 $exposure->{pairwise} = 0; 549 697 } 550 698 $exposure->{data_state} = 'drop'; 551 699 &update_this_exposure($exposure); 700 next; 552 701 } 553 702 … … 558 707 # $can_qstack ++; 559 708 $can_diff ++; 560 } 561 if (($exposure->{magicked}&& 562 &S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 709 $exposure->{data_state} = 'to_diff'; 710 } 711 if (($exposure->{diff_id})&& 712 (&S64_IS_NOT_NULL($exposure->{diff_id}))&& 713 (($exposure->{diffRun_state} eq 'full')|| 714 ($exposure->{diffRun_state} eq 'error_cleaned')|| 715 ($exposure->{diffRun_state} eq 'cleaned')) 716 ) { 563 717 $are_magicked++; 564 # $can_fstack ++;565 }566 if (($exposure->{diff_id})&&(&S64_IS_NOT_NULL($exposure->{diff_id}))) {567 718 $have_diff ++; 719 # $exposure->{data_state} = 'to_magic'; 720 $exposure->{data_state} = 'full'; 721 } 722 # We no longer need to care about magic 723 # if (($exposure->{magicked})&& 724 # ($exposure->{warpRun_state})&& 725 # ($exposure->{warpRun_state} eq 'full')&& 726 # (&S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 727 # $are_magicked++; 728 # $exposure->{data_state} = 'full'; 729 # # $can_fstack ++; 730 # } 731 unless ($debug) { 732 &update_this_exposure($exposure); 568 733 } 569 734 } … … 575 740 print "STATUS: HAVE_FSTACK: $have_fstack\n"; 576 741 577 # print "STATUS: NEEDS_QSTACK: $needs_qstack\n";578 742 print "STATUS: NEEDS_REMADE: $needs_something_remade\n"; 579 743 print "STATUS: NEEDS PRIVATIZE: $needs_something_private\n"; 580 744 print "STATUS: ARE WARPED: $are_warped\n"; 581 745 print "STATUS: ARE MAGICKED: $are_magicked\n"; 582 # print "STATUS: CAN_QSTACK: $can_qstack\n";583 746 print "STATUS: CAN_DIFF: $can_diff\n"; 584 747 print "STATUS: HAVE_DIFF: $have_diff\n"; 585 # print "STATUS: CAN_FSTACK: $can_fstack\n";586 748 587 749 print "STATUS: TOTAL_EXPOSURES: $total_exposures\n"; … … 595 757 if ($defined_fstack == 0) { # We have not yet made any stacks. 596 758 print "STATUS: We can attempt to queue deep final stacks.\n"; 597 my $Nstacks_made = &queue_muggle_finalstack($exposures); 759 my $Nstacks_made; 760 unless ($debug) { 761 $Nstacks_made = &queue_muggle_finalstack($exposures); 762 } 598 763 print "STATUS: Made $Nstacks_made final stacks.\n"; 599 764 exit($Nstacks_made); … … 603 768 if ($have_fstack == $defined_fstack) { # We have made all the stacks we have asked for (so far) 604 769 if ($are_magicked < $total_exposures) { # But we have not yet made diffs 770 # if ($have_diff < $total_exposures) { # We have not yet made diffs 605 771 if (($can_diff == $total_exposures)&& # And we have exposures that should be diffed. 606 772 ($have_diff < $can_diff)) { # and we haven't made them all yet, either. 607 773 print "STATUS: Dropping unpaired exposures and making pairwise diffs.\n"; 608 foreach my $exposure (@lonely_exposures) { 609 $exposure->{data_state} = 'drop'; 610 &update_this_exposure($exposure); 774 # foreach my $exposure (@lonely_exposures) { 775 # $exposure->{data_state} = 'drop'; 776 # &update_this_exposure($exposure); 777 # } 778 unless ($debug) { 779 &queue_diffs($exposures); 611 780 } 612 &queue_diffs($exposures);613 781 exit(0); 614 782 } … … 621 789 } 622 790 elsif ($are_magicked == $total_exposures) { # We have made all of the diffs, and propagated through magic 623 print "STATUS: We can create all remaining stacks possible.\n"; 624 my $Nstacks_made = &queue_magic_finalstack($exposures); 625 if ($Nstacks_made == 0) { # We have made all the stacks that we will ever make. 791 print "STATUS: We would create all remaining stacks possible, but no longer require magic.\n"; 792 # my $Nstacks_made = -1; 793 # unless ($debug) { 794 # $Nstacks_made = &queue_muggle_finalstack($exposures); 795 # } 796 # if ($Nstacks_made == 0) { # We have made all the stacks that we will ever make. 626 797 print "STATUS: No more stacks generated. Deactivating exposures for this complete lapRun.\n"; 627 &deactivate_exposures($exposures); 628 $command = "$laptool -updaterun -lap_id $lap_id"; 629 $command .= " -dbname $dbname " if defined $dbname; 630 $command .= " -set_state full "; 631 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 632 run(command => $command, verbose => $verbose); 633 unless ($success) { 634 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 635 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 636 } 798 unless ($debug) { 799 &deactivate_exposures($exposures); 800 801 $command = "$laptool -updaterun -lap_id $lap_id"; 802 $command .= " -dbname $dbname " if defined $dbname; 803 $command .= " -set_state full "; 804 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 805 run(command => $command, verbose => $verbose); 806 unless ($success) { 807 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 808 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 809 } 810 # } 637 811 exit(0); 638 812 } 639 else {640 print "STATUS: $Nstacks_made stacks made.\n";641 exit(0);642 }813 # else { 814 # print "STATUS: $Nstacks_made stacks made.\n"; 815 # exit(0); 816 # } 643 817 } 644 818 else { # What? … … 842 1016 foreach $exposure (@$exposures) { 843 1017 if (($exposure->{data_state} ne 'drop')&& 844 (S64_IS_NOT_NULL($exposure->{magicked}))&&1018 # (S64_IS_NOT_NULL($exposure->{magicked}))&& 845 1019 (S64_IS_NOT_NULL($exposure->{warp_id}))) { 846 1020 $warps .= " -warp_id $exposure->{warp_id} "; … … 924 1098 next; 925 1099 } 926 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # Not sure how this would happen, but still. ##This happens when we inherit a complete exposure.1100 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # This happens when we inherit a complete exposure. 927 1101 next; 928 1102 } … … 964 1138 } 965 1139 else { # warp-qstack 966 next; # We no longer wish to make these, and should never get here. 967 $command .= '-pretend'; 968 # $command .= " -definewarpstack -set_reduction NOCONVDIFF -available -good_frac 0.2 "; 969 # $command .= " -warp_id $exposure->{warp_id} -stack_label ${label}.quick "; 970 # $already_queued{$exposure->{warp_id}} = 1; 1140 # We need to decide if we can make a warp-stack diff: 1141 if (&can_warp_stack_diff_be_made($exposure)) { 1142 # next; 1143 # $command .= '-pretend'; 1144 $command .= " -definewarpstack -available -good_frac 0.2 "; 1145 $command .= " -warp_id $exposure->{warp_id} -stack_label ${label} "; 1146 $already_queued{$exposure->{warp_id}} = 1; 1147 $exposure->{private} = 0; 1148 &update_this_exposure($exposure); 1149 } 1150 else { 1151 $exposure->{private} = 1; 1152 $exposure->{data_state} = 'drop'; 1153 $already_queued{$exposure->{warp_id}} = 1; 1154 &update_this_exposure($exposure); 1155 next; 1156 } 971 1157 } 972 1158 … … 1006 1192 } 1007 1193 1194 sub can_warp_stack_diff_be_made { 1195 my $exposure = shift; 1196 my $lap_id = $exposure->{lap_id}; 1197 my $warp_id = $exposure->{warp_id}; 1198 1199 my $command = "$laptool -diffcheck -lap_id $lap_id -warp_id $warp_id"; 1200 $command .= " -dbname $dbname " if defined $dbname; 1201 1202 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1203 run(command => $command, verbose => $verbose); 1204 unless ($success) { 1205 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1206 &my_die("Unable to perform laptool -diffcheck: $error_code", $lap_id, $warp_id); 1207 } 1208 if (@$stdout_buf == 0) { 1209 return(0); 1210 } 1211 my $skycells = $mdcParser->parse_list(join "", @$stdout_buf) or 1212 &my_die("Unable to parse metadata from laptool -diffcheck", $lap_id, $warp_id); 1213 foreach my $skycell (@$skycells) { 1214 unless (defined($skycell->{stack_state})) { 1215 return(0); 1216 } 1217 if ($skycell->{stack_state} ne 'full') { 1218 return(0); 1219 } 1220 if ($skycell->{warp_state} ne 'full') { 1221 return(0); 1222 } 1223 unless (S64_IS_NOT_NULL($skycell->{stack_id})) { 1224 return(0); 1225 } 1226 } 1227 return(1); 1228 } 1229 1230 1008 1231 # Deactivate all exposures in this run. 1009 1232 sub deactivate_exposures { 1010 1233 my $exposures = shift; 1011 1234 foreach my $exposure (@$exposures) { 1012 $exposure->{active} = 0; 1013 update_this_exposure($exposure); 1235 if ($exposure->{private} == 1) { # This can probably be relaxed since we can update an undestreaked warp. 1236 $exposure->{active} = 1; 1237 } 1238 else { 1239 $exposure->{active} = 0; 1240 } 1241 update_this_exposure($exposure); 1014 1242 } 1015 1243 } … … 1022 1250 sub cleanup_mode { 1023 1251 my $lap_id = shift; 1252 1253 if (defined($queue_list)) { 1254 my $successful = 1; 1255 open(Q,$queue_list) or ($successful = 0); 1256 if ($successful == 1) { 1257 while(<Q>) { 1258 chomp; 1259 my $cmd = $_; 1260 my ($projection_cell,$seq_id,$filter,$label); 1261 $projection_cell = $cmd; 1262 $projection_cell =~ s/.*?-projection_cell (skycell.\w+?) .*/$1/; 1263 $seq_id = $cmd; 1264 $seq_id =~ s/.*-seq_id (\d+?) .*/$1/; 1265 $filter = $cmd; 1266 $filter =~ s/.*-filter (\w\.00000) .*/$1/; 1267 if ($filter =~ /\s+?/) { 1268 $filter =~ s/.*-filter (\w\.00000)$/$1/; 1269 } 1270 $label = $cmd; 1271 $label =~ s/.*-label (.+?) .*/$1/; 1272 1273 my $response; 1274 chomp($response = 1275 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1276 my $state = (split /\s+/, $response)[5]; 1277 1278 unless (defined($state)) { 1279 if ($verbose) { 1280 print "Queuing: $cmd\n"; 1281 } 1282 system($cmd); 1283 1284 my $i = 0; 1285 do { 1286 sleep(5); 1287 chomp($response = 1288 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1289 $state = (split /\s+/, $response)[5]; 1290 $i++; 1291 unless(defined($state)) { 1292 $successful = 0; 1293 } 1294 } while (($state ne 'run')&&($i < 20)&&($successful)); 1295 last; 1296 } 1297 } 1298 close(Q); 1299 } 1300 } 1301 1024 1302 my $command = "$laptool -inactiveexp -lap_id $lap_id "; 1025 1303 $command .= " -dbname $dbname " if defined $dbname; … … 1033 1311 if (@$stdout_buf == 0) { 1034 1312 # Nothing to do. 1313 $command = "$laptool -updaterun -lap_id $lap_id"; 1314 $command .= " -dbname $dbname " if defined $dbname; 1315 $command .= " -set_state done "; 1316 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1317 run(command => $command, verbose => $verbose); 1318 unless ($success) { 1319 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1320 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 1321 } 1322 1035 1323 return(0); 1036 1324 } … … 1043 1331 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@', 1044 1332 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@', 1333 'magictool -dbname @DBNAME@ -updaterun -set_state full -set_label @LABEL@.old -magic_id @MAGIC_ID@', 1045 1334 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@', 1046 1335 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@', 1047 1336 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage diff -stage_id @DIFF_ID@'); 1337 1048 1338 foreach my $exposure (@$exposures) { 1049 1339 if ($exposure->{is_in_use}) { … … 1077 1367 } 1078 1368 } 1369 if ($command =~ /\@MAGIC_ID\@/) { 1370 if ((S64_IS_NOT_NULL($exposure->{magicked}))&& 1371 ($exposure->{magicked} > 0)) { 1372 $command =~ s/\@MAGIC_ID\@/$exposure->{magicked}/; 1373 } 1374 else { 1375 next; 1376 } 1377 } 1079 1378 $command =~ s/\@LABEL\@/$exposure->{label}/; 1080 1379 … … 1139 1438 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 1140 1439 } 1141 1440 return(0); 1142 1441 } 1143 1442 … … 1210 1509 $command .= " -set_data_state $exposure->{data_state} "; 1211 1510 } 1212 1213 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1214 run(command => $command, verbose => $verbose); 1215 unless ($success) { 1216 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1217 &my_die("Unable to perform laptool -updateexp: $error_code", $exposure->{lap_id}, $exposure->{proj_cell}); 1511 unless ($do_nothing) { 1512 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1513 run(command => $command, verbose => $verbose); 1514 1515 unless ($success) { 1516 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1517 &my_die("Unable to perform laptool -updateexp: $error_code", $exposure->{lap_id}, $exposure->{proj_cell}); 1518 } 1218 1519 } 1219 1520 }
Note:
See TracChangeset
for help on using the changeset viewer.
