Changeset 30120 for trunk/ippScripts/scripts
- Timestamp:
- Dec 20, 2010, 5:52:38 PM (16 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 3 edited
-
ipp_apply_burntool_single.pl (modified) (1 diff)
-
nightly_science.pl (modified) (11 diffs)
-
register_imfile.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_apply_burntool_single.pl
r30049 r30120 178 178 my $exp_id = shift; 179 179 my $class_id = shift; 180 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);180 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state 0 -set_state pending_burntool",1); 181 181 } 182 182 printf STDERR "$message\n"; -
trunk/ippScripts/scripts/nightly_science.pl
r30067 r30120 396 396 exit(0); 397 397 } 398 exit(10); 398 399 399 if (defined($check_confirm_stacks) || defined($test_mode)) { 400 400 $metadata_out{nsStackState} = 'CONFIRM_STACKING'; … … 409 409 exit(0); 410 410 } 411 411 exit(10); 412 412 if (defined($check_sweetspot) || defined($test_mode) || defined($check_mode)) { 413 413 $metadata_out{nsSSState} = 'CHECKSWEETSPOT'; … … 1097 1097 my $pretend = shift; 1098 1098 1099 my $Npotential = 0; 1100 my $Nqueued = 0; 1099 1101 foreach my $target (sort (keys %science_config)) { 1100 1102 if ($science_config{$target}{STACKABLE} == 1) { … … 1120 1122 next; 1121 1123 } 1124 $Npotential++; 1122 1125 if ($Nalready != 0) { 1126 $Nqueued++; 1123 1127 if ($debug == 1) { 1124 1128 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; … … 1137 1141 } 1138 1142 stack_queue($date,$target,$filter); 1143 $Nqueued ++; 1139 1144 } 1140 1145 if (defined($pretend)) { … … 1152 1157 } 1153 1158 } 1159 $metadata_out{nsStackPotential} = $Npotential; 1160 $metadata_out{nsStackQueued} = $Nqueued; 1161 if (($Npotential == $Nqueued)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1162 $metadata_out{nsStackState} = 'FINISHED_STACKS'; 1163 } 1154 1164 } 1155 1165 … … 1231 1241 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1232 1242 1233 my $sth = "SELECT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1243 my $count = 0; 1244 1245 my $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1234 1246 my $data_ref = $db->selectall_arrayref( $sth ); 1235 1236 return($#{ $data_ref } + 1); 1247 $count += $#{ $data_ref } + 1; 1248 1249 $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_2 AND warp2 = $warp_id_1"; 1250 $data_ref = $db->selectall_arrayref( $sth ); 1251 $count += $#{ $data_ref } + 1; 1252 1253 return($count); 1237 1254 } 1238 1255 … … 1276 1293 foreach my $filter (@filter_list) { 1277 1294 my ($NprocChips,$NprocWarps) = pre_diff_queue($date,$observing_state,$target,$filter); 1278 if ((!defined($force_diff_count))&&($NprocChips != $NprocWarps)) {1279 if ($debug == 1) {1280 print STDERR "execute_diffs: Target $target in filter $filter on $date is not fully processed. ($NprocChips $NprocWarps)\n";1281 }1282 $metadata_out{nsDiffState} = 'FORCETOWARP';1283 next;1284 }1295 # if ((!defined($force_diff_count))&&($NprocChips != $NprocWarps)) { 1296 # if ($debug == 1) { 1297 # print STDERR "execute_diffs: Target $target in filter $filter on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 1298 # } 1299 # $metadata_out{nsDiffState} = 'FORCETOWARP'; 1300 # next; 1301 # } 1285 1302 if ($NprocChips == 0) { 1286 1303 if ($debug == 1) { … … 1326 1343 1327 1344 my $object_ref = $db->selectall_arrayref( $obj_sth ); 1345 1346 my $Npotential = 0; 1347 my $Nqueued = 0; 1328 1348 1329 1349 foreach my $object_row (@{ $object_ref }) { 1330 1350 my $this_object = shift @{ $object_row }; 1331 my $input_sth = "select exp_id,warp_id,dateobs from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";1351 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1332 1352 $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1333 1353 $input_sth .= " ORDER BY dateobs "; 1334 1354 1335 1355 my $warps = $db->selectall_arrayref( $input_sth ); 1356 1357 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1358 my %comment_hash = (); 1359 foreach my $this_warp (@{ $warps }) { 1360 my $this_comment = ${ $this_warp }[3]; 1361 my $this_exp_id = ${ $this_warp }[0]; 1362 $comment_hash{$this_comment} = $this_exp_id; 1363 } 1336 1364 1337 1365 if (($#{ $warps } + 1) % 2 != 0) { 1338 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps }\n"; 1339 next; 1366 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1367 if ($#{ $warps} + 1 == 1) { 1368 print STDERR ": I can do no diffs with only one exposure.\n"; 1369 next; 1370 } 1371 else { 1372 print STDERR ": I should declare an exposure to be faulty.\n"; 1373 my @keep_warps = (); 1374 # print "@{ $warps }\n"; 1375 foreach my $this_warp (@{ $warps }) { 1376 my $this_comment = ${ $this_warp }[3]; 1377 my $this_exp_id = ${ $this_warp }[0]; 1378 if ($comment_hash{$this_comment} == $this_exp_id) { 1379 push @keep_warps, $this_warp; 1380 } 1381 else { 1382 print STDERR "diff_queue: excluding $this_exp_id for $this_object\n"; 1383 } 1384 } 1385 @{ $warps } = @keep_warps; 1386 # print "@{ $warps }\n"; 1387 } 1340 1388 } 1341 1389 1342 1390 while ($#{ $warps } > -1) { 1343 1391 my $input_warp = shift @{ $warps }; 1392 my $input_exp_id = ${ $input_warp }[0]; 1393 my $input_comment = ${ $input_warp }[3]; 1394 1395 1344 1396 my $template_warp = shift @{ $warps }; 1345 my $input_exp_id = ${ $input_warp }[0]; 1397 1346 1398 my $template_exp_id = ${ $template_warp }[0]; 1347 1399 1348 1400 my $input_warp_id = ${ $input_warp }[1]; 1349 1401 my $template_warp_id = ${ $template_warp }[1]; 1350 1402 1403 $Npotential++; 1351 1404 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1405 $Nqueued++; 1352 1406 print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id\n"; 1353 1407 next; … … 1366 1420 $cmd .= ' -pretend '; 1367 1421 print STDERR "diff_queue: $cmd\n"; 1422 print STDERR " $input_warp_id $template_warp_id\n"; 1368 1423 } 1369 1424 … … 1378 1433 } 1379 1434 } 1435 $metadata_out{nsDiffPotential} += $Npotential; 1436 $metadata_out{nsDiffQueued} += $Nqueued; 1437 if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1438 $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1439 } 1440 1380 1441 } 1381 1442 -
trunk/ippScripts/scripts/register_imfile.pl
r30113 r30120 54 54 ) or pod2usage( 2 ); 55 55 56 my $ipprc = PS::IPP::Config->new() or my_die ( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration57 $ipprc->redirect_output($logfile) or my_die ( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile;56 my $ipprc = PS::IPP::Config->new() or my_die_for_add( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 57 $ipprc->redirect_output($logfile) or my_die_for_add( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile; 58 58 59 59 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 101 101 print "STDOUT:\n$out1"; 102 102 print "STDERR:\n$err1"; 103 &my_die ("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1;103 &my_die_for_add("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1; 104 104 105 105 print "[Running " . join(' ', @command2) . "]\n"; … … 110 110 print "STDOUT:\n$out2"; 111 111 print "STDERR:\n$err2"; 112 &my_die ("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2;112 &my_die_for_add("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2; 113 113 chomp $out2; 114 114 $cmdflags = $out2; … … 162 162 163 163 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 164 if (uc(&value_for_flag ($cmdflags, "NULL", "-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }165 if (uc(&value_for_flag ($cmdflags, "NULL", "-inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }166 if (uc(&value_for_flag ($cmdflags, "NULL", "-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }167 if (uc(&value_for_flag ($cmdflags, "NULL", "-class_id")) eq "NULL") { &my_die ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }168 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }164 if (uc(&value_for_flag ($cmdflags, "NULL", "-telescope")) eq "NULL") { &my_die_for_add ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 165 if (uc(&value_for_flag ($cmdflags, "NULL", "-inst")) eq "NULL") { &my_die_for_add ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 166 if (uc(&value_for_flag ($cmdflags, "NULL", "-filelevel")) eq "NULL") { &my_die_for_add ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 167 if (uc(&value_for_flag ($cmdflags, "NULL", "-class_id")) eq "NULL") { &my_die_for_add ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 168 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die_for_add ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 169 169 170 170 my $command = "$regtool -addprocessedimfile"; … … 177 177 $command .= " -hostname $host" if defined $host; 178 178 $command .= " -dbname $dbname" if defined $dbname; 179 $command .= " -data_state check_burntool"; 179 if (abs($burntoolState) == $burntoolStateGood) { 180 $command .= " -data_state full"; 181 } 182 else { 183 $command .= " -data_state check_burntool"; 184 } 180 185 $command .= " $cmdflags"; 181 186 … … 236 241 # We now have an imfile in the database, check if we can burntool it. If not, continue on. 237 242 238 {243 if (abs($burntoolState) != $burntoolStateGood) { 239 244 my $mdcParser = PS::IPP::Metadata::Config->new; 240 245 … … 256 261 unless ($success) { 257 262 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 258 &my_die ("Unable to perform regtool: $error_code",259 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR);263 &my_die_for_update("Unable to perform regtool: $error_code", 264 $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR); 260 265 } 261 266 … … 270 275 271 276 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 272 &my_die ("Unable to parse output from regtool",273 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR) unless274 defined $list;277 &my_die_for_update("Unable to parse output from regtool", 278 $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR) unless 279 defined $list; 275 280 push @{ $exposures }, @$list; 276 281 @single = (); … … 353 358 } 354 359 355 sub my_die 360 sub my_die_for_add 356 361 { 357 362 my $msg = shift; # Warning message on die … … 384 389 exit $exit_code; 385 390 } 391 sub my_die_for_update 392 { 393 my $msg = shift; # Warning message on die 394 my $exp_id = shift; 395 my $exp_name = shift; 396 my $class_id = shift; 397 my $uri = shift; 398 my $exit_code = shift; 399 400 # for failed imfiles, we insert UNKNOWN for inst, telescope, class_id 401 402 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 403 404 carp($msg); 405 if (defined $exp_id && defined $tmp_class_id and not $no_update) { 406 my $command = "$regtool -updateprocessedimfile"; 407 $command .= " -exp_id $exp_id"; 408 $command .= " -class_id $class_id"; 409 $command .= " -fault $exit_code"; 410 $command .= " -hostname $host" if defined $host; 411 $command .= " -dbname $dbname" if defined $dbname; 412 print "Running: $command\n"; 413 system($command); 414 } 415 exit $exit_code; 416 } 386 417 387 418 # Pau.
Note:
See TracChangeset
for help on using the changeset viewer.
