Changeset 23765
- Timestamp:
- Apr 8, 2009, 5:19:09 PM (17 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 7 added
- 1 deleted
- 3 edited
-
share/Makefile.am (modified) (1 diff)
-
share/disttool_definebyquery_camera.sql (added)
-
share/disttool_definebyquery_chip.sql (added)
-
share/disttool_definebyquery_diff.sql (added)
-
share/disttool_definebyquery_fake.sql (added)
-
share/disttool_definebyquery_raw.sql (added)
-
share/disttool_definebyquery_select.sql (deleted)
-
share/disttool_definebyquery_stack.sql (added)
-
share/disttool_definebyquery_warp.sql (added)
-
src/disttool.c (modified) (1 diff)
-
src/disttoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/Makefile.am
r23742 r23765 92 92 difftool_skyfile.sql \ 93 93 difftool_todiffskyfile.sql \ 94 disttool_definebyquery_camera.sql \ 95 disttool_definebyquery_chip.sql \ 96 disttool_definebyquery_diff.sql \ 97 disttool_definebyquery_fake.sql \ 98 disttool_definebyquery_raw.sql \ 99 disttool_definebyquery_stack.sql \ 100 disttool_definebyquery_warp.sql \ 94 101 disttool_pendingcomponent.sql \ 95 102 disttool_processedcomponent.sql \ -
trunk/ippTools/src/disttool.c
r23742 r23765 132 132 static bool definebyqueryMode(pxConfig *config) 133 133 { 134 psError(PS_ERR_PROGRAMMING, true, "-definebyquery is not implemented yet"); 135 return false; 134 PS_ASSERT_PTR_NON_NULL(config, false); 135 136 // required 137 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 138 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 139 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false); 140 141 // optional 142 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 143 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 144 PXOPT_LOOKUP_S64(limit, config->args, "-limit", false, false); 145 146 PXOPT_LOOKUP_BOOL(dry_run, config->args, "-dry_run", false); 147 148 // select arguments 149 psMetadata *where = psMetadataAlloc(); 150 151 PXOPT_COPY_S64(config->args, where, "-target_id", "distTarget.target_id", "=="); 152 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 153 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 154 PXOPT_COPY_STR(config->args, where, "-obs_mode", "rawExp.obs_mode", "=="); 155 156 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 157 158 psString query = NULL; 159 psString runType = NULL; 160 psString runJoinStr = NULL; 161 if (!strcmp(stage, "raw")) { 162 runType = "rawExp"; 163 runJoinStr = "rawExp.exp_id"; 164 query = pxDataGet("disttool_definebyquery_raw.sql"); 165 if (!query) { 166 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 167 psFree(where); 168 return false; 169 } 170 } else if (!strcmp(stage, "chip")) { 171 runType = "chipRun"; 172 runJoinStr = "chipRun.chip_id"; 173 query = pxDataGet("disttool_definebyquery_chip.sql"); 174 if (!query) { 175 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 176 psFree(where); 177 return false; 178 } 179 180 if (label) { 181 psStringAppend(&query, " AND (chipRun.label = '%s')", label); 182 } 183 } else if (!strcmp(stage, "camera")) { 184 runType = "camRun"; 185 query = pxDataGet("disttool_definebyquery_camera.sql"); 186 if (!query) { 187 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 188 psFree(where); 189 return false; 190 } 191 192 if (label) { 193 psStringAppend(&query, " AND (camRun.label = '%s')", label); 194 } 195 } else if (!strcmp(stage, "fake")) { 196 runType = "fakeRun"; 197 query = pxDataGet("disttool_definebyquery_fake.sql"); 198 if (!query) { 199 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 200 psFree(where); 201 return false; 202 } 203 204 if (label) { 205 psStringAppend(&query, " AND (fakeRun.label = '%s')", label); 206 } 207 // fake stage doesn't require magic 208 no_magic = true; 209 } else if (!strcmp(stage, "warp")) { 210 runType = "warpRun"; 211 runJoinStr = "warpRun.warp_id"; 212 query = pxDataGet("disttool_definebyquery_warp.sql"); 213 if (!query) { 214 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 215 psFree(where); 216 return false; 217 } 218 219 if (label) { 220 psStringAppend(&query, " AND (warpRun.label = '%s')", label); 221 } 222 223 } else if (!strcmp(stage, "diff")) { 224 runType = "diffRun"; 225 runJoinStr = "diffRun.diff_id"; 226 query = pxDataGet("disttool_definebyquery_diff.sql"); 227 if (!query) { 228 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 229 psFree(where); 230 return false; 231 } 232 233 if (label) { 234 psStringAppend(&query, " AND (diffRun.label = '%s')", label); 235 } 236 237 } else if (!strcmp(stage, "stack")) { 238 runType = "stackRun"; 239 query = pxDataGet("disttool_definebyquery_stack.sql"); 240 if (!query) { 241 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 242 psFree(where); 243 return false; 244 } 245 246 if (label) { 247 psStringAppend(&query, " AND (stackRun.label = '%s')", label); 248 } 249 // stack stage doesn't require magic (perhaps let the script do this? 250 no_magic = true; 251 } else { 252 psError(PS_ERR_UNKNOWN, true, "unknown value for stage: %s", stage); 253 psFree(where); 254 return false; 255 } 256 257 if (psListLength(where->list)) { 258 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 259 psStringAppend(&query, " AND %s", whereClause); 260 psFree(whereClause); 261 } 262 psFree(where); 263 264 psString joinHook = NULL; 265 266 if (!no_magic) { 267 psStringAppend(&query, " AND (distTarget.clean OR %s.magicked)", runType); 268 269 // is selecting by magic_ds_id really interesting? 270 if (magic_ds_id) { 271 if (strcmp(stage, "camera")) { 272 // stage other than camera 273 if (!runJoinStr) { 274 psError(PS_ERR_PROGRAMMING, true, "cannot select by magic_ds_id for stage: %s", stage); 275 psFree(query); 276 return false; 277 } 278 psStringAppend(&joinHook, "\nJOIN magicDSRun ON magicDSRun.stage = distTarget.stage" 279 " AND magicDSRun.stage_id = %s", runJoinStr); 280 } else { 281 // camera masks are magicked when the chipRun is magicked 282 // XXX: This is confusing. Is it dangerous? 283 // Maybe I should add a magicked bit to camRun. Note this isn't 284 psStringAppend(&joinHook, "\nJOIN magicDSRun ON magicDSRun.stage = 'chip'" 285 " AND magicDSRun.stage_id = chipRun.chip_id"); 286 } 287 psStringAppend(&query, " AND (magicDSRun.state = 'full' AND magicDSRun.re_place AND (magic_ds_id = %" PRId64 "))", magic_ds_id); 288 } 289 } 290 291 if (limit) { 292 psString limitString = psDBGenerateLimitSQL(limit); 293 psStringAppend(&query, " %s", limitString); 294 psFree(limitString); 295 } 296 297 if (!p_psDBRunQueryF(config->dbh, query, joinHook ? joinHook : "")) { 298 psError(PS_ERR_UNKNOWN, false, "database error"); 299 psFree(query); 300 return false; 301 } 302 psFree(query); 303 psFree(joinHook); 304 305 psArray *output = p_psDBFetchResult(config->dbh); 306 if (!output) { 307 psError(PS_ERR_UNKNOWN, false, "database error"); 308 return false; 309 } 310 if (!psArrayLength(output)) { 311 psTrace("warptool", PS_LOG_INFO, "no rows found"); 312 psFree(output); 313 return true; 314 } 315 316 // XXX Remove this debugging output at some point 317 if (!ippdbPrintMetadatas(stdout, output, "newdistRuns", true)) { 318 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 319 psFree(output); 320 return false; 321 } 322 if (dry_run) { 323 psFree(output); 324 return true; 325 } 326 327 for (long i=0; i < psArrayLength(output); i++) { 328 psMetadata *md = output->data[i]; 329 psString stage = psMetadataLookupStr(NULL, md, "stage"); 330 psString run_tag = psMetadataLookupStr(NULL, md, "run_tag"); 331 psS64 stage_id = psMetadataLookupS64(NULL, md, "stage_id"); 332 psS64 target_id = psMetadataLookupS64(NULL, md, "target_id"); 333 bool clean = psMetadataLookupBool(NULL, md, "clean"); 334 335 psString outroot = NULL; 336 psStringAppend(&outroot, "%s/%s/%s", workdir, run_tag, stage); 337 338 if (!distRunInsert(config->dbh, 339 0, // dist_id 340 target_id, 341 stage, 342 stage_id, 343 set_label, 344 outroot, 345 clean, 346 no_magic, 347 "new", 348 NULL, // time_stamp 349 0 // fault 350 )) { 351 psError(PS_ERR_UNKNOWN, false, "database error"); 352 psFree(outroot); 353 psFree(output); 354 return false; 355 } 356 psFree(outroot); 357 } 358 359 psFree(output); 360 361 return true; 136 362 } 137 363 -
trunk/ippTools/src/disttoolConfig.c
r23736 r23765 42 42 return NULL; 43 43 } 44 45 // -definebyquery 46 psMetadata *definebyqueryArgs = psMetadataAlloc(); 47 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-stage", 0, "define stage for bundle (required)", NULL); 48 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 49 50 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not needed", false); 51 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label for run", NULL); 52 53 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-dry_run", 0, "don't queue runs just display what would be selected", false); 54 55 // select args 56 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-target_id", 0, "define target_id", 0); 57 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-exp_id", 0, "define exp_id", 0); 58 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-chip_id", 0, "define chip_id", 0); 59 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define chip_id", 0); 60 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "select by label", NULL); 61 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-obs_mode", 0, "select by obs_mode", NULL); 62 63 psMetadataAddU64(definebyqueryArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 44 64 45 65 // -definerun … … 107 127 psMetadata *modes = psMetadataAlloc(); 108 128 129 PXOPT_ADD_MODE("-definebyquery", "", DISTTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 109 130 PXOPT_ADD_MODE("-definerun", "", DISTTOOL_MODE_DEFINERUN, definerunArgs); 110 131 PXOPT_ADD_MODE("-updaterun", "", DISTTOOL_MODE_UPDATERUN, updaterunArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
