Changeset 28003 for branches/pap/ippScripts/scripts/automate_stacks.pl
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/automate_stacks.pl (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippScripts/scripts/automate_stacks.pl
r27631 r28003 56 56 # Grab options 57 57 my ( $date, $camera, $dbname, $logfile, $verbose, $manual); 58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only );58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode); 59 59 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); 60 60 my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old); … … 67 67 'logfile=s' => \$logfile, 68 68 'verbose' => \$verbose, 69 'debug' => \$debug, 69 70 'isburning' => \$isburning, 70 71 'force_stack_count' => \$force_stack_count, 72 'check' => \$check_mode, 71 73 'test_mode' => \$test_mode, 72 74 'this_target_only=s' => \$this_target_only, … … 115 117 defined $queue_chips or defined $queue_stacks or 116 118 defined $check_chips or defined $check_stacks or 117 defined $test_mode or defined $clean_old ;119 defined $test_mode or defined $clean_old or defined $check_mode; 118 120 119 121 # Configurable parameters from our config file. … … 126 128 my %stackable_list = (); 127 129 my %reduction_class = (); 128 my $retention_time = 9000; 129 130 my %clean_commands = (); 131 my %clean_retention = (); 132 my %noclean_list = (); 130 133 # Grab the configuration data. 131 134 my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -"; … … 140 143 my $metadata = $mdcParser->parse(join "", @$stdout_buf); 141 144 foreach my $entry (@{ $metadata }) { 142 if (${ $entry }{name} eq 'RETENTION_TIME') { 143 $retention_time = ${ $entry }{value}; 144 } 145 if (@{ $entry }{name} eq 'CLEAN_MODES') { 146 my @mode_data = @{ ${ $entry }{value} }; 147 my $this_mode = ''; 148 foreach my $mentry (@mode_data) { 149 if (${ $mentry }{name} eq 'MODE') { 150 $this_mode = ${ $mentry }{value}; 151 } 152 elsif (${ $mentry }{name} eq 'COMMAND') { 153 $clean_commands{$this_mode} = ${ $mentry }{value}; 154 } 155 elsif (${ $mentry }{name} eq 'RETENTION_TIME') { 156 $clean_retention{$this_mode} = ${ $mentry }{value}; 157 } 158 } 159 } 160 # if (${ $entry }{name} eq 'RETENTION_TIME') { 161 # $retention_time = ${ $entry }{value}; 162 # } 145 163 elsif (${ $entry }{name} eq 'FILTERS') { 146 164 push @filter_list, ${ $entry }{value}; … … 172 190 $reduction_class{$this_target} = ${ $tentry }{value}; 173 191 } 192 elsif (${ $tentry }{name} eq 'NOCLEAN') { 193 $noclean_list{$this_target} = ${ $tentry }{value}; 194 } 174 195 } 175 196 } … … 217 238 if (defined($test_mode)) { 218 239 $debug = 1; 219 } 220 221 if (defined($check_registration) || defined($test_mode)) { 240 my $z; 241 foreach $z (@target_list) { 242 print "TARGET: $z $tessID_list{$z} $obsmode_list{$z} $object_list{$z} $comment_list{$z} $stackable_list{$z} $reduction_class{$z}\n"; 243 } 244 foreach $z (@filter_list) { 245 print "FILTER: $z\n"; 246 } 247 foreach $z (keys (%clean_commands)) { 248 print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n"; 249 } 250 251 } 252 253 if (defined($check_registration) || defined($test_mode) || defined($check_mode)) { 222 254 $metadata_out{nsState} = 'NEW'; 223 255 my ($Nsummit_exp,$Nfaults) = check_summit_copy($date); 224 256 return_metadata($date); 225 unless (defined($test_mode) ) { exit(0); }257 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 226 258 } 227 259 if (defined($define_burntool) || defined($test_mode)) { … … 236 268 unless (defined($test_mode)) { exit(0); } 237 269 } 238 if (defined($check_chips) || defined($test_mode) ) {270 if (defined($check_chips) || defined($test_mode) || defined($check_mode)) { 239 271 $metadata_out{nsState} = 'QUEUECHIPS'; 240 272 &execute_chips($date,"pretend"); … … 243 275 } 244 276 return_metadata($date); 245 unless (defined($test_mode) ) { exit(0); }277 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 246 278 } 247 279 if (defined($queue_chips)) { … … 251 283 exit(0); 252 284 } 253 if (defined($check_stacks) || defined($test_mode) ) {285 if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) { 254 286 $metadata_out{nsState} = 'TOWARP'; 255 287 &execute_stacks($date,"pretend"); … … 258 290 } 259 291 return_metadata($date); 260 unless (defined($test_mode) ) { exit(0); }292 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 261 293 } 262 294 if (defined($queue_stacks)) { 263 295 $metadata_out{nsState} = 'STACKING'; 264 296 &execute_stacks($date); 297 if ($metadata_out{nsState} eq 'QUEUESTACKING') { 298 $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR'; 299 } 265 300 return_metadata($date); 266 301 exit(0); … … 420 455 } 421 456 422 if ($#{ $stderr_buf } > -1) {423 $metadata_out{nsState} = 'ERROR';424 return(1);425 }457 # if ($#{ $stderr_buf } > -1) { 458 # $metadata_out{nsState} = 'ERROR'; 459 # return(1); 460 # } 426 461 427 462 my $N = 0; … … 429 464 foreach my $row (@burntool_entries) { 430 465 my ($trash,$start,$end); 431 ($trash,$trash,$start,$end) = (split /\s+/,$row); 432 466 (undef,$trash,$start,$end) = (split /\s+/,$row); 467 if ($trash ne 'burntool') { 468 $metadata_out{nsState} = 'ERROR'; 469 return(1); 470 } 433 471 for (my $class_counter = 0; $class_counter < 60; $class_counter++) { 434 472 $metadata_out{"bt${N}Begin"} = $start; … … 650 688 my @input_exposures = split /\n/, (join '', @$stdout_buf); 651 689 foreach my $entry (@input_exposures) { 652 my ($ skycell, @trash) = split /\s+/, $entry;690 my ($warp_tess_id,$skycell, @trash) = split /\s+/, $entry; 653 691 @trash = verify_uniqueness_stack($skycell,$date,$target,$filter); 654 692 $Nalready += $trash[0]; … … 681 719 my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter); 682 720 if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :( 683 # print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 721 if ($debug == 1) { 722 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 723 } 684 724 $metadata_out{nsState} = 'FORCETOWARP'; 685 725 next; 686 726 } 687 727 if ($Nexposures == 0) { 688 # print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n"; 728 if ($debug == 1) { 729 print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n"; 730 } 689 731 next; 690 732 } 691 733 if ($Nalready != 0) { 692 # print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; 734 if ($debug == 1) { 735 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; 736 } 737 unless ($metadata_out{nsState} eq 'FORCETOWARP') { 738 $metadata_out{nsState} = 'STACKING'; 739 } 693 740 next; 694 741 } 695 unless ( $metadata_out{nsState} eq 'FORCETOWARP') {742 unless (($metadata_out{nsState} eq 'FORCETOWARP')||($metadata_out{nsState} eq 'STACKING')) { 696 743 $metadata_out{nsState} = 'QUEUESTACKS'; 697 744 } 698 745 unless(defined($pretend)) { 699 # print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n"; 746 if ($debug == 1) { 747 print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n"; 748 } 700 749 stack_queue($date,$target,$filter); 701 750 } … … 716 765 my $date = shift; 717 766 my $target = shift; 767 my $mode = shift; 768 769 my $command = $clean_commands{$mode}; 770 my $retention_time = $clean_retention{$mode}; 718 771 719 772 my ($year,$month,$day) = split /-/,$date; … … 725 778 726 779 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target); 727 728 my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group ";780 my $args = $command; 781 $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group "; 729 782 if ($debug == 1) { 730 783 $args .= ' -pretend '; … … 737 790 my $pretend = shift; 738 791 739 foreach my $target (@target_list) { 740 my ($cleaning_date,$args) = construct_cleantool_args($date,$target); 741 742 my $command = $chiptool . $args; 743 print STDERR "$command\n"; 744 if (!(defined($pretend) || $debug == 1)) { 792 foreach my $mode (keys (%clean_commands)) { 793 foreach my $target (@target_list) { 794 if (exists($noclean_list{$target})) { 795 next; 796 } 797 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode); 798 799 print STDERR "$command\n"; 800 if (!(defined($pretend) || $debug == 1)) { 745 801 # print STDERR "BEAR IS DRIVING!?\n"; 746 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 747 run ( command => $command, verbose => $verbose ); 748 unless ($success) { 749 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 750 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 751 } 752 } 753 $command = $warptool . $args; 754 print STDERR "$command\n"; 755 if (!(defined($pretend) || $debug == 1)) { 756 # print STDERR "BEAR IS DRIVING $pretend $debug!?\n"; 757 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 758 run ( command => $command, verbose => $verbose ); 759 unless ($success) { 760 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 761 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 762 } 763 } 802 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 803 run ( command => $command, verbose => $verbose ); 804 unless ($success) { 805 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 806 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 807 } 808 } 809 } 764 810 } 765 811 return(0);
Note:
See TracChangeset
for help on using the changeset viewer.
