Changeset 26988
- Timestamp:
- Feb 18, 2010, 12:28:44 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/automate_stacks.pl (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/automate_stacks.pl
r26919 r26988 30 30 # my @filter_list = ('g.00000','r.00000','i.00000','z.00000','y.00000'); 31 31 # my @target_list = ('CMB','M31','MD01','MD02','MD03','MD04','MD05','MD06','MD07','MD08','MD09','MD10', 32 # 'STS','SVS','SweetSpot','ThreePi');32 # 'STS','SVS','SweetSpot','ThreePi'); 33 33 # my %tessID_list = ('CMB' => 'RINGS.V0', 'M31' => 'M31', 'MD01' => 'MD01', 'MD02' => 'MD02', 34 # 'MD03' => 'MD03', 'MD04' => 'MD04', 'MD05' => 'MD05', 'MD06' => 'MD06',35 # 'MD07' => 'MD07', 'MD08' => 'MD08', 'MD09' => 'MD09', 'MD10' => 'MD10',36 # 'STS' => 'STS', 'SVS' => 'RINGS.V0', 'SweetSpot' => 'RINGS.V0', 'ThreePi' => 'RINGS.V0');34 # 'MD03' => 'MD03', 'MD04' => 'MD04', 'MD05' => 'MD05', 'MD06' => 'MD06', 35 # 'MD07' => 'MD07', 'MD08' => 'MD08', 'MD09' => 'MD09', 'MD10' => 'MD10', 36 # 'STS' => 'STS', 'SVS' => 'RINGS.V0', 'SweetSpot' => 'RINGS.V0', 'ThreePi' => 'RINGS.V0'); 37 37 # my %comment_list = ('CMB' => 'CMB_Cold%', 'M31' => 'M31%', 'MD01' => 'MD01%', 'MD02' => 'MD02%', 38 # 'MD03' => 'MD03%', 'MD04' => 'MD04%', 'MD05' => 'MD05%', 'MD06' => 'MD06%',39 # 'MD07' => 'MD07%', 'MD08' => 'MD08%', 'MD09' => 'MD09%', 'MD10' => 'MD10%',40 # 'STS' => 'Stellar Transit%', 'SVS' => 'SVS%', 'SweetSpot' => 'Sweetspot%', 'ThreePi' => 'ThreePi%');38 # 'MD03' => 'MD03%', 'MD04' => 'MD04%', 'MD05' => 'MD05%', 'MD06' => 'MD06%', 39 # 'MD07' => 'MD07%', 'MD08' => 'MD08%', 'MD09' => 'MD09%', 'MD10' => 'MD10%', 40 # 'STS' => 'Stellar Transit%', 'SVS' => 'SVS%', 'SweetSpot' => 'Sweetspot%', 'ThreePi' => 'ThreePi%'); 41 41 # my %stackable_list = ('CMB' => 0, 'M31' => 1, 'MD01' => 1, 'MD02' => 1, 42 # 'MD03' => 1, 'MD04' => 1, 'MD05' => 1, 'MD06' => 1,43 # 'MD07' => 1, 'MD08' => 1, 'MD09' => 1, 'MD10' => 1,44 # 'STS' => 1, 'SVS' => 0, 'SweetSpot' => 0, 'ThreePi' => 0);42 # 'MD03' => 1, 'MD04' => 1, 'MD05' => 1, 'MD06' => 1, 43 # 'MD07' => 1, 'MD08' => 1, 'MD09' => 1, 'MD10' => 1, 44 # 'STS' => 1, 'SVS' => 0, 'SweetSpot' => 0, 'ThreePi' => 0); 45 45 # my $retention_time = 9000; # days. 46 46 … … 63 63 'help|h' => \$help, 64 64 'date=s' => \$date, # night to make stacks for 65 'camera=s' => \$camera, # camera 65 'camera=s' => \$camera, # camera 66 66 'dbname=s' => \$dbname, # Database name 67 'logfile=s' => \$logfile, 67 'logfile=s' => \$logfile, 68 68 'verbose' => \$verbose, 69 69 'isburning' => \$isburning, … … 83 83 'clean_old' => \$clean_old, 84 84 ) or pod2usage ( 2 ); 85 pod2usage( -msg => 85 pod2usage( -msg => 86 86 "USAGE: automate_stacks.pl <options...> <mode> 87 87 Options: … … 90 90 --camera <camera> Default GPC1. 91 91 --dbname <db> Default gpc1. 92 --verbose 92 --verbose 93 93 --isburning Signal that we are currently burntooling. 94 94 --force_stack_count Force the chip/warp counts. … … 106 106 --queue_diffs Issue difftool commands to queue diffs. 107 107 --clean_old Mark old data 'goto_cleanup'.\n", 108 -exitval => 2, ) if (defined($help));108 -exitval => 2, ) if (defined($help)); 109 109 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 110 110 pod2usage( … … 114 114 defined $check_registration or defined $define_burntool or defined $queue_burntool or 115 115 defined $queue_chips or defined $queue_stacks or 116 defined $check_chips or defined $check_stacks or 116 defined $check_chips or defined $check_stacks or 117 117 defined $test_mode or defined $clean_old; 118 118 … … 129 129 # Grab the configuration data. 130 130 my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -"; 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 132 run(command => $conf_cmd, verbose => $verbose); 133 133 unless ($success) { … … 140 140 foreach my $entry (@{ $metadata }) { 141 141 if (${ $entry }{name} eq 'RETENTION_TIME') { 142 $retention_time = ${ $entry }{value};142 $retention_time = ${ $entry }{value}; 143 143 } 144 144 elsif (${ $entry }{name} eq 'FILTERS') { 145 push @filter_list, ${ $entry }{value};145 push @filter_list, ${ $entry }{value}; 146 146 } 147 147 elsif (${ $entry }{name} eq 'TARGETS') { 148 my @target_data = @{ ${ $entry }{value} };149 my $this_target = '';150 foreach my $tentry (@target_data) {151 if (${ $tentry }{name} eq 'NAME') {152 $this_target = ${ $tentry }{value};153 push @target_list, $this_target;154 }155 elsif (${ $tentry }{name} eq 'TESS') {156 $tessID_list{$this_target} = ${ $tentry }{value};157 }158 elsif (${ $tentry }{name} eq 'OBSMODE') {159 $obsmode_list{$this_target} = ${ $tentry }{value};160 }161 elsif (${ $tentry }{name} eq 'OBJECT') {162 $object_list{$this_target} = ${ $tentry }{value};163 }164 elsif (${ $tentry }{name} eq 'COMMENT') {165 $comment_list{$this_target} = ${ $tentry }{value};166 }167 elsif (${ $tentry }{name} eq 'STACKABLE') {168 $stackable_list{$this_target} = ${ $tentry }{value};169 }170 }148 my @target_data = @{ ${ $entry }{value} }; 149 my $this_target = ''; 150 foreach my $tentry (@target_data) { 151 if (${ $tentry }{name} eq 'NAME') { 152 $this_target = ${ $tentry }{value}; 153 push @target_list, $this_target; 154 } 155 elsif (${ $tentry }{name} eq 'TESS') { 156 $tessID_list{$this_target} = ${ $tentry }{value}; 157 } 158 elsif (${ $tentry }{name} eq 'OBSMODE') { 159 $obsmode_list{$this_target} = ${ $tentry }{value}; 160 } 161 elsif (${ $tentry }{name} eq 'OBJECT') { 162 $object_list{$this_target} = ${ $tentry }{value}; 163 } 164 elsif (${ $tentry }{name} eq 'COMMENT') { 165 $comment_list{$this_target} = ${ $tentry }{value}; 166 } 167 elsif (${ $tentry }{name} eq 'STACKABLE') { 168 $stackable_list{$this_target} = ${ $tentry }{value}; 169 } 170 } 171 171 } 172 172 } … … 190 190 if (defined($this_target_only)) { 191 191 foreach my $t (@target_list) { 192 if ($t eq $this_target_only) {193 @target_list = ($this_target_only);194 last;195 }192 if ($t eq $this_target_only) { 193 @target_list = ($this_target_only); 194 last; 195 } 196 196 } 197 197 die("$this_target_only is invalid.") if ($#target_list != 0); … … 200 200 if (defined($this_filter_only)) { 201 201 foreach my $t (@filter_list) { 202 if ($t eq $this_filter_only) {203 @filter_list = ($this_filter_only);204 last;205 }202 if ($t eq $this_filter_only) { 203 @filter_list = ($this_filter_only); 204 last; 205 } 206 206 } 207 207 die("$this_filter_only is invalid.") if ($#filter_list != 0); … … 209 209 210 210 # 211 # Mode selection 211 # Mode selection 212 212 ################################################################################ 213 213 if (defined($test_mode)) { … … 236 236 &execute_chips($date,"pretend"); 237 237 if (($metadata_out{nsState} eq 'NEEDSBURNING')&&(defined($isburning))) { 238 $metadata_out{nsState} = 'BURNING';238 $metadata_out{nsState} = 'BURNING'; 239 239 } 240 240 return_metadata($date); … … 251 251 &execute_stacks($date,"pretend"); 252 252 if ($metadata_out{nsState} eq 'FORCETOWARP') { 253 $metadata_out{nsState} = 'TOWARP';253 $metadata_out{nsState} = 'TOWARP'; 254 254 } 255 255 return_metadata($date); … … 267 267 if (defined($clean_old) || defined($test_mode)) { 268 268 if (defined($test_mode)) { 269 &execute_cleans($date,"pretend");269 &execute_cleans($date,"pretend"); 270 270 } 271 271 else { 272 &execute_cleans($date);272 &execute_cleans($date); 273 273 } 274 274 unless (defined($test_mode)) { exit(0); } … … 276 276 exit(0); 277 277 # 278 # Registration 278 # Registration 279 279 ################################################################################ 280 280 … … 284 284 285 285 # largely stolen from Bill's checkexp program. 286 286 287 287 my $sth = " SELECT exp_name, summitExp.dateobs AS registered, rawExp.dateobs, summitExp.imfiles, "; 288 288 $sth .= " summitExp.fault AS summit_fault, pzDownloadExp.state AS download_state, "; … … 294 294 295 295 my $data_ref = $db->selectall_arrayref( $sth ); 296 296 297 297 my $Nsummit_exps = 0; 298 298 my $Nsummit_faults = 0; … … 303 303 304 304 foreach my $row_ref (@{ $data_ref }) { 305 my ($exp_name,$registered,$dateobs,$imfiles,$summit_fault,306 $download_state,$download_count,$new_state,$exp_id,$exp_type) = @{ $row_ref };307 $Nsummit_exps++;308 if ($summit_fault) {309 print STDERR "check_summit_copy: $date $exp_name has summit_fault $summit_fault";310 if ($exp_type ne 'OBJECT') {311 print STDERR " (but I don't care).\n";312 }313 else {314 print STDERR "\n";315 $Nsummit_faults++;316 }317 } 318 elsif (!$download_state or $download_state eq 'run') {319 print STDERR "check_summit_copy: $date $exp_name has download_state $download_state";320 if ($exp_type ne 'OBJECT') {321 print STDERR " (but I don't care).\n";322 }323 else {324 print STDERR "\n";325 $Ndownload_faults++;326 }327 }328 elsif (!$new_state or $new_state eq 'run' ) {329 print STDERR "check_summit_copy: $date $exp_name has new_state $new_state";330 if ($exp_type ne 'OBJECT') {331 print STDERR " (but I don't care).\n";332 }333 else {334 print STDERR "\n";335 $Nregister_faults++;336 }337 }305 my ($exp_name,$registered,$dateobs,$imfiles,$summit_fault, 306 $download_state,$download_count,$new_state,$exp_id,$exp_type) = @{ $row_ref }; 307 $Nsummit_exps++; 308 if ($summit_fault) { 309 print STDERR "check_summit_copy: $date $exp_name has summit_fault $summit_fault"; 310 if ($exp_type ne 'OBJECT') { 311 print STDERR " (but I don't care).\n"; 312 } 313 else { 314 print STDERR "\n"; 315 $Nsummit_faults++; 316 } 317 } 318 elsif (!$download_state or $download_state eq 'run') { 319 print STDERR "check_summit_copy: $date $exp_name has download_state $download_state"; 320 if ($exp_type ne 'OBJECT') { 321 print STDERR " (but I don't care).\n"; 322 } 323 else { 324 print STDERR "\n"; 325 $Ndownload_faults++; 326 } 327 } 328 elsif (!$new_state or $new_state eq 'run' ) { 329 print STDERR "check_summit_copy: $date $exp_name has new_state $new_state"; 330 if ($exp_type ne 'OBJECT') { 331 print STDERR " (but I don't care).\n"; 332 } 333 else { 334 print STDERR "\n"; 335 $Nregister_faults++; 336 } 337 } 338 338 } 339 339 340 340 my $Nfaults = $Nsummit_faults + $Ndownload_faults + $Nregister_faults; 341 341 if ($Nsummit_exps == 0) { 342 print STDERR "No exposures were found on the summit for $date.\n";343 $metadata_out{nsState} = 'DROP';342 print STDERR "No exposures were found on the summit for $date.\n"; 343 $metadata_out{nsState} = 'DROP'; 344 344 } 345 345 elsif ($Nfaults != 0) { 346 print STDERR "There were faults while downloading the exposures for $date.\n";347 $metadata_out{nsState} = 'NEW';346 print STDERR "There were faults while downloading the exposures for $date.\n"; 347 $metadata_out{nsState} = 'NEW'; 348 348 } 349 349 else { 350 print STDERR "Summit copy and Registration have succeeded for $date.\n";351 $metadata_out{nsState} = 'REGISTERED';352 } 353 350 print STDERR "Summit copy and Registration have succeeded for $date.\n"; 351 $metadata_out{nsState} = 'REGISTERED'; 352 } 353 354 354 return($Nsummit_exps,$Nfaults); 355 } 355 } 356 356 357 357 # … … 364 364 my $config_cmd = "$ppConfigDump -camera $camera -dump-camera - | grep BURNTOOL.STATE.GOOD | uniq"; 365 365 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 366 run ( command => $config_cmd, verbose => $verbose);366 run ( command => $config_cmd, verbose => $verbose); 367 367 unless ($success) { 368 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);369 &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, 0, $PS_EXIT_SYS_ERROR);368 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 369 &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, 0, $PS_EXIT_SYS_ERROR); 370 370 } 371 371 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 372 &my_die("Unable to parse metadata config doc", 0, 0, 0, $PS_EXIT_SYS_ERROR);372 &my_die("Unable to parse metadata config doc", 0, 0, 0, $PS_EXIT_SYS_ERROR); 373 373 my $burntoolStateGood = 999; 374 374 foreach my $cfg (@$recipeData) { 375 if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {376 $burntoolStateGood = $cfg->{value};377 }375 if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') { 376 $burntoolStateGood = $cfg->{value}; 377 } 378 378 } 379 379 if ($burntoolStateGood == 999) { 380 &my_die("Failed to determine BURNTOOL.STATE.GOOD", $burntoolStateGood, 0, 0, $PS_EXIT_SYS_ERROR);380 &my_die("Failed to determine BURNTOOL.STATE.GOOD", $burntoolStateGood, 0, 0, $PS_EXIT_SYS_ERROR); 381 381 } 382 382 return($burntoolStateGood); … … 388 388 389 389 my $db = init_gpc_db(); 390 390 391 391 my $sth = "SELECT exp_id,exp_name,obs_mode,dateobs,class_id,burntool_state,comment FROM rawImfile WHERE exp_id = $exp_id"; 392 392 my $data_ref = $db->selectall_arrayref( $sth ); … … 397 397 foreach my $row_ref (@{ $data_ref }) { 398 398 my ($exp_id,$exp_name, $obs_mode,$dateobs,$class_id,$burntool_state,$comment) = @{ $row_ref }; 399 $Nimfiles++;400 if (abs($burntool_state) == $burntoolStateGood) {401 $Nburntooled++;402 }399 $Nimfiles++; 400 if (abs($burntool_state) == $burntoolStateGood) { 401 $Nburntooled++; 402 } 403 403 } 404 404 return($Nimfiles,$Nburntooled); 405 } 405 } 406 406 407 407 sub find_burntool_ranges { … … 410 410 my $command = "$mkBTpcontrol -d $date -b"; 411 411 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 412 run ( command => $command, verbose => $verbose );412 run ( command => $command, verbose => $verbose ); 413 413 unless ($success) { 414 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);415 &my_die("Unable to perform $command: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);414 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 415 &my_die("Unable to perform $command: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 416 416 } 417 417 418 418 if ($#{ $stderr_buf } > -1) { 419 $metadata_out{nsState} = 'ERROR'; 420 return(1);419 $metadata_out{nsState} = 'ERROR'; 420 return(1); 421 421 } 422 422 … … 424 424 my @burntool_entries = split /\n/, (join '', @$stdout_buf); 425 425 foreach my $row (@burntool_entries) { 426 my ($trash,$start,$end);427 ($trash,$trash,$start,$end) = (split /\s+/,$row);428 $metadata_out{"btBegin${N}"} = $start;429 $metadata_out{"btEnd${N}"} = $end;430 $metadata_out{"btCounter${N}"} = 0;431 $N++;432 print STDERR "define_burntool: $row\n";426 my ($trash,$start,$end); 427 ($trash,$trash,$start,$end) = (split /\s+/,$row); 428 $metadata_out{"btBegin${N}"} = $start; 429 $metadata_out{"btEnd${N}"} = $end; 430 $metadata_out{"btCounter${N}"} = 0; 431 $N++; 432 print STDERR "define_burntool: $row\n"; 433 433 } 434 434 $metadata_out{btN} = $N - 1; … … 437 437 return(0); 438 438 } 439 439 440 440 # 441 441 # Chips … … 447 447 448 448 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group) = get_tool_parameters($date,$target); 449 449 450 450 my $select = "-dateobs_begin ${date}T00:00:00 -dateobs_end ${date}T23:59:59 "; 451 451 $date =~ s/-//g; … … 457 457 $cmd .= " -set_tess_id $tess_id -set_data_group $data_group "; 458 458 if (defined($obs_mode)) { 459 $cmd .= " -obs_mode '$obs_mode' ";459 $cmd .= " -obs_mode '$obs_mode' "; 460 460 } 461 461 if (defined($object)) { 462 $cmd .= " -object '$object' ";462 $cmd .= " -object '$object' "; 463 463 } 464 464 if (defined($comment)) { 465 $cmd .= " -comment '$comment' ";465 $cmd .= " -comment '$comment' "; 466 466 } 467 467 $cmd .= " $select "; 468 468 if ($debug == 1) { 469 $cmd .= " -pretend ";469 $cmd .= " -pretend "; 470 470 } 471 471 print STDERR "$cmd\n"; … … 477 477 my $date = shift; 478 478 my $target = shift; 479 479 480 480 my $db = init_gpc_db(); 481 481 $date =~ s/-//g; … … 491 491 my $date = shift; 492 492 my $target = shift; 493 493 494 494 my $command = construct_chiptool_cmd($date,$target) . ' -pretend '; 495 495 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 496 run ( command => $command, verbose => $verbose );496 run ( command => $command, verbose => $verbose ); 497 497 unless ($success) { 498 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);499 &my_die("Unable to perform chiptool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);498 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 499 &my_die("Unable to perform chiptool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 500 500 } 501 501 … … 506 506 my @input_exposures = split /\n/, (join '', @$stdout_buf); 507 507 foreach my $entry (@input_exposures) { 508 my ($exp_id, @trash) = split /\s+/, $entry;509 @trash = verify_burntool($exp_id,$burntoolStateGood);510 $Nimfiles += $trash[0];511 $Nburntooled += $trash[1];512 513 @trash = verify_uniqueness_chip($exp_id,$date,$target);514 $Nalready += $trash[0];508 my ($exp_id, @trash) = split /\s+/, $entry; 509 @trash = verify_burntool($exp_id,$burntoolStateGood); 510 $Nimfiles += $trash[0]; 511 $Nburntooled += $trash[1]; 512 513 @trash = verify_uniqueness_chip($exp_id,$date,$target); 514 $Nalready += $trash[0]; 515 515 } 516 516 return($#input_exposures + 1,$Nimfiles,$Nburntooled,$Nalready); … … 523 523 my $command = construct_chiptool_cmd($date,$target); 524 524 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 525 run ( command => $command, verbose => $verbose );525 run ( command => $command, verbose => $verbose ); 526 526 unless ($success) { 527 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);528 &my_die("Unable to perform chiptool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);527 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 528 &my_die("Unable to perform chiptool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 529 529 } 530 530 $metadata_out{nsState} = 'TOWARP'; … … 536 536 my $pretend = shift; 537 537 foreach my $target (@target_list) { 538 my ($Nexposures,$Nimfiles,$Nburntooled,$Nalready) = pre_chip_queue($date,$target);539 if ($Nexposures == 0) {540 print STDERR "execute_chips: Target $target on $date had no exposures.\n";541 next;542 }543 if ($Nalready != 0) {544 print STDERR "execute_chips: Not queueing $target on $date due to already existing exposures.\n";545 next;546 }547 if ($Nimfiles != $Nburntooled) {548 print STDERR "execute_chips: Target $target on $date is not fully burntooled.\n";549 $metadata_out{nsState} = 'NEEDSBURNING';550 next;551 }552 unless(defined($pretend)) {553 chip_queue($date,$target);554 }538 my ($Nexposures,$Nimfiles,$Nburntooled,$Nalready) = pre_chip_queue($date,$target); 539 if ($Nexposures == 0) { 540 print STDERR "execute_chips: Target $target on $date had no exposures.\n"; 541 next; 542 } 543 if ($Nalready != 0) { 544 print STDERR "execute_chips: Not queueing $target on $date due to already existing exposures.\n"; 545 next; 546 } 547 if ($Nimfiles != $Nburntooled) { 548 print STDERR "execute_chips: Target $target on $date is not fully burntooled.\n"; 549 $metadata_out{nsState} = 'NEEDSBURNING'; 550 next; 551 } 552 unless(defined($pretend)) { 553 chip_queue($date,$target); 554 } 555 555 } 556 556 } … … 572 572 my $cmd = "$stacktool"; 573 573 # $cmd .= ' -pretend -simple -dbname gpc1 -definebyquery -min_new 4 '; # Probably silly, but I want to be safe and not overwrite 574 $cmd .= ' -simple -dbname gpc1 -definebyquery '; 574 $cmd .= ' -simple -dbname gpc1 -definebyquery '; 575 575 $cmd .= " -set_label $label -select_label $label "; 576 576 $cmd .= " -set_workdir $workdir -set_dist_group $dist_group "; 577 577 $cmd .= " -select_filter $filter -set_data_group $data_group "; 578 $cmd .= " -min_num 4"; 578 579 $cmd .= " $select "; 579 580 if ($debug == 1) { 580 $cmd .= ' -pretend ';581 $cmd .= ' -pretend '; 581 582 } 582 583 print STDERR "$cmd\n"; 583 584 return($cmd); 584 } 585 } 585 586 586 587 sub verify_uniqueness_stack { … … 596 597 my $sth = "SELECT skycell_id from stackRun where data_group = '$data_group' AND skycell_id = '$skycell' AND filter = '$filter'"; 597 598 my $data_ref = $db->selectall_arrayref( $sth ); 598 599 599 600 return($#{ $data_ref } + 1); 600 601 } … … 620 621 # check that we will be able to queue them up 621 622 my $command = construct_stacktool_cmd($date,$target,$filter) . ' -pretend '; 622 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 623 run ( command => $command, verbose => $verbose );623 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 624 run ( command => $command, verbose => $verbose ); 624 625 unless ($success) { 625 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);626 &my_die("Unable to perform stacktool: $error_code", $#{ $chip_ref },$#{ $warp_ref },$date, $PS_EXIT_SYS_ERROR);627 } 628 626 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 627 &my_die("Unable to perform stacktool: $error_code", $#{ $chip_ref },$#{ $warp_ref },$date, $PS_EXIT_SYS_ERROR); 628 } 629 629 630 my $Nalready = 0; 630 631 631 my @input_exposures = split /\n/, (join '', @$stdout_buf); 632 my @input_exposures = split /\n/, (join '', @$stdout_buf); 632 633 foreach my $entry (@input_exposures) { 633 my ($skycell, @trash) = split /\s+/, $entry;634 @trash = verify_uniqueness_stack($skycell,$date,$target,$filter);635 $Nalready += $trash[0];634 my ($skycell, @trash) = split /\s+/, $entry; 635 @trash = verify_uniqueness_stack($skycell,$date,$target,$filter); 636 $Nalready += $trash[0]; 636 637 } 637 638 … … 645 646 646 647 my $command = construct_stacktool_cmd($date,$target,$filter); 647 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 648 run ( command => $command, verbose => $verbose );648 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 649 run ( command => $command, verbose => $verbose ); 649 650 unless ($success) { 650 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);651 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);651 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 652 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 652 653 } 653 654 return(0); … … 658 659 my $pretend = shift; 659 660 foreach my $target (@target_list) { 660 if ($stackable_list{$target} == 1) {661 foreach my $filter (@filter_list) {662 my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter);663 if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :(664 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n";665 $metadata_out{nsState} = 'FORCETOWARP';666 next;667 }668 if ($Nexposures == 0) {669 print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n";670 next;671 }672 if ($Nalready != 0) {673 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n";674 next;675 }676 unless ($metadata_out{nsState} eq 'FORCETOWARP') {677 $metadata_out{nsState} = 'QUEUESTACKS';678 }679 unless(defined($pretend)) {680 print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n";681 stack_queue($date,$target,$filter);682 }683 }684 }685 else {686 print STDERR "execute_stacks: Target $target is not auto-stackable.\n";687 }688 } 689 661 if ($stackable_list{$target} == 1) { 662 foreach my $filter (@filter_list) { 663 my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter); 664 if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :( 665 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 666 $metadata_out{nsState} = 'FORCETOWARP'; 667 next; 668 } 669 if ($Nexposures == 0) { 670 print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n"; 671 next; 672 } 673 if ($Nalready != 0) { 674 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; 675 next; 676 } 677 unless ($metadata_out{nsState} eq 'FORCETOWARP') { 678 $metadata_out{nsState} = 'QUEUESTACKS'; 679 } 680 unless(defined($pretend)) { 681 print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n"; 682 stack_queue($date,$target,$filter); 683 } 684 } 685 } 686 else { 687 print STDERR "execute_stacks: Target $target is not auto-stackable.\n"; 688 } 689 } 690 690 691 } 691 692 … … 697 698 my $date = shift; 698 699 my $target = shift; 699 700 700 701 my ($year,$month,$day) = split /-/,$date; 701 702 my $dt = DateTime->new(year => $year, month => $month, day => $day, 702 hour => 0, minute => 0, second => 0, nanosecond => 0,703 time_zone => 'Pacific/Honolulu');703 hour => 0, minute => 0, second => 0, nanosecond => 0, 704 time_zone => 'Pacific/Honolulu'); 704 705 $dt->subtract(days => $retention_time); 705 706 my $cleaning_date = $dt->ymd; … … 709 710 my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group "; 710 711 if ($debug == 1) { 711 $args .= ' -pretend ';712 $args .= ' -pretend '; 712 713 } 713 714 return($cleaning_date,$args); … … 719 720 720 721 foreach my $target (@target_list) { 721 my ($cleaning_date,$args) = construct_cleantool_args($date,$target);722 723 my $command = $chiptool . $args;724 print STDERR "$command\n";725 if (!(defined($pretend) || $debug == 1)) {726 # print STDERR "BEAR IS DRIVING!?\n";727 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 728 run ( command => $command, verbose => $verbose );729 unless ($success) {730 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);731 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);732 }733 }734 $command = $warptool . $args;735 print STDERR "$command\n";736 if (!(defined($pretend) || $debug == 1)) {737 # print STDERR "BEAR IS DRIVING $pretend $debug!?\n";738 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 739 run ( command => $command, verbose => $verbose );740 unless ($success) {741 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);742 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);743 }744 }722 my ($cleaning_date,$args) = construct_cleantool_args($date,$target); 723 724 my $command = $chiptool . $args; 725 print STDERR "$command\n"; 726 if (!(defined($pretend) || $debug == 1)) { 727 # print STDERR "BEAR IS DRIVING!?\n"; 728 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 729 run ( command => $command, verbose => $verbose ); 730 unless ($success) { 731 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 732 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 733 } 734 } 735 $command = $warptool . $args; 736 print STDERR "$command\n"; 737 if (!(defined($pretend) || $debug == 1)) { 738 # print STDERR "BEAR IS DRIVING $pretend $debug!?\n"; 739 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 740 run ( command => $command, verbose => $verbose ); 741 unless ($success) { 742 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 743 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 744 } 745 } 745 746 } 746 747 return(0); 747 748 } 748 749 750 749 750 751 751 752 752 753 # … … 779 780 my $dbpass = 'ippuser'; 780 781 $db = DBI->connect("DBI:mysql:database=${dbname};host=${dbserver};" . 781 "mysql_socket=" . DB_SOCKET(),782 ${dbuser},${dbpass}, 783 { RaiseError => 1, AutoCommit => 1}784 ) or die "Unable to connect to database $DBI::errstr\n";782 "mysql_socket=" . DB_SOCKET(), 783 ${dbuser},${dbpass}, 784 { RaiseError => 1, AutoCommit => 1} 785 ) or die "Unable to connect to database $DBI::errstr\n"; 785 786 return($db); 786 787 } … … 792 793 print STDOUT " date STR $date\n"; 793 794 foreach my $k (keys %metadata_out) { 794 print STDOUT " $k STR $metadata_out{$k}\n";795 print STDOUT " $k STR $metadata_out{$k}\n"; 795 796 } 796 797 print STDOUT "END\n"; … … 810 811 sub my_trace { 811 812 if ($debug == 1) { 812 foreach my $thing (@_) {813 carp($thing);814 }815 } 816 } 813 foreach my $thing (@_) { 814 carp($thing); 815 } 816 } 817 }
Note:
See TracChangeset
for help on using the changeset viewer.
