Changeset 29493
- Timestamp:
- Oct 20, 2010, 9:39:26 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
dbconfig/background.md (modified) (2 diffs)
-
dbconfig/changes.txt (modified) (1 diff)
-
ippScripts/scripts/magic_process.pl (modified) (12 diffs)
-
ippTools/share/magictool_toprocess_inputs.sql (modified) (1 diff)
-
ippTools/share/magictool_toprocess_tree.sql (modified) (2 diffs)
-
ippTools/share/magictool_totree.sql (modified) (1 diff)
-
ippTools/src/bgtool.c (modified) (2 diffs)
-
ippTools/src/magictool.c (modified) (6 diffs)
-
ippTools/src/magictoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/background.md
r28486 r29493 21 21 class_id STR 64 22 22 path_base STR 255 23 data_state STR 64 23 24 magicked S64 0 24 25 dtime_script F32 0.0 … … 57 58 skycell_id STR 64 58 59 path_base STR 255 60 data_state STR 64 59 61 magicked S64 0 60 62 dtime_script F32 0.0 -
trunk/dbconfig/changes.txt
r28873 r29493 1945 1945 ALTER TABLE diffSummary DROP PRIMARY KEY, ADD PRIMARY KEY (diff_id, projection_cell); 1946 1946 ALTER TABLE stackSummary DROP PRIMARY KEY, ADD PRIMARY KEY (sass_id, projection_cell); 1947 1948 -- changes to support cleanup of the background preserved images 1949 ALTER TABLE chipBackgroundImfile ADD COLUMN data_state VARCHAR(64) AFTER path_base; 1950 ALTER TABLE chipBackgroundImfile ADD KEY(data_state); 1951 ALTER TABLE warpBackgroundSkyfile ADD COLUMN data_state VARCHAR(64) AFTER path_base; 1952 ALTER TABLE warpBackgroundSkyfile ADD KEY(data_state); 1953 1954 ALTER TABLE stackSumSkyfile ADD COLUMN mjd_obs double AFTER good_frac; -
trunk/ippScripts/scripts/magic_process.pl
r28137 r29493 17 17 use IPC::Cmd 0.36 qw( can_run run ); 18 18 use File::Temp qw( tempfile ); 19 use File::Copy; 19 20 use PS::IPP::Metadata::Config; 20 21 use PS::IPP::Metadata::List qw( parse_md_list ); … … 41 42 42 43 # Parse the command-line arguments 43 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile );44 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile, $final_outroot); 44 45 45 46 GetOptions( … … 49 50 'dbname=s' => \$dbname, # Database name 50 51 'baseroot=s' => \$baseroot, # Output root name 52 'final-outroot=s' => \$final_outroot, # location for final outputs 51 53 'save-temps' => \$save_temps, # Save temporary files? 52 54 'verbose' => \$verbose, # Print stuff? … … 86 88 87 89 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 90 91 # list of VerifyStreaks input and output files to copy to nebulous 92 my @verify_outputs = qw( 93 clusterPos.txt 94 duplicate.png 95 mask.png 96 original.png 97 original.fits 98 residual.png 99 residual.fits 100 clusters.list 101 ); 88 102 89 103 ### Get a list of inputs … … 312 326 313 327 314 ### Input result into database315 {316 my $command = "$magictool -addresult";317 $command .= " -magic_id $magic_id";318 $command .= " -node $node";319 $command .= " -path_base $outroot";320 $command .= " -dbname $dbname" if defined $dbname;321 322 # Add the processed file to the database323 unless ($no_update) {324 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =325 run(command => $command, verbose => $verbose);326 unless ($success) {327 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);328 &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code);329 }330 } else {331 print "Skipping command: $command\n";332 }333 }334 335 328 if ($node eq "root") { 336 329 my $streaks_file = "$outroot.streaks"; … … 349 342 } 350 343 351 &run_verifystreaks($baseroot);352 344 353 345 my $exp_id; # Exposure identifier … … 366 358 } 367 359 360 &run_verifystreaks($baseroot, $exp_id); 361 368 362 { 369 363 my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path); # Astrometry file … … 383 377 } 384 378 379 my $output_streaks = $final_outroot . ".streaks"; 380 if ($output_streaks and ($output_streaks ne $streaks_file)) { 381 copy_to_nebulous($ipprc, $streaks_file, $output_streaks, 1); 382 foreach my $f (@verify_outputs) { 383 my $src = "$baseroot.verify/${exp_id}_$f"; 384 my $dest = "$final_outroot.${f}"; 385 copy_to_nebulous($ipprc, $src, $dest, 1); 386 } 387 } else { 388 $output_streaks = $streaks_file; 389 } 390 391 ### Input result into database 392 # XXXX: if this succeeds but addmask fails the magicRun is in a goofy state XXXX 393 { 394 my $command = "$magictool -addresult"; 395 $command .= " -magic_id $magic_id"; 396 $command .= " -node $node"; 397 $command .= " -path_base $outroot"; 398 $command .= " -dbname $dbname" if defined $dbname; 399 400 # Add the processed file to the database 401 unless ($no_update) { 402 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 403 run(command => $command, verbose => $verbose); 404 unless ($success) { 405 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 406 &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code); 407 } 408 } else { 409 print "Skipping command: $command\n"; 410 } 411 } 412 385 413 386 414 { 387 415 my $command = "$magictool -addmask"; 388 416 $command .= " -magic_id $magic_id"; 389 $command .= " -uri $ streaks_file";417 $command .= " -uri $final_outroot"; 390 418 $command .= " -streaks $num_streaks"; 391 419 $command .= " -dbname $dbname" if defined $dbname; … … 411 439 412 440 my $baseroot = shift; 441 my $exp_id = shift; 413 442 414 443 unless ($VerifyStreaks) { … … 431 460 my @files = <$baseroot.*.clusters>; 432 461 433 unless (open ($FILE, ">$outdir/clusters.list")) { 434 print "failed to create cluster file $outdir/clusters.list\n"; 462 my $clusters_list = "$outdir/${exp_id}_clusters.list"; 463 unless (open ($FILE, ">$clusters_list")) { 464 print "failed to create cluster file $clusters_list\n"; 435 465 return 1; 436 466 } … … 441 471 close ($FILE); 442 472 if ($status) { 443 print "failed to create cluster file $ outdir/clusters.list\n";473 print "failed to create cluster file $clusters_list\n"; 444 474 return 1; 445 475 } 446 476 447 my $command = "$VerifyStreaks --out $outdir --clusters $ outdir/clusters.list $baseroot.root.streakMap";477 my $command = "$VerifyStreaks --out $outdir --clusters $clusters_list $baseroot.root.streakMap"; 448 478 449 479 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 513 543 } 514 544 545 # Copy a file to nebulous and optionally replicate it 546 # We should consider making this an ipprc function. For now try it here so we can print 547 # the right error messages 548 sub copy_to_nebulous { 549 my $ipprc = shift; 550 my $src = shift; 551 my $dest = shift; 552 my $replicate = shift; 553 554 print "copying $src to $dest\n"; 555 556 $ipprc->file_exists($src) or 557 &my_die("expected output file does not exist: $src", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 558 559 # copy the file to it's final destination - which is presumably in nebulous 560 # we delete it so that all instances are deleted in case it has been replicated 561 if ($ipprc->file_exists($dest)) { 562 $ipprc->file_delete($dest) or 563 &my_die("failed to delete existing file: $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 564 } 565 my $dest_resolved = $ipprc->file_resolve($dest, 'create'); 566 &my_die("failed to resolve $dest", $PS_EXIT_UNKNOWN_ERROR) if !$dest_resolved; 567 568 copy ($src, $dest_resolved) or 569 &my_die("failed to copy $src to $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 570 571 if ($replicate and (file_scheme($dest) eq 'neb')) { 572 my $neb = $ipprc->nebulous(); 573 $neb->setxattr($dest, 'user.copies', 2, 'create') or 574 &my_die("failed to set user.copies for $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 575 576 $neb->replicate($dest) or 577 &my_die("failed to replicate $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 578 } 579 } 580 515 581 sub my_die 516 582 { -
trunk/ippTools/share/magictool_toprocess_inputs.sql
r28768 r29493 3 3 magicRun.workdir, 4 4 rawExp.exp_id, 5 rawExp.exp_name, 6 rawExp.workdir AS raw_workdir, 5 7 rawExp.camera, 6 8 -- convert magic_id into a boolean value (1 or 0) -
trunk/ippTools/share/magictool_toprocess_tree.sql
r28768 r29493 3 3 magicRun.workdir, 4 4 rawExp.exp_id, 5 rawExp.exp_name, 6 rawExp.workdir AS raw_workdir, 5 7 rawExp.camera, 6 8 -- convert magic_id into a boolean value (1 or 0) … … 16 18 WHERE 17 19 magicRun.state = 'new' 20 AND (Label.active OR Label.active IS NULL) 18 21 -- WHERE hook %s 19 22 ORDER BY -
trunk/ippTools/share/magictool_totree.sql
r28768 r29493 18 18 AND magicTree.node IS NULL 19 19 AND magicRun.fault = 0 20 AND (Label.active OR Label.active IS NULL) -
trunk/ippTools/src/bgtool.c
r28941 r29493 658 658 } 659 659 660 if (!chipBackgroundImfileInsert(config->dbh, chip_bg_id, class_id, path_base, magicked, dtime_script,660 if (!chipBackgroundImfileInsert(config->dbh, chip_bg_id, class_id, path_base, "full", magicked, dtime_script, 661 661 hostname, quality, fault, ver_code, bg, bg_stdev, maskfrac_npix, 662 662 maskfrac_static, maskfrac_dynamic, maskfrac_magic, maskfrac_advisory)) { … … 1497 1497 } 1498 1498 1499 if (!warpBackgroundSkyfileInsert(config->dbh, warp_bg_id, skycell_id, path_base, magicked, dtime_script,1499 if (!warpBackgroundSkyfileInsert(config->dbh, warp_bg_id, skycell_id, path_base, "full", magicked, dtime_script, 1500 1500 hostname, quality, fault, ver_code, bg, bg_stdev, maskfrac_npix, 1501 1501 maskfrac_static, maskfrac_dynamic, maskfrac_magic, maskfrac_advisory)) { -
trunk/ippTools/src/magictool.c
r28768 r29493 50 50 static bool exposureMode(pxConfig *config); 51 51 52 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state );52 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state, psString setString); 53 53 static bool parseAndInsertNodeDeps(pxConfig *config, psS64 magic_id, const char *filename); 54 54 … … 131 131 132 132 psMetadata *queryWhere = psMetadataAlloc(); // WHERE conditions for everything else 133 PXOPT_COPY_S64(config->args, queryWhere, "-exp_id", " exp_id", "==");133 PXOPT_COPY_S64(config->args, queryWhere, "-exp_id", "rawExp.exp_id", "=="); 134 134 PXOPT_COPY_STR(config->args, queryWhere, "-select_filter", "rawExp.filter", "=="); 135 135 … … 394 394 // required 395 395 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false); 396 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 396 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 397 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 398 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 399 PXOPT_LOOKUP_BOOL(clearfault, config->args, "-clearfault", false); 400 401 psString setString = NULL; 402 if (fault || clearfault) { 403 psStringAppend(&setString, ", fault = %d", fault); 404 } 405 if (note) { 406 psStringAppend(&setString, ", note = '%s'", note); 407 } 397 408 398 409 if (state) { 399 410 // set detRun.state to state 400 return setmagicRunState(config, magic_id, state );411 return setmagicRunState(config, magic_id, state, setString); 401 412 } 402 413 … … 612 623 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 613 624 614 psString query = psStringCopy("UPDATE magicRun SET fault = 0 , state = 'new' WHEREfault != 0");625 psString query = psStringCopy("UPDATE magicRun SET fault = 0 WHERE state = 'new' AND fault != 0"); 615 626 616 627 if (psListLength(where->list)) { … … 1364 1375 } 1365 1376 1366 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state )1377 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state, psString setString) 1367 1378 { 1368 1379 PS_ASSERT_PTR_NON_NULL(state, false); … … 1380 1391 return false; 1381 1392 } 1382 1383 char *query = "UPDATE magicRun SET state = '%s' WHERE magic_id = %" PRId64; 1384 if (!p_psDBRunQueryF(config->dbh, query, state, magic_id)) { 1393 psString query = NULL; 1394 psStringAppend(&query, "UPDATE magicRun SET state = '%s'", state); 1395 if (setString) { 1396 psStringAppend(&query, setString); 1397 } 1398 psStringAppend(&query, " WHERE magic_id = %" PRId64, magic_id);; 1399 1400 // char *query = "UPDATE magicRun SET state = '%s' WHERE magic_id = %" PRId64; 1401 if (!p_psDBRunQuery(config->dbh, query)) { 1385 1402 psError(PS_ERR_UNKNOWN, false, 1386 1403 "failed to change state for magic_id %" PRId64, magic_id); -
trunk/ippTools/src/magictoolConfig.c
r28039 r29493 79 79 psMetadata *updaterunArgs = psMetadataAlloc(); 80 80 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-magic_id", 0, "define magictool ID (required)", 0); 81 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 81 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state (required)", NULL); 82 psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-set_fault", 0, "set fault code", 0); 83 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 84 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-clearfault", 0, "set fault to zero", NULL); 82 85 83 86 // -addinputskyfile
Note:
See TracChangeset
for help on using the changeset viewer.
