Changeset 23438
- Timestamp:
- Mar 19, 2009, 2:54:59 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
ippScripts/scripts/diff_skycell.pl (modified) (5 diffs)
-
ippTools/share/difftool_completed_runs.sql (modified) (1 diff)
-
ippTools/src/difftool.c (modified) (7 diffs)
-
ippTools/src/magicdstool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/diff_skycell.pl
r23435 r23438 95 95 my $tess_id; # Tesselation identifier 96 96 my $camera; # Camera 97 my $magicked_0; 98 my $magicked_1; 97 99 foreach my $file (@$files) { 98 100 if (defined $file->{template} and $file->{template}) { … … 103 105 $templateVariance = "PPSTACK.OUTPUT.VARIANCE"; 104 106 $templateSources = "PSPHOT.OUT.CMF.MEF"; ## this must be consistent with the value in stack_skycell.pl:161 107 # template is a stack so it doesn't need to be magicked 108 $magicked_1 = 1; 105 109 ## use an explicit stack name for psphot output objects 106 110 } else { … … 108 112 $templateVariance = "PSWARP.OUTPUT.VARIANCE"; 109 113 $templateSources = "PSWARP.OUTPUT.SOURCES"; 114 $magicked_1 = $file->{magicked}; 110 115 } 111 116 } else { 112 117 $input = $file->{uri}; 113 118 $inputPath = $file->{path_base}; 119 $magicked_0 = $file->{magicked}; # if input is a stack the output can't be "magicked" 114 120 if ($file->{warp_id} == 0) { 115 121 $inputMask = "PPSTACK.OUTPUT.MASK"; … … 146 152 &my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera; 147 153 $ipprc->define_camera($camera); 154 155 # Compute the magicked status of the output. 156 # The output file will be considered magicked if the input has been magicked and the 157 # template is either a stack or a warp that has been magicked. 158 # note that difftool -inputskyfile outputs the magicked boolean as an int not T or F 159 # because the output is constructed from a union of two selects 160 my $magicked = $magicked_0 && $magicked_1; 148 161 149 162 # Recipes to use based on reduction class … … 265 278 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -uri $outputName -path_base $outroot"; 266 279 $command .= " $cmdflags"; 280 $command .= " -magicked" if $magicked; 267 281 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 268 282 $command .= " -hostname $host" if defined $host; -
trunk/ippTools/share/difftool_completed_runs.sql
r20973 r23438 1 1 SELECT DISTINCT 2 diff_id 2 diff_id, 3 all_magicked as magicked 3 4 FROM ( 4 5 SELECT 5 6 COUNT(diffInputSkyfile.skycell_id), COUNT(diffSkyfile.skycell_id), 6 diffSkyfile.* 7 diffSkyfile.*, 8 SUM(!diffSkyfile.magicked) = 0 as all_magicked 7 9 FROM diffRun 8 10 JOIN diffInputSkyfile USING(diff_id) -
trunk/ippTools/src/difftool.c
r23388 r23438 48 48 static bool importrunMode(pxConfig *config); 49 49 50 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state );50 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked); 51 51 static bool diffRunComplete(pxConfig *config); 52 52 … … 169 169 if (state) { 170 170 // set detRun.state to state 171 return setdiffRunState(config, diff_id, state );171 return setdiffRunState(config, diff_id, state, false); 172 172 } 173 173 … … 283 283 284 284 if (count == 2) { 285 if (!setdiffRunState(config, diff_id, "new" )) {285 if (!setdiffRunState(config, diff_id, "new", false)) { 286 286 if (!psDBRollback(config->dbh)) { 287 287 psError(PS_ERR_UNKNOWN, false, "database error"); … … 732 732 733 733 734 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state )734 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked) 735 735 { 736 736 PS_ASSERT_PTR_NON_NULL(state, false); … … 742 742 } 743 743 744 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 745 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 744 char *query = "UPDATE diffRun SET state = '%s', magicked = %d WHERE diff_id = %"PRId64; 745 746 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 746 747 psError(PS_ERR_UNKNOWN, false, 747 748 "failed to change state for diff_id %"PRId64, diff_id); … … 1169 1170 query = NULL; 1170 1171 1171 if (!setdiffRunState(config, run->diff_id, "new" )) {1172 if (!setdiffRunState(config, run->diff_id, "new", false)) { 1172 1173 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1173 1174 run->diff_id); … … 1432 1433 1433 1434 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1435 bool magicked = psMetadataLookupBool(NULL, row, "magicked"); 1434 1436 1435 1437 // set diffRun.state to 'stop' 1436 if (!setdiffRunState(config, diff_id, "full" )) {1438 if (!setdiffRunState(config, diff_id, "full", magicked)) { 1437 1439 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1438 1440 diff_id); -
trunk/ippTools/src/magicdstool.c
r23389 r23438 40 40 41 41 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); 42 static bool magicDSRunComplete(pxConfig *config );42 static bool magicDSRunComplete(pxConfig *config, bool setmagicked); 43 43 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 44 44 … … 528 528 } 529 529 530 static bool 531 setRunMagicked(pxConfig *config, psS64 magic_ds_id) 532 { 533 // first query the magicDSRun to find the stage and the stage_id 534 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64; 535 536 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { 537 psError(PS_ERR_UNKNOWN, false, "database error"); 538 return false; 539 } 540 541 psArray *output = p_psDBFetchResult(config->dbh); 542 if (!output) { 543 psError(PS_ERR_UNKNOWN, false, "database error"); 544 return false; 545 } 546 if (!psArrayLength(output)) { 547 psError(PS_ERR_UNKNOWN, true, "magicDSRun not found for magic_ds_id %" PRId64, magic_ds_id); 548 psFree(output); 549 return false; 550 } 551 if (psArrayLength(output) > 1) { 552 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_ds_id %" PRId64, 553 psArrayLength(output), magic_ds_id); 554 psFree(output); 555 return false; 556 } 557 psMetadata *row = output->data[0]; 558 559 psString stage = psMetadataLookupStr(NULL, row, "stage"); 560 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 561 562 563 // chose the appropriate query based on the stage 564 if (!strcmp(stage, "raw")) { 565 query = "UPDATE rawExp SET magicked = 1 where exp_id = %" PRId64; 566 } else if (!strcmp(stage, "chip")) { 567 query = "UPDATE chipRun SET magicked = 1 where chip_id = %" PRId64; 568 } else if (!strcmp(stage, "warp")) { 569 query = "UPDATE warpRun SET magicked = 1 where warp_id = %" PRId64; 570 } else if (!strcmp(stage, "diff")) { 571 query = "UPDATE diffRun SET magicked = 1 where diff_id = %" PRId64; 572 } else { 573 psError(PS_ERR_UNKNOWN, true, "unexpected value for stage: %s found", stage); 574 psFree(output); 575 return false; 576 } 577 if (!p_psDBRunQueryF(config->dbh, query, stage_id)) { 578 psError(PS_ERR_UNKNOWN, false, "database error"); 579 return false; 580 } 581 psFree(output); 582 583 psU64 affected = psDBAffectedRows(config->dbh); 584 if (affected != 1) { 585 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 586 return false; 587 } 588 589 return true; 590 } 591 530 592 static bool adddestreakedfileMode(pxConfig *config) 531 593 { … … 553 615 554 616 if (setmagicked) { 617 // set the image file's magicked flag 555 618 if (!setMagicked(config, magic_ds_id, component)) { 556 619 psError(PS_ERR_UNKNOWN, false, "setMagicked failed"); 620 if (!psDBRollback(config->dbh)) { 621 psError(PS_ERR_UNKNOWN, false, "database error"); 622 } 557 623 return false; 558 624 } … … 568 634 } 569 635 570 if (!magicDSRunComplete(config )) {636 if (!magicDSRunComplete(config, setmagicked)) { 571 637 // rollback 572 638 if (!psDBRollback(config->dbh)) { … … 593 659 594 660 if (!strcmp(stage, "diff")) { 595 // don't need these ids for diff stage 661 // don't need these ids for diff stage because diff_id is in the magicRun 596 662 *stage_id = 0; 597 663 *cam_id = 0; … … 654 720 } 655 721 656 static bool magicDSRunComplete(pxConfig *config )722 static bool magicDSRunComplete(pxConfig *config, bool setmagicked) 657 723 { 658 724 PS_ASSERT_PTR_NON_NULL(config, false); … … 686 752 687 753 psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id"); 754 755 // if requested, set stageRun.magicked 756 if (setmagicked && !setRunMagicked(config, magic_ds_id)) { 757 psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64, 758 magic_ds_id); 759 return false; 760 } 688 761 689 762 // set magicDSRun.state to 'full'
Note:
See TracChangeset
for help on using the changeset viewer.
