- Timestamp:
- Jan 11, 2012, 11:19:21 PM (15 years ago)
- Location:
- branches/meh_branches/ppsub_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/lap_science.pl (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppsub_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppsub_test/ippScripts/scripts/lap_science.pl
r32099 r33098 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 'cleaned')) 715 ) { 563 716 $are_magicked++; 564 # $can_fstack ++;565 }566 if (($exposure->{diff_id})&&(&S64_IS_NOT_NULL($exposure->{diff_id}))) {567 717 $have_diff ++; 718 # $exposure->{data_state} = 'to_magic'; 719 $exposure->{data_state} = 'full'; 720 } 721 # We no longer need to care about magic 722 # if (($exposure->{magicked})&& 723 # ($exposure->{warpRun_state})&& 724 # ($exposure->{warpRun_state} eq 'full')&& 725 # (&S64_IS_NOT_NULL($exposure->{magicked}))) { # This exposure has been magicked, so it is through with diff. 726 # $are_magicked++; 727 # $exposure->{data_state} = 'full'; 728 # # $can_fstack ++; 729 # } 730 unless ($debug) { 731 &update_this_exposure($exposure); 568 732 } 569 733 } … … 575 739 print "STATUS: HAVE_FSTACK: $have_fstack\n"; 576 740 577 # print "STATUS: NEEDS_QSTACK: $needs_qstack\n";578 741 print "STATUS: NEEDS_REMADE: $needs_something_remade\n"; 579 742 print "STATUS: NEEDS PRIVATIZE: $needs_something_private\n"; 580 743 print "STATUS: ARE WARPED: $are_warped\n"; 581 744 print "STATUS: ARE MAGICKED: $are_magicked\n"; 582 # print "STATUS: CAN_QSTACK: $can_qstack\n";583 745 print "STATUS: CAN_DIFF: $can_diff\n"; 584 746 print "STATUS: HAVE_DIFF: $have_diff\n"; 585 # print "STATUS: CAN_FSTACK: $can_fstack\n";586 747 587 748 print "STATUS: TOTAL_EXPOSURES: $total_exposures\n"; … … 595 756 if ($defined_fstack == 0) { # We have not yet made any stacks. 596 757 print "STATUS: We can attempt to queue deep final stacks.\n"; 597 my $Nstacks_made = &queue_muggle_finalstack($exposures); 758 my $Nstacks_made; 759 unless ($debug) { 760 $Nstacks_made = &queue_muggle_finalstack($exposures); 761 } 598 762 print "STATUS: Made $Nstacks_made final stacks.\n"; 599 763 exit($Nstacks_made); … … 603 767 if ($have_fstack == $defined_fstack) { # We have made all the stacks we have asked for (so far) 604 768 if ($are_magicked < $total_exposures) { # But we have not yet made diffs 769 # if ($have_diff < $total_exposures) { # We have not yet made diffs 605 770 if (($can_diff == $total_exposures)&& # And we have exposures that should be diffed. 606 771 ($have_diff < $can_diff)) { # and we haven't made them all yet, either. 607 772 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); 773 # foreach my $exposure (@lonely_exposures) { 774 # $exposure->{data_state} = 'drop'; 775 # &update_this_exposure($exposure); 776 # } 777 unless ($debug) { 778 &queue_diffs($exposures); 611 779 } 612 &queue_diffs($exposures);613 780 exit(0); 614 781 } … … 621 788 } 622 789 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. 790 print "STATUS: We would create all remaining stacks possible, but no longer require magic.\n"; 791 # my $Nstacks_made = -1; 792 # unless ($debug) { 793 # $Nstacks_made = &queue_muggle_finalstack($exposures); 794 # } 795 # if ($Nstacks_made == 0) { # We have made all the stacks that we will ever make. 626 796 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 } 797 unless ($debug) { 798 &deactivate_exposures($exposures); 799 800 $command = "$laptool -updaterun -lap_id $lap_id"; 801 $command .= " -dbname $dbname " if defined $dbname; 802 $command .= " -set_state full "; 803 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 804 run(command => $command, verbose => $verbose); 805 unless ($success) { 806 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 807 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 808 } 809 # } 637 810 exit(0); 638 811 } 639 else {640 print "STATUS: $Nstacks_made stacks made.\n";641 exit(0);642 }812 # else { 813 # print "STATUS: $Nstacks_made stacks made.\n"; 814 # exit(0); 815 # } 643 816 } 644 817 else { # What? … … 842 1015 foreach $exposure (@$exposures) { 843 1016 if (($exposure->{data_state} ne 'drop')&& 844 (S64_IS_NOT_NULL($exposure->{magicked}))&&1017 # (S64_IS_NOT_NULL($exposure->{magicked}))&& 845 1018 (S64_IS_NOT_NULL($exposure->{warp_id}))) { 846 1019 $warps .= " -warp_id $exposure->{warp_id} "; … … 924 1097 next; 925 1098 } 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.1099 if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # This happens when we inherit a complete exposure. 927 1100 next; 928 1101 } … … 964 1137 } 965 1138 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; 1139 # We need to decide if we can make a warp-stack diff: 1140 if (&can_warp_stack_diff_be_made($exposure)) { 1141 # next; 1142 # $command .= '-pretend'; 1143 $command .= " -definewarpstack -available -good_frac 0.2 "; 1144 $command .= " -warp_id $exposure->{warp_id} -stack_label ${label} "; 1145 $already_queued{$exposure->{warp_id}} = 1; 1146 $exposure->{private} = 0; 1147 &update_this_exposure($exposure); 1148 } 1149 else { 1150 $exposure->{private} = 1; 1151 $exposure->{data_state} = 'drop'; 1152 $already_queued{$exposure->{warp_id}} = 1; 1153 &update_this_exposure($exposure); 1154 next; 1155 } 971 1156 } 972 1157 … … 1006 1191 } 1007 1192 1193 sub can_warp_stack_diff_be_made { 1194 my $exposure = shift; 1195 my $lap_id = $exposure->{lap_id}; 1196 my $warp_id = $exposure->{warp_id}; 1197 1198 my $command = "$laptool -diffcheck -lap_id $lap_id -warp_id $warp_id"; 1199 $command .= " -dbname $dbname " if defined $dbname; 1200 1201 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1202 run(command => $command, verbose => $verbose); 1203 unless ($success) { 1204 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1205 &my_die("Unable to perform laptool -diffcheck: $error_code", $lap_id, $warp_id); 1206 } 1207 if (@$stdout_buf == 0) { 1208 return(0); 1209 } 1210 my $skycells = $mdcParser->parse_list(join "", @$stdout_buf) or 1211 &my_die("Unable to parse metadata from laptool -diffcheck", $lap_id, $warp_id); 1212 foreach my $skycell (@$skycells) { 1213 unless (defined($skycell->{stack_state})) { 1214 return(0); 1215 } 1216 if ($skycell->{stack_state} ne 'full') { 1217 return(0); 1218 } 1219 if ($skycell->{warp_state} ne 'full') { 1220 return(0); 1221 } 1222 unless (S64_IS_NOT_NULL($skycell->{stack_id})) { 1223 return(0); 1224 } 1225 } 1226 return(1); 1227 } 1228 1229 1008 1230 # Deactivate all exposures in this run. 1009 1231 sub deactivate_exposures { 1010 1232 my $exposures = shift; 1011 1233 foreach my $exposure (@$exposures) { 1012 $exposure->{active} = 0; 1013 update_this_exposure($exposure); 1234 if ($exposure->{private} == 1) { # This can probably be relaxed since we can update an undestreaked warp. 1235 $exposure->{active} = 1; 1236 } 1237 else { 1238 $exposure->{active} = 0; 1239 } 1240 update_this_exposure($exposure); 1014 1241 } 1015 1242 } … … 1022 1249 sub cleanup_mode { 1023 1250 my $lap_id = shift; 1251 1252 if (defined($queue_list)) { 1253 my $successful = 1; 1254 open(Q,$queue_list) or ($successful = 0); 1255 if ($successful == 1) { 1256 while(<Q>) { 1257 chomp; 1258 my $cmd = $_; 1259 my ($projection_cell,$seq_id,$filter,$label); 1260 $projection_cell = $cmd; 1261 $projection_cell =~ s/.*?-projection_cell (skycell.\w+?) .*/$1/; 1262 $seq_id = $cmd; 1263 $seq_id =~ s/.*-seq_id (\d+?) .*/$1/; 1264 $filter = $cmd; 1265 $filter =~ s/.*-filter (\w\.00000) .*/$1/; 1266 if ($filter =~ /\s+?/) { 1267 $filter =~ s/.*-filter (\w\.00000)$/$1/; 1268 } 1269 $label = $cmd; 1270 $label =~ s/.*-label (.+?) .*/$1/; 1271 1272 my $response; 1273 chomp($response = 1274 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1275 my $state = (split /\s+/, $response)[5]; 1276 1277 unless (defined($state)) { 1278 if ($verbose) { 1279 print "Queuing: $cmd\n"; 1280 } 1281 system($cmd); 1282 1283 my $i = 0; 1284 do { 1285 sleep(5); 1286 chomp($response = 1287 `laptool -dbname gpc1 -listrun -projection_cell $projection_cell -seq_id $seq_id -filter $filter -label $label -simple`); 1288 $state = (split /\s+/, $response)[5]; 1289 $i++; 1290 unless(defined($state)) { 1291 $successful = 0; 1292 } 1293 } while (($state ne 'run')&&($i < 20)&&($successful)); 1294 last; 1295 } 1296 } 1297 close(Q); 1298 } 1299 } 1300 1024 1301 my $command = "$laptool -inactiveexp -lap_id $lap_id "; 1025 1302 $command .= " -dbname $dbname " if defined $dbname; … … 1043 1320 'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@', 1044 1321 'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@', 1322 'magictool -dbname @DBNAME@ -updaterun -set_state full -set_label @LABEL@.old -magic_id @MAGIC_ID@', 1045 1323 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage chip -stage_id @CHIP_ID@', 1046 1324 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage warp -stage_id @WARP_ID@', 1047 1325 'magicdstool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -stage diff -stage_id @DIFF_ID@'); 1326 1048 1327 foreach my $exposure (@$exposures) { 1049 1328 if ($exposure->{is_in_use}) { … … 1077 1356 } 1078 1357 } 1358 if ($command =~ /\@MAGIC_ID\@/) { 1359 if ((S64_IS_NOT_NULL($exposure->{magicked}))&& 1360 ($exposure->{magicked} > 0)) { 1361 $command =~ s/\@MAGIC_ID\@/$exposure->{magicked}/; 1362 } 1363 else { 1364 next; 1365 } 1366 } 1079 1367 $command =~ s/\@LABEL\@/$exposure->{label}/; 1080 1368 … … 1139 1427 &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id); 1140 1428 } 1141 1429 return(0); 1142 1430 } 1143 1431 … … 1210 1498 $command .= " -set_data_state $exposure->{data_state} "; 1211 1499 } 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}); 1500 unless ($do_nothing) { 1501 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1502 run(command => $command, verbose => $verbose); 1503 1504 unless ($success) { 1505 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1506 &my_die("Unable to perform laptool -updateexp: $error_code", $exposure->{lap_id}, $exposure->{proj_cell}); 1507 } 1218 1508 } 1219 1509 }
Note:
See TracChangeset
for help on using the changeset viewer.
