Changeset 20903 for branches/bills_081204/ippTools
- Timestamp:
- Dec 4, 2008, 1:44:33 PM (18 years ago)
- Location:
- branches/bills_081204/ippTools
- Files:
-
- 14 edited
-
share/Makefile.am (modified) (1 diff)
-
share/difftool_definebyquery.sql (modified) (3 diffs)
-
share/difftool_inputskyfile.sql (modified) (4 diffs)
-
share/difftool_skyfile.sql (modified) (2 diffs)
-
share/difftool_todiffskyfile.sql (modified) (2 diffs)
-
share/magictool_definebyquery_insert.sql (modified) (1 diff)
-
share/magictool_definebyquery_select.sql (modified) (1 diff)
-
share/magictool_definebyquery_temp_insert.sql (modified) (1 diff)
-
share/magictool_inputs.sql (modified) (2 diffs)
-
share/pxadmin_create_tables.sql (modified) (5 diffs)
-
src/difftool.c (modified) (21 diffs)
-
src/difftoolConfig.c (modified) (5 diffs)
-
src/magictool.c (modified) (7 diffs)
-
src/magictoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/bills_081204/ippTools/share/Makefile.am
r20841 r20903 70 70 dettool_toresidimfile.sql \ 71 71 dettool_tostacked.sql \ 72 difftool_completed_runs.sql \ 72 73 difftool_definebyquery.sql \ 73 74 difftool_donecleanup.sql \ -
branches/bills_081204/ippTools/share/difftool_definebyquery.sql
r20682 r20903 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 -
branches/bills_081204/ippTools/share/difftool_inputskyfile.sql
r19582 r20903 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_id93 ON diffInputSkyfile.stack1 = stackSumSkyfile.stack_id 54 94 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) 95 ON diffInputSkyfile.stack1 = stackInputSkyfile.stack_id 66 96 JOIN rawExp 67 ON chipRun.exp_id = rawExp.exp_id97 USING(exp_id) 68 98 WHERE 69 99 diffRun.state = 'new' 70 AND warpRun.state = 'full' 71 AND fakeRun.state = 'full' 72 AND camRun.state = 'full' 73 AND chipRun.state = 'full' 100 -- where hook %s 101 UNION 102 SELECT 103 -- stack template 104 diffRun.diff_id, 105 diffInputSkyfile.skycell_id, 106 diffInputSkyfile.tess_id, 107 stackSumSkyfile.stack_id, 108 0 as warp_id, 109 stackSumSkyfile.uri, 110 stackSumSkyfile.path_base, 111 1 as template, 112 rawExp.camera 113 FROM diffRun 114 JOIN diffInputSkyfile 115 USING(diff_id) 116 JOIN stackSumSkyfile 117 ON diffInputSkyfile.stack2 = stackSumSkyfile.stack_id 118 JOIN stackInputSkyfile 119 ON diffInputSkyfile.stack2 = stackInputSkyfile.stack_id 120 JOIN rawExp 121 USING(exp_id) 122 WHERE 123 diffRun.state = 'new' 74 124 -- where hook %s 75 125 ) as Foo -
branches/bills_081204/ippTools/share/difftool_skyfile.sql
r20694 r20903 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) -
branches/bills_081204/ippTools/share/difftool_todiffskyfile.sql
r19678 r20903 5 5 diffRun.diff_id, 6 6 diffRun.workdir, 7 diff Run.skycell_id,7 diffInputSkyfile.skycell_id, 8 8 diffRun.tess_id, 9 9 diffRun.label, 10 10 diffRun.state 11 11 FROM diffRun 12 JOIN diffInputSkyfile USING(diff_id) 13 12 14 -- Get list of templates for each diffRun 13 JOIN diffInputSkyfile AS diffTemplateSkyfile14 ON diffRun.diff_id = diffTemplateSkyfile.diff_id15 AND diffRun.skycell_id = diffTemplateSkyfile.skycell_id16 AND diffTemplateSkyfile.template = 115 -- JOIN diffInputSkyfile AS diffTemplateSkyfile 16 -- ON diffRun.diff_id = diffTemplateSkyfile.diff_id 17 -- AND diffRun.skycell_id = diffTemplateSkyfile.skycell_id 18 -- AND diffTemplateSkyfile.template = 1 17 19 -- Get list of inputs for each diffRun 18 JOIN diffInputSkyfile 19 ON diffRun.diff_id = diffInputSkyfile.diff_id 20 AND diffRun.skycell_id = diffInputSkyfile.skycell_id 21 AND diffInputSkyfile.template = 0 20 -- JOIN diffInputSkyfile 21 -- ON diffRun.diff_id = diffInputSkyfile.diff_id 22 -- AND diffRun.skycell_id = diffInputSkyfile.skycell_id 23 -- AND diffInputSkyfile.template = 0 24 22 25 -- Get warp templates 23 26 LEFT JOIN warpRun AS warpTemplateRun 24 ON warpTemplateRun.warp_id = diff TemplateSkyfile.warp_id25 AND diff TemplateSkyfile.warp_idIS NOT NULL27 ON warpTemplateRun.warp_id = diffInputSkyfile.warp2 28 AND diffInputSkyfile.warp2 IS NOT NULL 26 29 LEFT JOIN warpSkyfile AS warpTemplateSkyfile 27 30 ON warpTemplateSkyfile.warp_id = warpTemplateRun.warp_id 28 AND warpTemplateSkyfile.skycell_id = diffTemplateSkyfile.skycell_id 31 AND warpTemplateSkyfile.skycell_id = diffInputSkyfile.skycell_id 32 29 33 -- Get warp inputs 30 34 LEFT JOIN warpRun 31 ON warpRun.warp_id = diffInputSkyfile.warp _id32 AND diffInputSkyfile.warp _idIS NOT NULL35 ON warpRun.warp_id = diffInputSkyfile.warp1 36 AND diffInputSkyfile.warp1 IS NOT NULL 33 37 LEFT JOIN warpSkyfile 34 38 ON warpSkyfile.warp_id = warpRun.warp_id 35 39 AND warpSkyfile.skycell_id = diffInputSkyfile.skycell_id 40 36 41 -- Get stack templates 37 42 LEFT JOIN stackRun AS stackTemplateRun 38 ON stackTemplateRun.stack_id = diffTemplateSkyfile.stack_id 43 ON stackTemplateRun.stack_id = diffInputSkyfile.stack2 44 AND diffInputSkyfile.stack2 IS NOT NULL 39 45 LEFT JOIN stackSumSkyfile AS stackTemplateSkyfile 40 46 ON stackTemplateSkyfile.stack_id = stackTemplateRun.stack_id 47 41 48 -- Get stack inputs 42 49 LEFT JOIN stackRun 43 ON stackRun.stack_id = diffInputSkyfile.stack _id44 AND diffInputSkyfile. warp_id ISNULL50 ON stackRun.stack_id = diffInputSkyfile.stack1 51 AND diffInputSkyfile.stack1 IS NOT NULL 45 52 LEFT JOIN stackSumSkyfile 46 53 ON stackSumSkyfile.stack_id = stackRun.stack_id 47 AND diffInputSkyfile.warp_id IS NULL 54 48 55 -- Get what's already been processed 49 56 LEFT JOIN diffSkyfile … … 57 64 ) 58 65 -- Ensure input warps are available 59 AND (diffInputSkyfile.warp _idIS NULL66 AND (diffInputSkyfile.warp1 IS NULL 60 67 OR (warpRun.state = 'full' 61 68 AND warpSkyfile.fault = 0 62 69 AND warpSkyfile.ignored = 0)) 63 70 -- Ensure input stacks are available 64 AND (diffInputSkyfile.stack _idIS NULL71 AND (diffInputSkyfile.stack1 IS NULL 65 72 OR (stackRun.state = 'full' 66 73 AND stackSumSkyfile.fault = 0)) 67 74 -- Ensure template warps are available 68 AND (diff TemplateSkyfile.warp_idIS NULL75 AND (diffInputSkyfile.warp2 IS NULL 69 76 OR (warpTemplateRun.state = 'full' 70 77 AND warpTemplateSkyfile.fault = 0 71 78 AND warpTemplateSkyfile.ignored = 0)) 72 79 -- Ensure template stacks are available 73 AND (diff TemplateSkyfile.stack_idIS NULL80 AND (diffInputSkyfile.stack2 IS NULL 74 81 OR (stackTemplateRun.state = 'full' 75 82 AND stackTemplateSkyfile.fault = 0)) -
branches/bills_081204/ippTools/share/magictool_definebyquery_insert.sql
r20890 r20903 3 3 SELECT 4 4 @MAGIC_ID@, -- Update this with the appropriate magic_id 5 diff_id,6 5 skycell_id 7 FROM magicBestDiffs6 FROM diffSkyfile 8 7 WHERE 9 exp_id = @EXP_ID@ -- Update this with the appropriate exp_id 8 diff_id = @DIFF_ID@ -- Update this with the appropriate diff_id 9 AND fault = 0 -
branches/bills_081204/ippTools/share/magictool_definebyquery_select.sql
r20742 r20903 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(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 -
branches/bills_081204/ippTools/share/magictool_definebyquery_temp_insert.sql
r20738 r20903 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) -
branches/bills_081204/ippTools/share/magictool_inputs.sql
r20695 r20903 11 11 diffSkyfile.fault 12 12 FROM magicInputSkyfile 13 JOIN magicRun USING(magic_id) 13 14 JOIN diffSkyfile 14 15 USING(diff_id) 15 JOIN magicRun16 USING(magic_id)17 16 UNION 18 17 -- Merged skycells … … 21 20 magicRun.state, 22 21 magicTree.node, 23 0, 22 0, -- no diff_id 24 23 magicNodeResult.uri, 25 24 NULL, -- magicNodeResult doesn't have a path_base -
branches/bills_081204/ippTools/share/pxadmin_create_tables.sql
r20841 r20903 941 941 dvodb VARCHAR(255), 942 942 registered DATETIME, 943 skycell_id VARCHAR(64),943 exp_id BIGINT, 944 944 tess_id VARCHAR(64), 945 945 PRIMARY KEY(diff_id), 946 946 KEY(diff_id), 947 947 KEY(state), 948 KEY(skycell_id),949 948 KEY(tess_id) 950 949 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 952 951 CREATE TABLE diffInputSkyfile ( 953 952 diff_id BIGINT, 954 template TINYINT, 955 stack_id BIGINT, 956 warp_id BIGINT, 953 warp1 BIGINT, 954 warp2 BIGINT, 955 stack1 BIGINT, 956 stack2 BIGINT, 957 957 skycell_id VARCHAR(64), 958 958 tess_id VARCHAR(64), 959 kind VARCHAR(64), 960 PRIMARY KEY(diff_id, template), 961 KEY(stack_id), 962 KEY(warp_id), 959 PRIMARY KEY(diff_id), 960 KEY(warp1), 961 KEY(warp2), 962 KEY(stack1), 963 KEY(stack2), 963 964 KEY(skycell_id), 964 965 KEY(tess_id), 965 KEY(kind),966 966 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) 967 FOREIGN KEY (warp1, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id), 968 FOREIGN KEY (warp2, skycell_id, tess_id) REFERENCES warpSkyfile(warp_id, skycell_id, tess_id), 969 FOREIGN KEY (stack1) REFERENCES stackSumSkyfile(stack_id), 970 FOREIGN KEY (stack2) REFERENCES stackSumSkyfile(stack_id) 969 971 ) ENGINE=innodb DEFAULT CHARSET=latin1; 970 972 971 973 CREATE TABLE diffSkyfile ( 972 974 diff_id BIGINT, 975 skycell_id VARCHAR(64), 973 976 uri VARCHAR(255), 974 977 path_base VARCHAR(255), … … 996 999 KEY(good_frac), 997 1000 KEY(fault), 1001 KEY(skycell_id), 998 1002 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 999 1003 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 1002 1006 magic_id BIGINT AUTO_INCREMENT, 1003 1007 exp_id BIGINT, 1008 diff_id BIGINT, 1004 1009 state VARCHAR(64), 1005 1010 workdir VARCHAR(255), … … 1015 1020 KEY(label), 1016 1021 KEY(fault), 1017 FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id) 1022 FOREIGN KEY (exp_id) REFERENCES rawExp(exp_id), 1023 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 1018 1024 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1019 1025 1020 1026 CREATE TABLE magicInputSkyfile ( 1021 1027 magic_id BIGINT, 1022 diff_id BIGINT,1023 1028 node VARCHAR(64), 1024 PRIMARY KEY(magic_id, diff_id), 1025 FOREIGN KEY (magic_id) REFERENCES magicRun(magic_id), 1026 FOREIGN KEY (diff_id) REFERENCES diffRun(diff_id) 1029 PRIMARY KEY(magic_id), 1030 FOREIGN KEY (magic_id) REFERENCES magicRun(magic_id) 1027 1031 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1028 1032 -
branches/bills_081204/ippTools/src/difftool.c
r20719 r20903 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 … … 125 126 NULL, // dvodb 126 127 registered, 127 skycell_id,128 exp_id, 128 129 tess_id 129 130 ); … … 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 NULL 232 warp_id ? warp_id : PS_MAX_S64, // defined or NULL 236 warp1 ? warp1 : PS_MAX_S64, // defined or NULL 237 warp2 ? warp2 : PS_MAX_S64, // defined or NULL 238 stack1 ? stack1 : PS_MAX_S64, // defined or NULL 239 stack2 ? stack2 : PS_MAX_S64, // defined or NULL 233 240 skycell_id, 234 tess_id, 235 kind 241 tess_id 236 242 )) { 237 243 if (!psDBRollback(config->dbh)) { … … 300 306 PXOPT_COPY_STR(config->args, where, "-skycell_id", "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, … … 533 540 } 534 541 535 if (! setdiffRunState(config, diff_id, "full")) {542 if (!diffRunComplete(config)) { 536 543 if (!psDBRollback(config->dbh)) { 537 544 psError(PS_ERR_UNKNOWN, false, "database error"); … … 546 553 return false; 547 554 } 555 548 556 549 557 return true; … … 762 770 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 763 771 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 772 psS64 exp_id, // exposure id for input_warp_id (if defined) 764 773 pxConfig *config // Configuration 765 774 ) … … 791 800 NULL, // dvodb 792 801 registered, 793 skycell_id,802 exp_id, 794 803 tess_id 795 804 ); … … 817 826 if (!diffInputSkyfileInsert(config->dbh, 818 827 run->diff_id, 819 true, 828 input_warp_id, 829 template_warp_id, 830 input_stack_id, 820 831 template_stack_id, 821 template_warp_id,822 832 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 833 tess_id 842 834 )) { 843 835 if (!psDBRollback(config->dbh)) { … … 887 879 PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false); 888 880 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 881 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 889 882 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 890 883 … … 906 899 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 907 900 "No input has been defined (-input_stack_id or -input_warp_id)"); 901 return false; 902 } 903 if (input_warp_id && !exp_id) { 904 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 905 "-exp_id is required with -input_warp_id."); 908 906 return false; 909 907 } … … 916 914 template_warp_id ? template_warp_id : PS_MAX_S64, 917 915 template_stack_id ? template_stack_id : PS_MAX_S64, 916 exp_id, 918 917 config)) { 919 918 psError(PS_ERR_UNKNOWN, false, "failed to create populated diffRun"); … … 945 944 PXOPT_COPY_STR(config->args, warpWhere, "-filter", "rawExp.filter", "=="); 946 945 PXOPT_COPY_STR(config->args, warpWhere, "-warp_label", "warpRun.label", "=="); 947 PXOPT_COPY_STR(config->args, warpWhere, "-kind", "warpsToDiff.kind", "==");948 946 PXOPT_COPY_F32(config->args, warpWhere, "-good_frac", "warpSkyfile.good_frac", ">="); 949 947 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); … … 1048 1046 continue; 1049 1047 } 1048 psS64 exp_id = psMetadataLookupS64(&mdok, row, "exp_id"); 1049 if (!mdok) { 1050 psWarning("exp_id not found --- ignoring row %ld", i); 1051 continue; 1052 } 1050 1053 1051 1054 if (!populatedrun(list, workdir, skycell_id, tess_id, label, reduction, warp_id, 1052 PS_MAX_S64, PS_MAX_S64, stack_id, config)) {1055 PS_MAX_S64, PS_MAX_S64, stack_id, exp_id, config)) { 1053 1056 psWarning("Unable to add run for %s,%s,%" PRId64 ",%" PRId64, skycell_id, tess_id, 1054 1057 warp_id, stack_id); … … 1274 1277 } 1275 1278 1279 static bool diffRunComplete(pxConfig *config) 1280 { 1281 PS_ASSERT_PTR_NON_NULL(config, false); 1282 1283 // look for completed diffRuns 1284 psString query = pxDataGet("difftool_completed_runs.sql"); 1285 if (!query) { 1286 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1287 return false; 1288 } 1289 1290 if (!p_psDBRunQuery(config->dbh, query)) { 1291 psError(PS_ERR_UNKNOWN, false, "database error"); 1292 psFree(query); 1293 return false; 1294 } 1295 psFree(query); 1296 1297 psArray *output = p_psDBFetchResult(config->dbh); 1298 if (!output) { 1299 psError(PS_ERR_UNKNOWN, false, "database error"); 1300 return false; 1301 } 1302 if (!psArrayLength(output)) { 1303 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1304 psFree(output); 1305 return true; 1306 } 1307 for (long i = 0; i < psArrayLength(output); i++) { 1308 psMetadata *row = output->data[i]; 1309 1310 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1311 1312 // set diffRun.state to 'stop' 1313 if (!setdiffRunState(config, diff_id, "full")) { 1314 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1315 diff_id); 1316 psFree(output); 1317 return false; 1318 } 1319 } 1320 1321 return true; 1322 } 1323 -
branches/bills_081204/ippTools/src/difftoolConfig.c
r20693 r20903 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); … … 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); -
branches/bills_081204/ippTools/src/magictool.c
r20783 r20903 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 if (!queryWhere) { 163 psStringAppend(&queryWhere, " "); 164 } 165 166 if (!p_psDBRunQuery(config->dbh, query, queryWhere)) { 167 psError(PS_ERR_UNKNOWN, false, "database error"); 217 168 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 169 psFree(query); 225 170 return false; 226 171 } 227 psFree( magicSkyCellNumsWhere);172 psFree(queryWhere); 228 173 psFree(query); 229 174 } … … 262 207 psMetadata *row = output->data[i]; // Row of interest 263 208 psS64 exp_id = psMetadataLookupS64(NULL, row, "exp_id"); // Exposure identifier 209 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); // Exposure identifier 264 210 265 211 // create a new magicRun for this group 266 magicRunRow *run = magicRunRowAlloc(0, exp_id, "run", workdir, "dirty", label, dvodb, registered, 0);212 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, "run", workdir, "dirty", label, dvodb, registered, 0); 267 213 if (!run) { 268 214 psAbort("failed to alloc magicRun object"); … … 297 243 { 298 244 psString idString = NULL; 299 psStringAppend(&idString, "%" PRId64, exp_id);300 psStringSubstitute(&thisInsert, idString, "@ EXP_ID@");245 psStringAppend(&idString, "%" PRId64, diff_id); 246 psStringSubstitute(&thisInsert, idString, "@DIFF_ID@"); 301 247 psFree(idString); 302 248 } … … 340 286 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 341 287 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 288 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 342 289 343 290 // optional … … 350 297 0, // ID 351 298 exp_id, 299 diff_id, 352 300 "reg", // state 353 301 workdir, … … 414 362 config->dbh, 415 363 magic_id, 416 diff_id,417 364 node 418 365 ); -
branches/bills_081204/ippTools/src/magictoolConfig.c
r20744 r20903 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
Note:
See TracChangeset
for help on using the changeset viewer.
