Changeset 20973
- Timestamp:
- Dec 13, 2008, 10:17:34 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 38 edited
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/chip.md (modified) (1 diff)
-
dbconfig/config.md (modified) (1 diff)
-
dbconfig/diff.md (modified) (3 diffs)
-
dbconfig/magic.md (modified) (2 diffs)
-
dbconfig/tasks.md (modified) (2 diffs)
-
dbconfig/warp.md (modified) (4 diffs)
-
ippScripts/scripts/diff_skycell.pl (modified) (8 diffs)
-
ippTasks/diff.pro (modified) (3 diffs)
-
ippTasks/simtest.auto (modified) (1 diff)
-
ippTools/configure.ac (modified) (1 diff)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/difftool_completed_runs.sql (added)
-
ippTools/share/difftool_definebyquery.sql (modified) (3 diffs)
-
ippTools/share/difftool_definebyquery_part1.sql (added)
-
ippTools/share/difftool_definebyquery_part2.sql (added)
-
ippTools/share/difftool_definebyquery_temp_create.sql (added)
-
ippTools/share/difftool_inputskyfile.sql (modified) (4 diffs)
-
ippTools/share/difftool_skyfile.sql (modified) (2 diffs)
-
ippTools/share/difftool_todiffskyfile.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_completed_runs.sql (modified) (1 diff)
-
ippTools/share/magicdstool_getrunids.sql (modified) (1 diff)
-
ippTools/share/magicdstool_getskycells.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_todestreak.sql (modified) (2 diffs)
-
ippTools/share/magictool_definebyquery_insert.sql (modified) (1 diff)
-
ippTools/share/magictool_definebyquery_select.sql (modified) (1 diff)
-
ippTools/share/magictool_definebyquery_temp_insert.sql (modified) (1 diff)
-
ippTools/share/magictool_inputs.sql (modified) (2 diffs)
-
ippTools/share/magictool_inputskyfile.sql (modified) (1 diff)
-
ippTools/share/magictool_toprocess_inputs.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (10 diffs)
-
ippTools/share/warptool_tooverlap.sql (modified) (1 diff)
-
ippTools/src/chiptool.c (modified) (1 diff)
-
ippTools/src/difftool.c (modified) (27 diffs)
-
ippTools/src/difftoolConfig.c (modified) (7 diffs)
-
ippTools/src/magicdstool.c (modified) (1 diff)
-
ippTools/src/magictool.c (modified) (6 diffs)
-
ippTools/src/magictoolConfig.c (modified) (1 diff)
-
ippTools/src/pxwarp.c (modified) (1 diff)
-
ippTools/src/regtool.c (modified) (1 diff)
-
ippTools/src/warptool.c (modified) (4 diffs)
-
ippTools/src/warptoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/changes.txt
r20855 r20973 717 717 alter table magicDSRun add column cam_id BIGINT after stage_id; 718 718 719 -- Version: 1.1.47 720 721 -- WARNING WARNING WARNING 722 -- Updating a database which has populated diffRun's requires editing 723 -- the contents of the tables in a way that cannot be expresed here. 724 -- The script tools/collapsdiffinputs.pl does the appropriate edits 725 -- and should be run at the spot indicated below 726 727 -- fix order of workdir to match pxadmin_create_tables.sql 728 ALTER TABLE diffRun CHANGE COLUMN workdir workdir VARCHAR(255) AFTER state; 729 730 -- add exposure id to diffRun 731 ALTER TABLE diffRun ADD COLUMN exp_id BIGINT; 732 ALTER TABLE diffRun ADD FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id); 733 ALTER TABLE diffRun DROP COLUMN skycell_id; 734 735 736 -- drop exiting foreign key constraints 737 ALTER TABLE diffInputSkyfile drop FOREIGN KEY diffInputSkyfile_ibfk_1; 738 ALTER TABLE diffInputSkyfile drop FOREIGN KEY diffInputSkyfile_ibfk_2; 739 ALTER TABLE diffInputSkyfile drop FOREIGN KEY diffInputSkyfile_ibfk_3; 740 741 ALTER TABLE diffInputSkyfile DROP COLUMN kind; 742 ALTER TABLE diffInputSkyfile CHANGE COLUMN skycell_id skycell_id VARCHAR(64) AFTER diff_id; 743 744 -- WARNING WARNING 745 -- If you have existing diff runs they must be converted 746 747 -- run the script collapse_diffinputs.pl here. 748 -- collapse_diffinputs.pl dbname dbuser dbpass dbhost 749 750 DELETE FROM diffInputSkyfile where template = 1; 751 752 ALTER TABLE diffInputSkyfile DROP PRIMARY KEY; 753 ALTER TABLE diffInputSkyfile ADD PRIMARY KEY (diff_id, skycell_id); 754 ALTER TABLE diffInputSkyfile DROP COLUMN template; 755 756 ALTER TABLE diffInputSkyfile CHANGE COLUMN warp_id warp1 BIGINT; 757 ALTER TABLE diffInputSkyfile ADD COLUMN stack1 BIGINT AFTER warp1, ADD KEY(stack1); 758 ALTER TABLE diffInputSkyfile ADD COLUMN warp2 BIGINT AFTER stack1, ADD KEY(warp2); 759 ALTER TABLE diffInputSkyfile CHANGE COLUMN stack_id stack2 BIGINT AFTER warp2; 760 ALTER TABLE diffInputSkyfile ADD FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id); 761 762 # need to check these 763 ALTER TABLE diffInputSkyfile ADD FOREIGN KEY (warp1, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id); 764 ALTER TABLE diffInputSkyfile ADD FOREIGN KEY (warp2, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id); 765 766 ALTER TABLE diffInputSkyfile ADD FOREIGN KEY (stack1) REFERENCES stackRun(stack_id); 767 ALTER TABLE diffInputSkyfile ADD FOREIGN KEY (stack2) REFERENCES stackRun(stack_id); 768 769 -- add unique ids for each image and flags that indicate whether the image has been 770 -- magic destreaked 771 ALTER TABLE diffSkyfile ADD COLUMN skycell_id VARCHAR(64) AFTER diff_id; 772 ALTER TABLE diffSkyfile DROP PRIMARY KEY, ADD PRIMARY KEY (diff_id, skycell_id); 773 ALTER TABLE diffSkyfile ADD COLUMN diff_image_id BIGINT NOT NULL AUTO_INCREMENT, ADD KEY(diff_image_id); 774 ALTER TABLE diffSkyfile ADD COLUMN magicked TINYINT; 775 776 ALTER TABLE warpRun DROP COLUMN magiced; 777 778 ALTER TABLE warpSkyfile ADD COLUMN warp_image_id BIGINT NOT NULL AUTO_INCREMENT, ADD KEY(warp_image_id); 779 ALTER TABLE warpSkyfile ADD COLUMN magicked TINYINT; 780 781 ALTER TABLE chipProcessedImfile ADD COLUMN chip_image_id BIGINT NOT NULL AUTO_INCREMENT, ADD KEY(chip_image_id); 782 ALTER TABLE chipProcessedImfile ADD COLUMN magicked TINYINT; 783 784 ALTER TABLE rawImfile ADD COLUMN raw_image_id BIGINT NOT NULL AUTO_INCREMENT, ADD KEY(raw_image_id); 785 ALTER TABLE rawImfile ADD COLUMN magicked TINYINT; 786 787 -- magic adaptations to diff reorginization 788 ALTER TABLE magicRun ADD COLUMN diff_id BIGINT AFTER exp_id; 789 ALTER TABLE magicRun ADD CONSTRAINT FOREIGN KEY(diff_id) REFERENCES diffRun(diff_id); 790 ALTER TABLE magicRun ADD CONSTRAINT FOREIGN KEY(exp_id) REFERENCES rawExp(exp_id); 791 ALTER TABLE magicInputSkyfile DROP PRIMARY KEY, ADD PRIMARY KEY(magic_id, diff_id, node); 792 -
trunk/dbconfig/chip.md
r20240 r20973 81 81 path_base STR 255 82 82 fault S16 0 # Key NOT NULL 83 chip_image_id S64 0 # Key AUTO_INCREMENT 84 magicked BOOL f 83 85 END 84 86 -
trunk/dbconfig/config.md
r20275 r20973 2 2 pkg_name STR ippdb 3 3 pkg_namespace STR ippdb 4 pkg_version STR 1.1.4 64 pkg_version STR 1.1.47 5 5 END -
trunk/dbconfig/diff.md
r20061 r20973 1 # $Id: diff.md,v 1.1 4 2008-10-11 02:33:40 priceExp $1 # $Id: diff.md,v 1.15 2008-12-13 20:17:34 bills Exp $ 2 2 3 3 diffRun METADATA 4 4 diff_id S64 0 # Primary Key AUTO_INCREMENT 5 5 state STR 64 # Key 6 workdir STR 255 6 7 label STR 64 # Key 7 8 reduction STR 64 # Reduction class 8 workdir STR 2559 9 dvodb STR 255 10 10 registered TAI NULL 11 skycell_id STR 64 # Key12 11 tess_id STR 64 # Key 12 exp_id S64 0 # fkey(exp_id) ref rawExp(exp_id) 13 13 END 14 14 … … 17 17 # 18 18 19 # only ever 2 per run - one template / one not20 19 diffInputSkyfile METADATA 21 20 diff_id S64 0 # Primary Key fkey(diff_id) ref diffRun(diff_id) 22 template BOOL f # Primary Key 23 stack_id S64 0 # fkey(stack_id) ref stackSumSkyfile(stack_id) 24 warp_id S64 0 # fkey(warp_id, skycell_id, tess_id) ref warpSkyfile(warp_id, skycell_id, tess_id) 25 skycell_id STR 64 # Key 21 skycell_id STR 64 # Primary Key 22 warp1 S64 0 # fkey(warp1, skycell_id, tess_id) ref warpSkyfile(warp_id, skycell_id, tess_id) 23 stack1 S64 0 # fkey(stack1) ref stackSumSkyfile(stack_id) 24 warp2 S64 0 # fkey(warp2, skycell_id, tess_id) ref warpSkyfile(warp_id, skycell_id, tess_id) 25 stack2 S64 0 # fkey(stack2) ref stackSumSkyfile(stack_id) 26 26 tess_id STR 64 # Key 27 # either a input or a template28 kind STR 64 # Key29 27 END 30 28 31 29 diffSkyfile METADATA 32 30 diff_id S64 0 # Primary Key fkey(diff_id) ref diffRun(diff_id) 31 skycell_id STR 64 # 33 32 uri STR 255 34 33 path_base STR 255 … … 53 52 good_frac F32 0.0 # Key 54 53 fault S16 0 # Key 54 diff_image_id S64 0 # Key NOT NULL AUTO_INCREMENT 55 magicked BOOL f 55 56 END -
trunk/dbconfig/magic.md
r20841 r20973 1 # $Id: magic.md,v 1.1 2 2008-11-26 03:21:13bills Exp $1 # $Id: magic.md,v 1.13 2008-12-13 20:17:34 bills Exp $ 2 2 3 3 ### Fault in magicRun indicates that the processing tree failed … … 5 5 magic_id S64 0 # Primary Key AUTO_INCREMENT 6 6 exp_id S64 0 # Key 7 diff_id S64 0 # Key 7 8 state STR 64 # Key 8 9 workdir STR 255 -
trunk/dbconfig/tasks.md
r20608 r20973 1 # $Id: tasks.md,v 1.15 8 2008-11-09 23:51:01 priceExp $1 # $Id: tasks.md,v 1.159 2008-12-13 20:17:34 bills Exp $ 2 2 3 3 # this table records all exposure ID ever seen from the summit … … 239 239 fault S16 0 # Key NOT NULL 240 240 epoch UTC 0001-01-01T00:00:00Z 241 END 241 magicked BOOL f 242 END -
trunk/dbconfig/warp.md
r19930 r20973 1 # $Id: warp.md,v 1. 19 2008-10-07 00:01:28 priceExp $1 # $Id: warp.md,v 1.20 2008-12-13 20:17:34 bills Exp $ 2 2 3 3 # … … 11 11 warpRun METADATA 12 12 warp_id S64 0 # Primary Key AUTO_INCREMENT 13 fake_id S64 0 # Key INDEX(warp_id, fake_id) fkey(fake_id) ref camProcessedExp(fake_id)13 fake_id S64 0 # Key INDEX(warp_id, fake_id) fkey(fake_id) ref camProcessedExp(fake_id) 14 14 mode STR 64 # Key 15 15 state STR 64 # Key … … 22 22 registered TAI NULL 23 23 # if magic is T then look for the exp_id in the magic output tables 24 magiced BOOL f # Key25 24 END 26 25 … … 52 51 ignored BOOL f # Key 53 52 fault S16 0 # Key 53 warp_image_id S64 0 # Key AUTO_INCREMENT 54 magicked BOOL f 54 55 END 55 56 -
trunk/ippScripts/scripts/diff_skycell.pl
r20928 r20973 27 27 use Pod::Usage qw( pod2usage ); 28 28 29 my ($diff_id, $diff_skyfile_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect); 29 my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect); 30 my $skycell_id; # Skycell identifier 30 31 GetOptions( 31 'diff_id |d=s' => \$diff_id, # Diff identifier32 ' diff_skyfile_id|d=s' => \$diff_skyfile_id, # Unique skyfileidentifier33 'dbname|d=s' => \$dbname, # Database name34 'threads=s' => \$threads, # Number of threads to use35 'outroot=s' => \$outroot, # Output root name36 'reduction=s' => \$reduction, # Reduction class37 'verbose' => \$verbose, # Print to stdout38 'no-update' => \$no_update, # Don't update the database?39 'no-op' => \$no_op, # Don't do any operations?40 'redirect-output' => \$redirect,32 'diff_id=s' => \$diff_id, # Diff identifier 33 'skycell_id=s' => \$skycell_id, # Diff identifier 34 'dbname|d=s' => \$dbname, # Database name 35 'threads=s' => \$threads, # Number of threads to use 36 'outroot=s' => \$outroot, # Output root name 37 'reduction=s' => \$reduction, # Reduction class 38 'verbose' => \$verbose, # Print to stdout 39 'no-update' => \$no_update, # Don't update the database? 40 'no-op' => \$no_op, # Don't do any operations? 41 'redirect-output' => \$redirect, 41 42 ) or pod2usage( 2 ); 42 43 43 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 45 pod2usage( 45 -msg => "Required options: --diff_id -- outroot",46 -msg => "Required options: --diff_id --skycell_id --outroot", 46 47 -exitval => 3, 47 48 ) unless defined $diff_id 49 and defined $skycell_id 48 50 and defined $outroot; 49 51 … … 53 55 my $logDest = "$outroot.log"; 54 56 $ipprc->redirect_output($logDest) if $redirect; 55 56 my $image_id = $diff_skyfile_id;57 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF);58 57 59 58 # Look for programs we need … … 71 70 my $files; 72 71 { 73 my $command = "$difftool -inputskyfile -diff_id $diff_id ";72 my $command = "$difftool -inputskyfile -diff_id $diff_id -skycell_id $skycell_id"; 74 73 $command .= " -dbname $dbname" if defined $dbname; 75 74 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 93 92 my ($template, $templateMask, $templateWeight, $templatePath, $templateSources); # Template files and path 94 93 my $tess_id; # Tesselation identifier 95 my $skycell_id; # Skycell identifier96 94 my $camera; # Camera 97 95 foreach my $file (@$files) { … … 214 212 $command .= " -dumpconfig $configuration"; 215 213 $command .= " -dbname $dbname" if defined $dbname; 216 # $command .= " -image_id $image_id" if defined $image_id;217 # $command .= " -source_id $source_id" if defined $source_id;218 214 219 215 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 226 222 &my_die("Couldn't find expected output file: $outputMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 227 223 &my_die("Couldn't find expected output file: $outputWeight", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 228 &my_die("Couldn't find expected output file: $outputSources", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);224 # &my_die("Couldn't find expected output file: $outputSources", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 229 225 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name); 230 226 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name); … … 251 247 # Add the subtraction result 252 248 { 253 my $command = "$difftool -adddiffskyfile -diff_id $diff_id - uri $outputName -path_base $outroot";249 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -uri $outputName -path_base $outroot"; 254 250 $command .= " $cmdflags"; 255 251 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); … … 275 271 warn($msg); 276 272 if (defined $diff_id and not $no_update) { 277 my $command = "$difftool -adddiffskyfile -diff_id $diff_id - code $exit_code";273 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -code $exit_code"; 278 274 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 279 275 $command .= " -hostname $host" if defined $host; -
trunk/ippTasks/diff.pro
r20932 r20973 98 98 task.exit 0 99 99 # convert 'stdout' to book format 100 ipptool2book stdout diffSkyfile -key diff_id -uniq -setword dbname $options:0 -setword pantaskState INIT100 ipptool2book stdout diffSkyfile -key diff_id:skycell_id -uniq -setword dbname $options:0 -setword pantaskState INIT 101 101 if ($VERBOSE > 2) 102 102 book listbook diffSkyfile … … 157 157 stderr $LOGDIR/diff.skycell.log 158 158 159 $run = diff_skycell.pl --threads @MAX_THREADS@ --diff_id $DIFF_ID -- diff_skyfile_id $DIFF_SKYFILE_ID --outroot $outroot --redirect-output159 $run = diff_skycell.pl --threads @MAX_THREADS@ --diff_id $DIFF_ID --skycell_id $SKYCELL_ID --outroot $outroot --redirect-output 160 160 add_standard_args run 161 161 … … 215 215 task.exit 0 216 216 # convert 'stdout' to book format 217 ipptool2book stdout diffCleanup -key diff_id -uniq -setword dbname $options:0 -setword pantaskState INIT217 ipptool2book stdout diffCleanup -key diff_id:skycell_id -uniq -setword dbname $options:0 -setword pantaskState INIT 218 218 if ($VERBOSE > 2) 219 219 book listbook diffCleanup -
trunk/ippTasks/simtest.auto
r20909 r20973 70 70 END 71 71 72 ### #Magic automation???72 ### Magic automation??? 73 73 #automate METADATA 74 74 # name STR MAGIC 75 # regular STR "magictool -definebyquery -workdir file://@CWD@/magic - good_frac 0.2 -dbname @DBNAME@"75 # regular STR "magictool -definebyquery -workdir file://@CWD@/magic -dbname @DBNAME@" 76 76 #END 77 78 77 79 78 -
trunk/ippTools/configure.ac
r20276 r20973 18 18 PKG_CHECK_MODULES([PSLIB], [pslib >= 1.1.0]) 19 19 PKG_CHECK_MODULES([PSMODULES], [psmodules >= 1.1.0]) 20 PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.4 6])20 PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.47]) 21 21 22 22 PXTOOLS_CFLAGS="${PSLIB_CFLAGS=} ${PSMODULES_CFLAGS=} ${IPPDB_CFLAGS=}" -
trunk/ippTools/share/Makefile.am
r20841 r20973 70 70 dettool_toresidimfile.sql \ 71 71 dettool_tostacked.sql \ 72 difftool_definebyquery.sql \ 72 difftool_completed_runs.sql \ 73 difftool_definebyquery_part1.sql \ 74 difftool_definebyquery_part2.sql \ 75 difftool_definebyquery_temp_create.sql \ 73 76 difftool_donecleanup.sql \ 74 77 difftool_inputskyfile.sql \ -
trunk/ippTools/share/difftool_definebyquery.sql
r20682 r20973 9 9 warpsToDiff.good_frac, 10 10 warpsToDiff.diff_id, 11 warpsToDiff.kind,12 11 current_stack_id, 13 best_stack_id 12 best_stack_id, 13 exp_id 14 14 FROM ( 15 15 -- Get list of warps that can be diffed, with any associated diff … … 23 23 warpRun.label as warp_label, 24 24 diffInputs.diff_id, 25 diffInputs. kind,26 diffTemplates.stack_id AS current_stack_id25 diffInputs.stack2 AS current_stack_id, 26 rawExp.exp_id 27 27 FROM warpSkyfile 28 28 JOIN warpRun USING(warp_id) … … 33 33 -- Check if it has an associated diff 34 34 LEFT JOIN diffInputSkyfile AS diffInputs 35 ON diffInputs.warp _id= warpSkyfile.warp_id35 ON diffInputs.warp1 = warpSkyfile.warp_id 36 36 AND diffInputs.skycell_id = warpSkyfile.skycell_id 37 AND diffInputs.template = 0 -- only join input files 38 -- Get the stack_id currently used as a template, if any 39 LEFT JOIN diffInputSkyfile AS diffTemplates 40 ON diffTemplates.diff_id = diffInputs.diff_id 41 AND diffTemplates.template != 0 -- only join template files 37 AND diffInputs.stack2 IS NOT NULL 42 38 WHERE 43 39 warpSkyfile.fault = 0 -
trunk/ippTools/share/difftool_inputskyfile.sql
r19582 r20973 1 1 SELECT * FROM 2 (SELECT 2 (SELECT 3 -- warp input 3 4 diffRun.diff_id, 4 diff Run.skycell_id,5 diff Run.tess_id,5 diffInputSkyfile.skycell_id, 6 diffInputSkyfile.tess_id, 6 7 0 as stack_id, 7 8 warpSkyfile.warp_id, 8 9 warpSkyfile.uri, 9 10 warpSkyfile.path_base, 10 diffInputSkyfile.template,11 0 as template, 11 12 rawExp.camera 12 13 FROM diffRun … … 14 15 USING(diff_id) 15 16 JOIN warpSkyfile 16 ON diffInputSkyfile.warp _id= warpSkyfile.warp_id17 ON diffInputSkyfile.warp1 = warpSkyfile.warp_id 17 18 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 18 19 AND diffInputSkyfile.tess_id = warpSkyfile.tess_id 19 20 JOIN warpRun 20 ON diffInputSkyfile.warp_id = warpRun.warp_id 21 ON diffInputSkyfile.warp1 = warpRun.warp_id 22 JOIN fakeRun 23 USING(fake_id) 24 JOIN camRun 25 USING(cam_id) 26 JOIN chipRun 27 USING(chip_id) 28 JOIN chipProcessedImfile 29 USING(chip_id) 30 JOIN rawExp 31 ON chipRun.exp_id = rawExp.exp_id 32 WHERE 33 diffRun.state = 'new' 34 AND warpRun.state = 'full' 35 AND fakeRun.state = 'full' 36 AND camRun.state = 'full' 37 AND chipRun.state = 'full' 38 -- where hook %s 39 UNION 40 SELECT 41 -- warp template 42 diffRun.diff_id, 43 diffInputSkyfile.skycell_id, 44 diffInputSkyfile.tess_id, 45 0 as stack_id, 46 warpSkyfile.warp_id, 47 warpSkyfile.uri, 48 warpSkyfile.path_base, 49 0 as template, 50 rawExp.camera 51 FROM diffRun 52 JOIN diffInputSkyfile 53 USING(diff_id) 54 JOIN warpSkyfile 55 ON diffInputSkyfile.warp2 = warpSkyfile.warp_id 56 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 57 AND diffInputSkyfile.tess_id = warpSkyfile.tess_id 58 JOIN warpRun 59 ON diffInputSkyfile.warp2 = warpRun.warp_id 21 60 JOIN fakeRun 22 61 USING(fake_id) … … 38 77 UNION 39 78 SELECT 79 -- stack input 40 80 diffRun.diff_id, 41 diff Run.skycell_id,42 diff Run.tess_id,81 diffInputSkyfile.skycell_id, 82 diffInputSkyfile.tess_id, 43 83 stackSumSkyfile.stack_id, 44 84 0 as warp_id, 45 85 stackSumSkyfile.uri, 46 86 stackSumSkyfile.path_base, 47 diffInputSkyfile.template,87 1 as template, 48 88 rawExp.camera 49 89 FROM diffRun … … 51 91 USING(diff_id) 52 92 JOIN stackSumSkyfile 53 ON diffInputSkyfile.stack_id = stackSumSkyfile.stack_id 54 JOIN stackInputSkyfile 55 ON diffInputSkyfile.stack_id = stackInputSkyfile.stack_id 56 JOIN warpRun 57 ON stackInputSkyfile.warp_id = warpRun.warp_id 58 JOIN fakeRun 59 USING(fake_id) 60 JOIN camRun 61 USING(cam_id) 62 JOIN chipRun 63 USING(chip_id) 64 JOIN chipProcessedImfile 65 USING(chip_id) 93 ON diffInputSkyfile.stack1 = stackSumSkyfile.stack_id 66 94 JOIN rawExp 67 ON chipRun.exp_id = rawExp.exp_id95 USING(exp_id) 68 96 WHERE 69 97 diffRun.state = 'new' 70 AND warpRun.state = 'full' 71 AND fakeRun.state = 'full' 72 AND camRun.state = 'full' 73 AND chipRun.state = 'full' 98 -- where hook %s 99 UNION 100 SELECT 101 -- stack template 102 diffRun.diff_id, 103 diffInputSkyfile.skycell_id, 104 diffInputSkyfile.tess_id, 105 stackSumSkyfile.stack_id, 106 0 as warp_id, 107 stackSumSkyfile.uri, 108 stackSumSkyfile.path_base, 109 1 as template, 110 rawExp.camera 111 FROM diffRun 112 JOIN diffInputSkyfile 113 USING(diff_id) 114 JOIN stackSumSkyfile 115 ON diffInputSkyfile.stack2 = stackSumSkyfile.stack_id 116 JOIN rawExp 117 USING(exp_id) 118 WHERE 119 diffRun.state = 'new' 74 120 -- where hook %s 75 121 ) as Foo -
trunk/ippTools/share/difftool_skyfile.sql
r20694 r20973 1 1 SELECT 2 diff Run.skycell_id,2 diffSkyfile.*, 3 3 diffRun.tess_id, 4 4 diffRun.state, 5 diffSkyfile.*, 6 (SELECT warp_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 7 AND diffInputSkyfile.template = 0 ) AS warp_id_temp_0, 8 (SELECT stack_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 9 AND diffInputSkyfile.template = 0 ) AS stack_id_temp_0, 10 (SELECT warp_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 11 AND diffInputSkyfile.template = 1 ) AS warp_id_temp_1, 12 (SELECT stack_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 13 AND diffInputSkyfile.template = 1 ) AS stack_id_temp_1 5 warp1, 6 stack1, 7 warp2, 8 stack2 9 -- (SELECT warp_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 10 -- AND diffInputSkyfile.template = 0 ) AS warp_id_temp_0, 11 -- (SELECT stack_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 12 -- AND diffInputSkyfile.template = 0 ) AS stack_id_temp_0, 13 -- (SELECT warp_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 14 -- AND diffInputSkyfile.template = 1 ) AS warp_id_temp_1, 15 -- (SELECT stack_id FROM diffInputSkyfile WHERE diffInputSkyfile.diff_id = diffRun.diff_id 16 -- AND diffInputSkyfile.template = 1 ) AS stack_id_temp_1 14 17 FROM diffRun 15 18 JOIN diffSkyfile … … 17 20 JOIN diffInputSkyfile 18 21 ON diffInputSkyfile.diff_id = diffRun.diff_id 19 AND diffInputSkyfile.template = 020 22 JOIN warpRun 21 USING(warp_id) 22 JOIN fakeRun 23 USING(fake_id) 24 JOIN camRun 25 USING(cam_id) 26 JOIN chipRun 27 USING(chip_id) 23 ON warpRun.warp_id = diffInputSkyfile.warp1 28 24 JOIN rawExp 29 25 USING(exp_id) -
trunk/ippTools/share/difftool_todiffskyfile.sql
r20934 r20973 6 6 0 as diff_skyfile_id, 7 7 diffRun.workdir, 8 diff Run.skycell_id,8 diffInputSkyfile.skycell_id, 9 9 diffRun.tess_id, 10 10 diffRun.label, 11 11 diffRun.state 12 12 FROM diffRun 13 JOIN diffInputSkyfile USING(diff_id) 14 13 15 -- Get list of templates for each diffRun 14 JOIN diffInputSkyfile AS diffTemplateSkyfile15 ON diffRun.diff_id = diffTemplateSkyfile.diff_id16 AND diffRun.skycell_id = diffTemplateSkyfile.skycell_id17 AND diffTemplateSkyfile.template = 116 -- JOIN diffInputSkyfile AS diffTemplateSkyfile 17 -- ON diffRun.diff_id = diffTemplateSkyfile.diff_id 18 -- AND diffRun.skycell_id = diffTemplateSkyfile.skycell_id 19 -- AND diffTemplateSkyfile.template = 1 18 20 -- Get list of inputs for each diffRun 19 JOIN diffInputSkyfile 20 ON diffRun.diff_id = diffInputSkyfile.diff_id 21 AND diffRun.skycell_id = diffInputSkyfile.skycell_id 22 AND diffInputSkyfile.template = 0 21 -- JOIN diffInputSkyfile 22 -- ON diffRun.diff_id = diffInputSkyfile.diff_id 23 -- AND diffRun.skycell_id = diffInputSkyfile.skycell_id 24 -- AND diffInputSkyfile.template = 0 25 23 26 -- Get warp templates 24 27 LEFT JOIN warpRun AS warpTemplateRun 25 ON warpTemplateRun.warp_id = diff TemplateSkyfile.warp_id26 AND diff TemplateSkyfile.warp_idIS NOT NULL28 ON warpTemplateRun.warp_id = diffInputSkyfile.warp2 29 AND diffInputSkyfile.warp2 IS NOT NULL 27 30 LEFT JOIN warpSkyfile AS warpTemplateSkyfile 28 31 ON warpTemplateSkyfile.warp_id = warpTemplateRun.warp_id 29 AND warpTemplateSkyfile.skycell_id = diffTemplateSkyfile.skycell_id 32 AND warpTemplateSkyfile.skycell_id = diffInputSkyfile.skycell_id 33 30 34 -- Get warp inputs 31 35 LEFT JOIN warpRun 32 ON warpRun.warp_id = diffInputSkyfile.warp _id33 AND diffInputSkyfile.warp _idIS NOT NULL36 ON warpRun.warp_id = diffInputSkyfile.warp1 37 AND diffInputSkyfile.warp1 IS NOT NULL 34 38 LEFT JOIN warpSkyfile 35 39 ON warpSkyfile.warp_id = warpRun.warp_id 36 40 AND warpSkyfile.skycell_id = diffInputSkyfile.skycell_id 41 37 42 -- Get stack templates 38 43 LEFT JOIN stackRun AS stackTemplateRun 39 ON stackTemplateRun.stack_id = diffTemplateSkyfile.stack_id 44 ON stackTemplateRun.stack_id = diffInputSkyfile.stack2 45 AND diffInputSkyfile.stack2 IS NOT NULL 40 46 LEFT JOIN stackSumSkyfile AS stackTemplateSkyfile 41 47 ON stackTemplateSkyfile.stack_id = stackTemplateRun.stack_id 48 42 49 -- Get stack inputs 43 50 LEFT JOIN stackRun 44 ON stackRun.stack_id = diffInputSkyfile.stack _id45 AND diffInputSkyfile. warp_id ISNULL51 ON stackRun.stack_id = diffInputSkyfile.stack1 52 AND diffInputSkyfile.stack1 IS NOT NULL 46 53 LEFT JOIN stackSumSkyfile 47 54 ON stackSumSkyfile.stack_id = stackRun.stack_id 48 AND diffInputSkyfile.warp_id IS NULL 55 49 56 -- Get what's already been processed 50 57 LEFT JOIN diffSkyfile 51 58 ON diffInputSkyfile.diff_id = diffSkyfile.diff_id 59 AND diffInputSkyfile.skycell_id = diffSkyfile.skycell_id 52 60 WHERE 53 61 -- Ready to be processed … … 58 66 ) 59 67 -- Ensure input warps are available 60 AND (diffInputSkyfile.warp _idIS NULL68 AND (diffInputSkyfile.warp1 IS NULL 61 69 OR (warpRun.state = 'full' 62 70 AND warpSkyfile.fault = 0 63 71 AND warpSkyfile.ignored = 0)) 64 72 -- Ensure input stacks are available 65 AND (diffInputSkyfile.stack _idIS NULL73 AND (diffInputSkyfile.stack1 IS NULL 66 74 OR (stackRun.state = 'full' 67 75 AND stackSumSkyfile.fault = 0)) 68 76 -- Ensure template warps are available 69 AND (diff TemplateSkyfile.warp_idIS NULL77 AND (diffInputSkyfile.warp2 IS NULL 70 78 OR (warpTemplateRun.state = 'full' 71 79 AND warpTemplateSkyfile.fault = 0 72 80 AND warpTemplateSkyfile.ignored = 0)) 73 81 -- Ensure template stacks are available 74 AND (diff TemplateSkyfile.stack_idIS NULL82 AND (diffInputSkyfile.stack2 IS NULL 75 83 OR (stackTemplateRun.state = 'full' 76 84 AND stackTemplateSkyfile.fault = 0)) -
trunk/ippTools/share/magicdstool_completed_runs.sql
r20841 r20973 65 65 JOIN magicRun USING (magic_id) 66 66 JOIN magicInputSkyfile USING(magic_id) 67 -- Do we really need to join back to diffInputSkyfile here? 68 JOIN diffRun USING(diff_id) 69 JOIN diffSkyfile USING(diff_id) 70 JOIN diffInputSkyfile USING(diff_id) 67 JOIN diffSkyfile 68 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 69 AND magicInputSkyfile.node = diffSkyfile.skycell_id 71 70 LEFT JOIN magicDSFile 72 71 ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id 73 AND magicDSFile.component = diff InputSkyfile.skycell_id72 AND magicDSFile.component = diffSkyfile.skycell_id 74 73 WHERE 75 74 magicDSRun.state = 'run' 76 75 AND magicDSRun.stage = 'diff' 77 AND diffRun.state = 'full'78 76 AND diffSkyfile.fault = 0 79 77 GROUP BY -
trunk/ippTools/share/magicdstool_getrunids.sql
r20846 r20973 8 8 FROM magicRun 9 9 JOIN magicInputSkyfile USING(magic_id) 10 JOIN diffInputSkyfile USING(diff_id) 11 JOIN warpRun USING(warp_id) 10 JOIN diffSkyfile 11 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 12 AND magicInputSkyfile.node = diffSkyfile.skycell_id 13 JOIN diffInputSkyfile 14 ON diffInputSkyfile.diff_id = diffSkyfile.diff_id 15 AND diffInputSkyfile.skycell_id = diffSkyfile.skycell_id 16 JOIN warpRun 17 ON diffInputSkyfile.warp1 = warp_id 12 18 JOIN fakeRun USING(fake_id) 13 19 JOIN camRun USING(cam_id) 14 20 JOIN chipRun USING(chip_id) 15 WHERE template = 0 16 AND magic_id = %ld 21 WHERE magic_id = %ld -
trunk/ippTools/share/magicdstool_getskycells.sql
r20782 r20973 1 1 SELECT DISTINCT 2 2 diffSkyfile.diff_id, 3 diff Run.skycell_id,3 diffSkyfile.skycell_id, 4 4 diffSkyfile.uri, 5 5 diffSkyfile.path_base 6 6 FROM magicDSRun 7 7 JOIN magicRun USING(magic_id) 8 JOIN magicInputSkyfile USING(magic_id) 9 JOIN diffRun USING(diff_id) 10 JOIN diffSkyfile USING(diff_id) 8 JOIN magicInputSkyfile USING(magic_id, diff_id) 9 JOIN diffSkyfile 10 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 11 AND magicInputSkyfile.node = diffSkyfile.skycell_id 11 12 JOIN diffInputSkyfile 12 ON diffInputSkyfile.diff_id = diff Run.diff_id13 AND diffInputSkyfile.skycell_id = diff Run.skycell_id13 ON diffInputSkyfile.diff_id = diffSkyfile.diff_id 14 AND diffInputSkyfile.skycell_id = diffSkyfile.skycell_id 14 15 -- Want input warps only 15 AND diffInputSkyfile.warp_id IS NOT NULL 16 AND diffInputSkyfile.template = 0 16 AND diffInputSkyfile.warp1 IS NOT NULL 17 17 JOIN warpSkyCellMap 18 ON warpSkyCellMap.warp_id = diffInputSkyfile.warp _id18 ON warpSkyCellMap.warp_id = diffInputSkyfile.warp1 19 19 AND warpSkyCellMap.skycell_id = diffInputSkyfile.skycell_id 20 20 JOIN warpSkyfile … … 23 23 AND warpSkyfile.ignored = 0 24 24 WHERE 25 diffRun.state = 'full' 26 AND diffSkyfile.fault = 0 25 diffSkyfile.fault = 0 27 26 AND magic_ds_id = %lld -
trunk/ippTools/share/magicdstool_todestreak.sql
r20841 r20973 106 106 magicMask.uri as streaks_uri, 107 107 stage, 108 diff_id as stage_id,109 diff InputSkyfile.skycell_id as component,108 magicRun.diff_id as stage_id, 109 diffSkyfile.skycell_id as component, 110 110 diffSkyfile.uri, 111 111 diffSkyfile.path_base, … … 120 120 JOIN magicDSRun USING(magic_id) 121 121 JOIN magicInputSkyfile USING(magic_id) 122 JOIN diff Run USING(diff_id)123 JOIN diffSkyfile USING(diff_id) 124 JOIN diffInputSkyfile USING(diff_id) 122 JOIN diffSkyfile 123 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 124 AND magicInputSkyfile.node = diffSkyfile.skycell_id 125 125 LEFT JOIN magicDSFile 126 126 ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id 127 AND magicDSFile.component = diff InputSkyfile.skycell_id127 AND magicDSFile.component = diffSkyfile.skycell_id 128 128 WHERE 129 129 magicDSRun.state = 'run' 130 130 AND magicDSRun.stage = 'diff' 131 AND diffRun.state = 'full'132 131 AND diffSkyfile.fault = 0 133 132 AND magicDSFile.component IS NULL -
trunk/ippTools/share/magictool_definebyquery_insert.sql
r18700 r20973 5 5 diff_id, 6 6 skycell_id 7 FROM magicBestDiffs7 FROM diffSkyfile 8 8 WHERE 9 exp_id = @EXP_ID@ -- Update this with the appropriate exp_id 9 diff_id = @DIFF_ID@ -- Update this with the appropriate diff_id 10 AND fault = 0 -
trunk/ippTools/share/magictool_definebyquery_select.sql
r20742 r20973 1 1 -- Get a list of exposures on which magic may be performed 2 SELECT DISTINCT2 SELECT 3 3 exp_id, 4 filter, 5 num_todo, 6 num_done, 7 MAX(magic_id) 8 FROM ( 9 -- Number of skycells as a function of exposure 10 SELECT 11 exp_id, 12 filter, 13 COUNT(DISTINCT warpSkyfile.tess_id,warpSkyfile.skycell_id) AS num_todo 14 FROM rawExp 15 JOIN chipRun USING(exp_id) 16 JOIN camRun USING(chip_id) 17 JOIN fakeRun USING(cam_id) 18 JOIN warpRun USING(fake_id) 19 JOIN warpSkyCellMap USING(warp_id) 20 JOIN warpSkyfile USING(warp_id, skycell_id) 21 JOIN diffInputSkyfile USING(warp_id,skycell_id) 22 JOIN diffRun USING(diff_id) 23 WHERE 24 warpSkyfile.ignored = 0 25 -- magicSkycellNums WHERE hook %s 26 GROUP BY 27 exp_id 28 ) AS magicSkycellNums 29 JOIN ( 30 -- Number of completed diffs for an exposure 31 SELECT 32 exp_id, 33 COUNT(diff_id) AS num_done 34 FROM magicBestDiffs 35 GROUP BY 36 exp_id 37 ) AS magicDiffNums USING(exp_id) 4 MAX(diffRun.diff_id) AS diff_id 5 FROM diffRun 6 JOIN rawExp USING(exp_id) 38 7 LEFT JOIN magicRun USING(exp_id) 8 -- WHERE hook %s 9 GROUP BY exp_id -
trunk/ippTools/share/magictool_definebyquery_temp_insert.sql
r20738 r20973 14 14 JOIN warpSkyfile USING(warp_id, skycell_id) 15 15 JOIN diffInputSkyfile 16 ON diffInputSkyfile.warp _id= warpSkyfile.warp_id16 ON diffInputSkyfile.warp1 = warpSkyfile.warp_id 17 17 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 18 AND diffInputSkyfile.template = 0 -- selecting inputs only19 18 JOIN diffRun USING(diff_id) 20 19 JOIN diffSkyfile USING(diff_id) -
trunk/ippTools/share/magictool_inputs.sql
r20695 r20973 10 10 diffSkyfile.path_base, 11 11 diffSkyfile.fault 12 FROM magicInputSkyfile 12 FROM magicRun 13 JOIN magicInputSkyfile 14 USING(magic_id) 13 15 JOIN diffSkyfile 14 USING(diff_id) 15 JOIN magicRun 16 USING(magic_id) 16 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 17 AND magicInputSkyfile.node = diffSkyfile.skycell_id 17 18 UNION 18 19 -- Merged skycells … … 21 22 magicRun.state, 22 23 magicTree.node, 23 0, 24 0, -- no diff_id 24 25 magicNodeResult.uri, 25 26 NULL, -- magicNodeResult doesn't have a path_base -
trunk/ippTools/share/magictool_inputskyfile.sql
r20696 r20973 2 2 magicInputSkyfile.*, 3 3 diffSkyfile.uri 4 FROM magic InputSkyfile5 JOIN magic Run4 FROM magicRun 5 JOIN magicInputSkyfile 6 6 USING(magic_id) 7 7 JOIN diffSkyfile 8 USING(diff_id) 8 ON magicInputSkyfile.diff_id = diffSkyfile.diff_id 9 AND magicInputSkyfile.node = diffSkyfile.skycell_id 9 10 WHERE 10 11 magicRun.state = 'run' -
trunk/ippTools/share/magictool_toprocess_inputs.sql
r20697 r20973 11 11 JOIN magicRun USING(magic_id) 12 12 JOIN magicInputSkyfile USING(magic_id, node) 13 JOIN diffSkyfile USING(diff_id) 13 JOIN diffSkyfile 14 ON magicRun.diff_id = diffSkyfile.diff_id 15 AND magicInputSkyfile.node = diffSkyfile.skycell_id 14 16 JOIN rawExp USING(exp_id) 15 17 LEFT JOIN magicNodeResult -
trunk/ippTools/share/pxadmin_create_tables.sql
r20841 r20973 238 238 fault SMALLINT NOT NULL, 239 239 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 240 raw_image_id BIGINT AUTO_INCREMENT, 241 magicked TINYINT, 240 242 PRIMARY KEY(exp_id, class_id), 241 243 KEY(tmp_class_id), 242 244 KEY(fault), 245 KEY(raw_image_id), 243 246 UNIQUE KEY(exp_id, tmp_class_id), 244 247 FOREIGN KEY (exp_id, tmp_class_id) … … 330 333 path_base VARCHAR(255), 331 334 fault SMALLINT NOT NULL, 335 chip_image_id BIGINT AUTO_INCREMENT, 336 magicked BIGINT, 332 337 PRIMARY KEY(chip_id, exp_id, class_id), 333 338 KEY(data_state), 334 339 KEY(fault), 340 KEY(chip_image_id), 335 341 FOREIGN KEY (chip_id, exp_id) 336 342 REFERENCES chipRun(chip_id, exp_id), … … 815 821 end_stage VARCHAR(64), 816 822 registered DATETIME, 817 magiced TINYINT,818 823 PRIMARY KEY(warp_id), 819 824 KEY(warp_id), … … 824 829 KEY(label), 825 830 KEY(end_stage), 826 KEY(magiced),827 831 INDEX(warp_id, fake_id), 828 832 FOREIGN KEY (fake_id) … … 861 865 ignored TINYINT, 862 866 fault SMALLINT, 867 warp_image_id BIGINT AUTO_INCREMENT, 868 magicked TINYINT, 863 869 PRIMARY KEY(warp_id, skycell_id, tess_id), 864 870 KEY(good_frac), 865 871 KEY(ignored), KEY(fault), 872 KEY(warp_image_id), 866 873 FOREIGN KEY (warp_id, skycell_id, tess_id) 867 874 REFERENCES warpSkyCellMap(warp_id, skycell_id, tess_id) … … 941 948 dvodb VARCHAR(255), 942 949 registered DATETIME, 943 skycell_id VARCHAR(64),944 950 tess_id VARCHAR(64), 951 exp_id BIGINT, 945 952 PRIMARY KEY(diff_id), 946 953 KEY(diff_id), 947 954 KEY(state), 948 KEY( skycell_id),949 KEY(tess_id)955 KEY(tess_id), 956 FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id) 950 957 ) ENGINE=innodb DEFAULT CHARSET=latin1; 951 958 952 959 CREATE TABLE diffInputSkyfile ( 953 960 diff_id BIGINT, 954 template TINYINT,955 stack_id BIGINT,956 warp_id BIGINT,957 961 skycell_id VARCHAR(64), 962 warp1 BIGINT, 963 stack1 BIGINT, 964 warp2 BIGINT, 965 stack2 BIGINT, 958 966 tess_id VARCHAR(64), 959 kind VARCHAR(64), 960 PRIMARY KEY(diff_id, template), 961 KEY(stack_id), 962 KEY(warp_id), 967 PRIMARY KEY(diff_id, skycell_id), 968 KEY(warp1), 969 KEY(warp2), 970 KEY(stack1), 971 KEY(stack2), 963 972 KEY(skycell_id), 964 973 KEY(tess_id), 965 KEY(kind),966 974 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id), 967 FOREIGN KEY (stack_id) REFERENCES stackSumSkyfile(stack_id), 968 FOREIGN KEY (warp_id, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id) 975 FOREIGN KEY (warp1, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id), 976 FOREIGN KEY (warp2, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id), 977 FOREIGN KEY (stack1) REFERENCES stackSumSkyfile(stack_id), 978 FOREIGN KEY (stack2) REFERENCES stackSumSkyfile(stack_id) 969 979 ) ENGINE=innodb DEFAULT CHARSET=latin1; 970 980 971 981 CREATE TABLE diffSkyfile ( 972 982 diff_id BIGINT, 983 skycell_id VARCHAR(64), 973 984 uri VARCHAR(255), 974 985 path_base VARCHAR(255), … … 993 1004 good_frac FLOAT, 994 1005 fault SMALLINT, 995 PRIMARY KEY(diff_id), 1006 diff_image_id BIGINT AUTO_INCREMENT, 1007 magicked TINYINT, 1008 PRIMARY KEY(diff_id, skycell_id), 996 1009 KEY(good_frac), 997 1010 KEY(fault), 1011 KEY(diff_image_id), 998 1012 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 999 1013 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 1002 1016 magic_id BIGINT AUTO_INCREMENT, 1003 1017 exp_id BIGINT, 1018 diff_id BIGINT, 1004 1019 state VARCHAR(64), 1005 1020 workdir VARCHAR(255), … … 1015 1030 KEY(label), 1016 1031 KEY(fault), 1017 FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id) 1032 FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id), 1033 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 1018 1034 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1019 1035 … … 1022 1038 diff_id BIGINT, 1023 1039 node VARCHAR(64), 1024 PRIMARY KEY(magic_id, diff_id ),1040 PRIMARY KEY(magic_id, diff_id, node), 1025 1041 FOREIGN KEY (magic_id) REFERENCES magicRun(magic_id), 1026 FOREIGN KEY (diff_id) REFERENCESdiffRun(diff_id)1042 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 1027 1043 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1028 1044 -
trunk/ippTools/share/warptool_tooverlap.sql
r19092 r20973 7 7 rawExp.camera, 8 8 exp_id, 9 exp_tag, 10 warpRun.magiced 9 exp_tag 11 10 FROM warpRun 12 11 JOIN fakeRun -
trunk/ippTools/src/chiptool.c
r20244 r20973 484 484 n_cr, 485 485 path_base, 486 code 486 code, 487 0, // chip_image_id 488 0 // magic_ds_id 487 489 )) { 488 490 // rollback -
trunk/ippTools/src/difftool.c
r20719 r20973 47 47 48 48 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state); 49 static bool diffRunComplete(pxConfig *config); 49 50 50 51 # define MODECASE(caseName, func) \ … … 108 109 // required options 109 110 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 110 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);111 111 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 112 112 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 113 113 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 114 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 114 115 115 116 // default … … 120 121 0, // ID 121 122 "reg", // state 123 workdir, 122 124 label, 123 125 reduction, 124 workdir,125 126 NULL, // dvodb 126 127 registered, 127 skycell_id,128 tess_id128 tess_id, 129 exp_id 129 130 ); 130 131 if (!run) { … … 178 179 179 180 // optional 180 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false); 181 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false); 182 PXOPT_LOOKUP_STR(kind, config->args, "-kind", false, false); 183 184 // defaults to false 185 PXOPT_LOOKUP_BOOL(template, config->args, "-template", false); 186 187 // must provide either stack_id or warp_id but not BOTH 188 if (!(stack_id || warp_id)) { 189 psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified"); 190 return false; 191 } 192 if (stack_id && warp_id) { 193 psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified"); 194 return false; 195 } 196 197 // if a warp_id was provided we need to lookup the skycell_id and tess_id 198 // from the warpRun 199 psString skycell_id = NULL; 181 PXOPT_LOOKUP_S64(stack1, config->args, "-stack1", false, false); 182 PXOPT_LOOKUP_S64(stack2, config->args, "-stack2", false, false); 183 PXOPT_LOOKUP_S64(warp1, config->args, "-warp1", false, false); 184 PXOPT_LOOKUP_S64(warp2, config->args, "-warp2", false, false); 185 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 186 187 // must provide either stack1 or warp1 but not BOTH 188 if (!(stack1 || warp1)) { 189 psError(PS_ERR_UNKNOWN, true, "either -stack1 or -warp1 must be specified"); 190 return false; 191 } 192 if (stack1 && warp1) { 193 psError(PS_ERR_UNKNOWN, true, "either -stack1 or -warp1 must be specified"); 194 return false; 195 } 196 // must provide either stack2 or warp2 but not BOTH 197 if (!(stack2 || warp2)) { 198 psError(PS_ERR_UNKNOWN, true, "either -stack2 or -warp2 must be specified"); 199 return false; 200 } 201 if (stack2 && warp2) { 202 psError(PS_ERR_UNKNOWN, true, "either -stack2 or -warp2 must be specified"); 203 return false; 204 } 205 206 // if a warp1 was provided we need to lookup the and tess_id from the diffRun 200 207 psString tess_id = NULL; 201 if (warp _id) {208 if (warp1) { 202 209 if (!p_psDBRunQuery(config->dbh, "SELECT * from diffRun WHERE diff_id = %" PRId64, diff_id)) { 203 210 psError(PS_ERR_UNKNOWN, false, "database error"); … … 217 224 218 225 diffRunRow *run = diffRunObjectFromMetadata(output->data[0]); 219 skycell_id = run->skycell_id;220 226 tess_id = run->tess_id; 221 227 } … … 228 234 if (!diffInputSkyfileInsert(config->dbh, 229 235 diff_id, 230 template,231 stack_id ? stack_id : PS_MAX_S64, // defined or NULL232 warp_id ? warp_id : PS_MAX_S64, // defined or NULL233 236 skycell_id, 234 tess_id, 235 kind 237 warp1 ? warp1 : PS_MAX_S64, // defined or NULL 238 stack1 ? stack1 : PS_MAX_S64, // defined or NULL 239 warp2 ? warp2 : PS_MAX_S64, // defined or NULL 240 stack2 ? stack2 : PS_MAX_S64, // defined or NULL 241 tess_id 236 242 )) { 237 243 if (!psDBRollback(config->dbh)) { … … 298 304 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); 299 305 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 300 PXOPT_COPY_STR(config->args, where, "-skycell_id", " skycell_id", "==");306 PXOPT_COPY_STR(config->args, where, "-skycell_id", "diffInputSkyfile.skycell_id", "=="); 301 307 PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "=="); 302 PXOPT_COPY_STR(config->args, where, "-kind", "kind", "==");303 308 304 309 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 349 354 } 350 355 351 if (!p_psDBRunQuery(config->dbh, query, whereClause, whereClause )) {356 if (!p_psDBRunQuery(config->dbh, query, whereClause, whereClause, whereClause, whereClause)) { 352 357 psError(PS_ERR_UNKNOWN, false, "database error"); 353 358 psFree(whereClause); … … 471 476 472 477 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); // required 478 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 473 479 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 474 480 PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false); … … 503 509 if (!diffSkyfileInsert(config->dbh, 504 510 diff_id, 511 skycell_id, 505 512 uri, 506 513 path_base, … … 524 531 hostname, 525 532 good_frac, 526 code 533 code, 534 0, // diff_image_id 535 0 // magic_ds_id 527 536 )) { 528 537 if (!psDBRollback(config->dbh)) { … … 533 542 } 534 543 535 if (! setdiffRunState(config, diff_id, "full")) {544 if (!diffRunComplete(config)) { 536 545 if (!psDBRollback(config->dbh)) { 537 546 psError(PS_ERR_UNKNOWN, false, "database error"); … … 546 555 return false; 547 556 } 557 548 558 549 559 return true; … … 762 772 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 763 773 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 774 psS64 exp_id, // exposure id for input_warp_id (if defined) 764 775 pxConfig *config // Configuration 765 776 ) … … 786 797 0, // ID 787 798 "reg", // state 799 workdir, 788 800 label, 789 801 reduction, 790 workdir,791 802 NULL, // dvodb 792 803 registered, 793 skycell_id,794 tess_id804 tess_id, 805 exp_id 795 806 ); 796 807 … … 817 828 if (!diffInputSkyfileInsert(config->dbh, 818 829 run->diff_id, 819 true, 830 skycell_id, 831 input_warp_id, 832 input_stack_id, 833 template_warp_id, 820 834 template_stack_id, 821 template_warp_id, 822 skycell_id, 823 tess_id, 824 NULL // kind 825 )) { 826 if (!psDBRollback(config->dbh)) { 827 psError(PS_ERR_UNKNOWN, false, "database error"); 828 } 829 psError(PS_ERR_UNKNOWN, false, "database error"); 830 return false; 831 } 832 833 // Input 834 if (!diffInputSkyfileInsert(config->dbh, 835 run->diff_id, 836 false, 837 input_stack_id, 838 input_warp_id, 839 skycell_id, 840 tess_id, 841 NULL // kind 835 tess_id 842 836 )) { 843 837 if (!psDBRollback(config->dbh)) { … … 887 881 PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false); 888 882 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 883 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 889 884 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 890 885 … … 906 901 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 907 902 "No input has been defined (-input_stack_id or -input_warp_id)"); 903 return false; 904 } 905 if (input_warp_id && !exp_id) { 906 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 907 "-exp_id is required with -input_warp_id."); 908 908 return false; 909 909 } … … 916 916 template_warp_id ? template_warp_id : PS_MAX_S64, 917 917 template_stack_id ? template_stack_id : PS_MAX_S64, 918 exp_id, 918 919 config)) { 919 920 psError(PS_ERR_UNKNOWN, false, "failed to create populated diffRun"); … … 937 938 PS_ASSERT_PTR_NON_NULL(config, false); 938 939 940 psMetadata *expWhere = psMetadataAlloc(); 939 941 psMetadata *warpWhere = psMetadataAlloc(); 940 942 psMetadata *stackWhere = psMetadataAlloc(); 941 943 944 PXOPT_COPY_S64(config->args, expWhere, "-exp_id", "exp_id", "=="); 942 945 PXOPT_COPY_S64(config->args, warpWhere, "-warp_id", "warpRun.warp_id", "=="); 943 946 PXOPT_COPY_STR(config->args, warpWhere, "-skycell_id", "warpRun.skycell_id", "=="); … … 945 948 PXOPT_COPY_STR(config->args, warpWhere, "-filter", "rawExp.filter", "=="); 946 949 PXOPT_COPY_STR(config->args, warpWhere, "-warp_label", "warpRun.label", "=="); 947 PXOPT_COPY_STR(config->args, warpWhere, "-kind", "warpsToDiff.kind", "==");948 950 PXOPT_COPY_F32(config->args, warpWhere, "-good_frac", "warpSkyfile.good_frac", ">="); 949 951 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); … … 955 957 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 956 958 PXOPT_LOOKUP_BOOL(newTemplates, config->args, "-new-templates", false); 959 PXOPT_LOOKUP_BOOL(reRun, config->args, "-rerun", false); 960 PXOPT_LOOKUP_BOOL(available, config->args, "-available", false); 957 961 958 962 // find all things to queue 959 psString query = pxDataGet("difftool_definebyquery .sql");963 psString query = pxDataGet("difftool_definebyquery_part1.sql"); 960 964 if (!query) { 961 965 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 963 967 } 964 968 965 if (newTemplates) {966 // Warps that haven't been diffed OR warps that can take a newer template in the diff967 psStringAppend(&query, " WHERE (diff_id IS NULL OR best_stack_id > current_stack_id)");968 } else {969 // Only warps that haven't been diffed970 psStringAppend(&query, " WHERE diff_id IS NULL");971 }972 973 969 psString warpQuery = NULL; 974 970 psString stackQuery = NULL; 975 971 psString expQuery = NULL; 972 973 if (psListLength(expWhere->list)) { 974 psString whereClause = psDBGenerateWhereConditionSQL(expWhere, NULL); 975 psStringAppend(&expQuery, "\n AND %s", whereClause); 976 psFree(whereClause); 977 } else { 978 expQuery = psStringCopy("\n"); 979 } 980 psFree(expWhere); 976 981 if (psListLength(warpWhere->list)) { 977 982 psString whereClause = psDBGenerateWhereConditionSQL(warpWhere, NULL); … … 979 984 psFree(whereClause); 980 985 } else { 981 warpQuery = psStringCopy(" ");986 warpQuery = psStringCopy("\n"); 982 987 } 983 988 psFree(warpWhere); 989 990 if (!available) { 991 // diff what's available, even if warp run has some faults and is incomplete 992 psStringAppend(&warpQuery, " AND warpRun.state = 'full'"); 993 } 994 995 // don't queue for exposures that have already been diff'd unless requested 996 psString diffQuery = NULL; 997 if (! (reRun || newTemplates) ) { 998 psStringAppend(&diffQuery, "\nAND diff_id IS NULL"); 999 } else { 1000 diffQuery = psStringCopy("\n"); 1001 } 984 1002 985 1003 if (psListLength(stackWhere->list)) { 986 1004 psString whereClause = psDBGenerateWhereConditionSQL(stackWhere, NULL); 987 psStringAppend(&stackQuery, "\n AND %s", whereClause);1005 psStringAppend(&stackQuery, "\nAND %s", whereClause); 988 1006 psFree(whereClause); 989 1007 } else { … … 992 1010 psFree(stackWhere); 993 1011 994 psTrace("difftool", 1, query, warpQuery, stackQuery); 995 996 if (!p_psDBRunQuery(config->dbh, query, warpQuery, stackQuery)) { 1012 psTrace("difftool", 1, query, warpQuery, diffQuery, expQuery, stackQuery); 1013 1014 1015 if (!p_psDBRunQuery(config->dbh, query, warpQuery, expQuery, diffQuery)) { 997 1016 psError(PS_ERR_UNKNOWN, false, "database error"); 998 1017 psFree(query); … … 1021 1040 } 1022 1041 1042 // create temporary table 1043 query = pxDataGet("difftool_definebyquery_temp_create.sql"); 1044 if (!p_psDBRunQuery(config->dbh, query)) { 1045 psError(PS_ERR_UNKNOWN, false, "database error"); 1046 psFree(query); 1047 return false; 1048 } 1049 psFree(query); 1050 query = NULL; 1051 1052 psString skycell_query = pxDataGet("difftool_definebyquery_part2.sql"); 1053 1023 1054 psArray *list = psArrayAllocEmpty(16); // List of runs, to print 1024 1055 long numGood = 0; // Number of good rows added 1056 psS64 last_exp_id = 0; 1025 1057 for (long i = 0; i < output->n; i++) { 1026 1058 psMetadata *row = output->data[i]; // Output row from query 1027 1028 // Selected parameters1029 1059 bool mdok; // Status of MD lookup 1030 const char *skycell_id = psMetadataLookupStr(&mdok, row, "skycell_id"); 1031 if (!mdok || !skycell_id) { 1032 psWarning("skycell_id not found --- ignoring row %ld", i); 1060 1061 // Take the first warp for each exposure. 1062 // The list is sorted by exposure id and warp_id and the warps are in descending 1063 // order. 1064 psS64 exp_id = psMetadataLookupS64(&mdok, row, "exp_id"); 1065 if (!mdok) { 1066 psError(PXTOOLS_ERR_PROG, false, "exp_id not found"); 1067 return false; 1068 } 1069 if (exp_id == last_exp_id) { 1033 1070 continue; 1034 1071 } 1035 const char *tess_id = psMetadataLookupStr(&mdok, row, "tess_id");1036 if (!mdok || !tess_id) { 1037 psWarning("tess_id not found --- ignoring row %ld", i);1038 continue;1039 }1040 psS64 stack_id = psMetadataLookupS64(&mdok, row, "best_stack_id");1041 if (!mdok) {1042 ps Warning("stack_id not found --- ignoring row %ld", i);1043 continue;1072 last_exp_id = exp_id; 1073 1074 // clear temporary table 1075 if (!p_psDBRunQuery(config->dbh, "DELETE FROM skycellsToDiff")) { 1076 psError(PS_ERR_UNKNOWN, false, "database error"); 1077 psFree(warpQuery); 1078 psFree(stackQuery); 1079 psFree(skycell_query); 1080 return false; 1044 1081 } 1045 1082 psS64 warp_id = psMetadataLookupS64(&mdok, row, "warp_id"); 1046 1083 if (!mdok) { 1047 psWarning("warp_id not found --- ignoring row %ld", i); 1084 psError(PXTOOLS_ERR_PROG, false, "warp_id not found --- ignoring row %ld", i); 1085 psFree(warpQuery); 1086 psFree(stackQuery); 1087 psFree(skycell_query); 1088 return false; 1089 } 1090 psS64 skycell_count = psMetadataLookupS64(&mdok, row, "skycell_count"); 1091 if (!mdok) { 1092 psError(PXTOOLS_ERR_PROG, false, "skycell_count not found"); 1093 psFree(warpQuery); 1094 psFree(stackQuery); 1095 psFree(skycell_query); 1096 return false; 1097 } 1098 psString tess_id = psMetadataLookupStr(&mdok, row, "tess_id"); 1099 if (!mdok) { 1100 psError(PXTOOLS_ERR_PROG, false, "tess_id not found"); 1101 psFree(warpQuery); 1102 psFree(stackQuery); 1103 psFree(skycell_query); 1104 return false; 1105 } 1106 psString filter = psMetadataLookupStr(&mdok, row, "filter"); 1107 if (!mdok) { 1108 psError(PXTOOLS_ERR_PROG, false, "filter not found"); 1109 psFree(warpQuery); 1110 psFree(stackQuery); 1111 psFree(skycell_query); 1112 return false; 1113 } 1114 if (!p_psDBRunQuery(config->dbh, skycell_query, warp_id, filter, warpQuery, stackQuery)) { 1115 psError(PS_ERR_UNKNOWN, false, "database error"); 1116 psFree(warpQuery); 1117 psFree(stackQuery); 1118 psFree(skycell_query); 1119 return false; 1120 } 1121 psS64 num = psDBAffectedRows(config->dbh); 1122 1123 if (num == 0) { 1124 psTrace("difftool", PS_LOG_INFO, "no skycells with stack found for %" PRId64, warp_id); 1048 1125 continue; 1049 1126 } 1050 1127 1051 if (!populatedrun(list, workdir, skycell_id, tess_id, label, reduction, warp_id, 1052 PS_MAX_S64, PS_MAX_S64, stack_id, config)) { 1053 psWarning("Unable to add run for %s,%s,%" PRId64 ",%" PRId64, skycell_id, tess_id, 1054 warp_id, stack_id); 1055 psErrorClear(); 1128 if (!available && (num != skycell_count)) { 1129 psTrace("difftool", PS_LOG_INFO, "%" PRId64 " skyfiles with stack found for warp_id %" 1130 PRId64 " need %" PRId64, num, skycell_count, warp_id); 1056 1131 continue; 1057 1132 } 1058 1133 1134 // ok we've got one create the diffRun 1135 diffRunRow *run = diffRunRowAlloc( 1136 0, // ID 1137 "reg", // state 1138 workdir, 1139 label, 1140 reduction, 1141 NULL, // dvodb 1142 registered, 1143 tess_id, 1144 exp_id 1145 ); 1146 1147 if (!diffRunInsertObject(config->dbh, run)) { 1148 psError(PS_ERR_UNKNOWN, false, "database error"); 1149 psFree(run); 1150 return true; 1151 } 1152 run->diff_id = psDBLastInsertID(config->dbh); 1153 1154 psStringAppend(&query, "UPDATE skycellsToDiff SET diff_id = %" PRId64, run->diff_id); 1155 if (!p_psDBRunQuery(config->dbh, query)) { 1156 psError(PS_ERR_UNKNOWN, false, "database error"); 1157 psFree(warpQuery); 1158 psFree(stackQuery); 1159 psFree(skycell_query); 1160 psFree(query); 1161 return false; 1162 } 1163 psFree(query); 1164 query = NULL; 1165 psStringAppend(&query, "INSERT INTO diffInputSkyfile SELECT * from skycellsToDiff"); 1166 if (!p_psDBRunQuery(config->dbh, query)) { 1167 psError(PS_ERR_UNKNOWN, false, "database error"); 1168 psFree(warpQuery); 1169 psFree(stackQuery); 1170 psFree(skycell_query); 1171 psFree(query); 1172 return false; 1173 } 1174 psFree(query); 1175 query = NULL; 1176 1177 if (!setdiffRunState(config, run->diff_id, "new")) { 1178 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1179 run->diff_id); 1180 psFree(warpQuery); 1181 psFree(stackQuery); 1182 psFree(skycell_query); 1183 psFree(query); 1184 return false; 1185 } 1186 1187 psArrayAdd(list, list->n, run); 1059 1188 numGood++; 1060 1189 } 1061 1190 psFree(output); 1191 psFree(warpQuery); 1192 psFree(stackQuery); 1193 psFree(skycell_query); 1062 1194 1063 1195 if (!diffRunPrintObjects(stdout, list, !simple)) { … … 1274 1406 } 1275 1407 1408 static bool diffRunComplete(pxConfig *config) 1409 { 1410 PS_ASSERT_PTR_NON_NULL(config, false); 1411 1412 // look for completed diffRuns 1413 psString query = pxDataGet("difftool_completed_runs.sql"); 1414 if (!query) { 1415 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1416 return false; 1417 } 1418 1419 if (!p_psDBRunQuery(config->dbh, query)) { 1420 psError(PS_ERR_UNKNOWN, false, "database error"); 1421 psFree(query); 1422 return false; 1423 } 1424 psFree(query); 1425 1426 psArray *output = p_psDBFetchResult(config->dbh); 1427 if (!output) { 1428 psError(PS_ERR_UNKNOWN, false, "database error"); 1429 return false; 1430 } 1431 if (!psArrayLength(output)) { 1432 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1433 psFree(output); 1434 return true; 1435 } 1436 for (long i = 0; i < psArrayLength(output); i++) { 1437 psMetadata *row = output->data[i]; 1438 1439 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1440 1441 // set diffRun.state to 'stop' 1442 if (!setdiffRunState(config, diff_id, "full")) { 1443 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1444 diff_id); 1445 psFree(output); 1446 return false; 1447 } 1448 } 1449 1450 return true; 1451 } 1452 -
trunk/ippTools/src/difftoolConfig.c
r20693 r20973 48 48 psMetadata *definerunArgs = psMetadataAlloc(); 49 49 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 50 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell ID (required)", NULL);51 50 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-tess_id", 0, "define tessellation ID (required)", NULL); 52 51 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); … … 65 64 psMetadataAddS64(addinputskyfileArgs, PS_LIST_TAIL, "-stack_id", 0, "define stack ID", 0); 66 65 psMetadataAddS64(addinputskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "define warp ID", 0); 67 psMetadataAddStr(addinputskyfileArgs, PS_LIST_TAIL, "-kind", 0, "define kind", NULL);68 66 psMetadataAddBool(addinputskyfileArgs, PS_LIST_TAIL, "-template", 0, "this sky cell file is the subtrahend", false); 69 67 … … 74 72 psMetadataAddStr(inputskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", NULL); 75 73 psMetadataAddStr(inputskyfileArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tess ID", NULL); 76 psMetadataAddStr(inputskyfileArgs, PS_LIST_TAIL, "-kind", 0, "search by kind", NULL);77 74 psMetadataAddBool(inputskyfileArgs, PS_LIST_TAIL, "-template", 0, "find only subtrahend", false); 78 75 psMetadataAddBool(inputskyfileArgs, PS_LIST_TAIL, "-input", 0, "find only minuend", false); … … 90 87 psMetadata *adddiffskyfileArgs = psMetadataAlloc(); 91 88 psMetadataAddS64(adddiffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "define warp ID (required)", 0); 89 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell of file (required)", 0); 92 90 psMetadataAddS16(adddiffskyfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 93 91 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-uri", 0, "define URI of file", 0); … … 147 145 // -definebyquery 148 146 psMetadata *definebyqueryArgs = psMetadataAlloc(); 149 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-diff_id", 0, "search by diff ID", 0);150 147 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 148 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 151 149 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", NULL); 152 150 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tess ID", NULL); … … 155 153 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-warp_label", 0, "search by warp label", NULL); 156 154 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-good_frac", 0, "minimum good fraction of skycell", NAN); 157 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-kind", 0, "search by kind", NULL);158 155 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 159 156 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); … … 161 158 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 162 159 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-new-templates", 0, "also search for diffs with new template", false); 160 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false); 161 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-available", 0, "define new run even if warpRun has some faults", false); 163 162 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 164 163 -
trunk/ippTools/src/magicdstool.c
r20850 r20973 469 469 if (psArrayLength(output)) { 470 470 // negative simple so the default is true 471 if (!ippdbPrintMetadatas(stdout, output, "to tree", !simple)) {471 if (!ippdbPrintMetadatas(stdout, output, "todestreak", !simple)) { 472 472 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 473 473 psFree(output); -
trunk/ippTools/src/magictool.c
r20783 r20973 128 128 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 129 129 130 // Create temporary table of the best diffs 131 { 132 psString query = pxDataGet("magictool_definebyquery_temp_create.sql"); 133 if (!query) { 134 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 135 return false; 136 } 137 138 if (!p_psDBRunQuery(config->dbh, query)) { 139 psError(PS_ERR_UNKNOWN, false, "database error"); 140 return false; 141 } 142 psFree(query); 143 } 144 145 // Insert list of best diffs into temporary table 146 { 147 psString query = pxDataGet("magictool_definebyquery_temp_insert.sql"); 148 if (!query) { 149 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 150 return false; 151 } 152 153 psMetadata *where = psMetadataAlloc(); 154 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 155 PXOPT_COPY_STR(config->args, where, "-diff_label", "diffRun.label", "=="); 156 PXOPT_COPY_F32(config->args, where, "-good_frac", "warpSkyfile.good_frac", ">="); 157 158 psString whereClause = NULL; // WHERE conditions 159 if (psListLength(where->list)) { 160 whereClause = psDBGenerateWhereConditionSQL(where, NULL); 161 psStringPrepend(&whereClause, "\n AND "); 162 } 163 psFree(where); 164 165 if (!p_psDBRunQuery(config->dbh, query, whereClause)) { 166 psError(PS_ERR_UNKNOWN, false, "database error"); 167 psFree(whereClause); 168 psFree(query); 169 return false; 170 } 171 psFree(whereClause); 172 psFree(query); 173 } 130 psMetadata *where = psMetadataAlloc(); 131 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 132 PXOPT_COPY_STR(config->args, where, "-diff_label", "diffRun.label", "=="); 133 174 134 175 135 // Get list of exposures ready to magic … … 181 141 } 182 142 183 psString magicSkyCellNumsWhere = NULL; // WHERE conditions for magicSkyCellNums 184 { 185 psMetadata *where = psMetadataAlloc(); 186 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 187 PXOPT_COPY_STR(config->args, where, "-diff_label", "diffRun.label", "=="); 188 PXOPT_COPY_F32(config->args, where, "-good_frac", "warpSkyfile.good_frac", ">="); 189 190 if (psListLength(where->list)) { 191 magicSkyCellNumsWhere = psDBGenerateWhereConditionSQL(where, NULL); 192 psStringPrepend(&magicSkyCellNumsWhere, "\n AND "); 193 } 194 psFree(where); 195 } 196 197 // "available" means only concern ourselves with exposures that have all diffs completed, unless we're 198 // told to only take what's available. 199 // "new" means we want a new run even if there's already a magic run defined 143 // "available" means queue magic run even though the diffRun has skycells that did not complete 144 // "rerun" means we want a new run even if there's already a magic run defined for the exposure 200 145 PXOPT_LOOKUP_BOOL(available, config->args, "-available", false); 201 PXOPT_LOOKUP_BOOL( new, config->args, "-new", false);146 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 202 147 203 148 psString queryWhere = NULL; // WHERE conditions for entire query 204 if (available) { 205 psStringAppend(&queryWhere, " WHERE num_done = num_todo"); 206 } 207 if (new) { 149 if (!available) { 150 psStringAppend(&queryWhere, " \nWHERE diffRun.state = 'full'"); 151 } else { 152 // what if no skycells for the diff run completed? 153 } 154 if (!rerun) { 208 155 const char *newWhere = " magic_id IS NULL"; // String to add 209 156 if (queryWhere) { 210 157 psStringAppend(&queryWhere, " AND %s", newWhere); 211 158 } else { 212 psStringAppend(&queryWhere, " WHERE %s", newWhere);159 psStringAppend(&queryWhere, "\nWHERE %s", newWhere); 213 160 } 214 161 } 215 if (queryWhere) { 216 psStringAppend(&query, " %s", queryWhere); 162 // now add the user specified qualifiers 163 if (psListLength(where->list)) { 164 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 165 psStringAppend(&queryWhere, "\n%s %s", queryWhere == NULL ? "WHERE" : "AND", whereClause); 166 psFree(whereClause); 167 } 168 psFree(where); 169 if (!queryWhere) { 170 psStringAppend(&queryWhere, " "); 171 } 172 173 if (!p_psDBRunQuery(config->dbh, query, queryWhere)) { 174 psError(PS_ERR_UNKNOWN, false, "database error"); 217 175 psFree(queryWhere); 218 }219 220 221 if (!p_psDBRunQuery(config->dbh, query, magicSkyCellNumsWhere ? magicSkyCellNumsWhere : "")) {222 psError(PS_ERR_UNKNOWN, false, "database error");223 psFree(magicSkyCellNumsWhere);224 176 psFree(query); 225 177 return false; 226 178 } 227 psFree( magicSkyCellNumsWhere);179 psFree(queryWhere); 228 180 psFree(query); 229 181 } … … 262 214 psMetadata *row = output->data[i]; // Row of interest 263 215 psS64 exp_id = psMetadataLookupS64(NULL, row, "exp_id"); // Exposure identifier 216 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); // difference identifier 264 217 265 218 // create a new magicRun for this group 266 magicRunRow *run = magicRunRowAlloc(0, exp_id, "run", workdir, "dirty", label, dvodb, registered, 0);219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, "run", workdir, "dirty", label, dvodb, registered, 0); 267 220 if (!run) { 268 221 psAbort("failed to alloc magicRun object"); … … 297 250 { 298 251 psString idString = NULL; 299 psStringAppend(&idString, "%" PRId64, exp_id);300 psStringSubstitute(&thisInsert, idString, "@ EXP_ID@");252 psStringAppend(&idString, "%" PRId64, diff_id); 253 psStringSubstitute(&thisInsert, idString, "@DIFF_ID@"); 301 254 psFree(idString); 302 255 } … … 340 293 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 341 294 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 295 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 342 296 343 297 // optional … … 350 304 0, // ID 351 305 exp_id, 306 diff_id, 352 307 "reg", // state 353 308 workdir, -
trunk/ippTools/src/magictoolConfig.c
r20744 r20973 55 55 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-exp_id", 0, "search exp_id", 0); 56 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-diff_label", 0, "select diff label", NULL); 57 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-good_frac", 0, "limit good_frac", NAN);58 57 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-available", 0, "process what's immediately available?", false); 59 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "- new", 0, "generate new run even if existing?", false);58 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-rerun", 0, "generate new run even if existing?", false); 60 59 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 61 60 -
trunk/ippTools/src/pxwarp.c
r19092 r20973 147 147 tess_id, 148 148 end_stage, 149 NULL, // registered 150 false // magiced 149 NULL // registered 151 150 )) { 152 151 psError(PS_ERR_UNKNOWN, false, "database error"); -
trunk/ippTools/src/regtool.c
r20608 r20973 299 299 hostname, 300 300 code, 301 NULL 301 NULL, 302 0 302 303 )) { 303 304 psError(PS_ERR_UNKNOWN, false, "database error"); -
trunk/ippTools/src/warptool.c
r20723 r20973 134 134 PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false); 135 135 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 136 PXOPT_LOOKUP_BOOL(magiced, config->args, "-magiced", false);137 136 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 138 137 … … 154 153 tess_id, 155 154 end_stage, 156 registered, 157 magiced 155 registered 158 156 ); 159 157 if (!warpRun) { … … 246 244 247 245 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 248 PXOPT_LOOKUP_BOOL(magiced, config->args, "-magiced", false);249 246 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 250 247 … … 942 939 ymax, 943 940 !accept, 944 code 941 code, 942 0, // warp_image_id 943 0 // magic_ds_id 945 944 )) { 946 945 if (!psDBRollback(config->dbh)) { -
trunk/ippTools/src/warptoolConfig.c
r20440 r20973 103 103 104 104 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 105 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-magiced", 0, "has this exposure been magiced", false);106 105 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 107 106 … … 116 115 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-end_stage", 0, "define end stage", NULL); 117 116 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 118 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-magiced", 0, "has this exposure been magiced", false);119 117 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 120 118
Note:
See TracChangeset
for help on using the changeset viewer.
