- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/chiptool.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Property svn:ignore
-
old new 33 33 pstamptool 34 34 disttool 35 receivetool
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c
r23594 r24244 125 125 psMetadata *where = psMetadataAlloc(); 126 126 pxchipGetSearchArgs (config, where); // rawExp only 127 PXOPT_COPY_STR(config->args, where, "-label", "rawExp.label", "LIKE");127 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); 128 128 129 129 // psListLength(where->list) is at least 1 because exp_type defaults to "object" … … 198 198 } 199 199 200 // if end_stage is warp (or NULL), check for valid tess_id 201 for (long i = 0; i < psArrayLength(output); i++) { 202 psMetadata *md = output->data[i]; 203 204 bool status; 205 char *end_stage = psMetadataLookupStr(&status, md, "end_stage"); 206 if (end_stage && strcasecmp(end_stage, "warp")) continue; 207 208 char *raw_tess_id = psMetadataLookupStr(&status, md, "tess_id"); 209 if (raw_tess_id || tess_id) continue; 210 211 char *label = psMetadataLookupStr(&status, md, "label"); 212 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 213 214 if (!status) { 215 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 216 psFree(output); 217 return false; 218 } 219 } 220 221 222 # define GET_VALUE(PTYPE,CTYPE,VALUE,NAME) \ 223 PTYPE VALUE; \ 224 { bool status; \ 225 VALUE = psMetadataLookup##CTYPE(&status, md, NAME); \ 226 if (!status) { \ 227 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", NAME); \ 228 psFree(output); \ 229 return false; \ 230 } } 231 200 232 // loop over our list of exp_ids 201 233 for (long i = 0; i < psArrayLength(output); i++) { 202 234 psMetadata *md = output->data[i]; 203 235 204 bool status; 205 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 206 if (!status) { 207 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id"); 236 rawExpRow *row = rawExpObjectFromMetadata(md); 237 if (!row) { 238 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 208 239 psFree(output); 209 240 return false; 210 241 } 211 // 242 243 GET_VALUE (psS64, S64, exp_id, "exp_id"); 244 GET_VALUE (psString, Str, raw_workdir, "workdir"); 245 GET_VALUE (psString, Str, raw_label, "label"); 246 GET_VALUE (psString, Str, raw_reduction, "reduction"); 247 // GET_VALUE (psString, Str, raw_expgroup, "expgroup"); 248 GET_VALUE (psString, Str, raw_dvodb, "dvodb"); 249 GET_VALUE (psString, Str, raw_tess_id, "tess_id"); 250 GET_VALUE (psString, Str, raw_end_stage, "end_stage"); 251 252 if (!row->exp_id) { 253 psError(PS_ERR_UNKNOWN, false, "failed to find value for exp_id"); 254 psFree(output); 255 return false; 256 } 257 212 258 // queue the exp 213 if (!pxchipQueueByExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) { 259 if (!pxchipQueueByExpTag(config, 260 exp_id, 261 workdir ? workdir : raw_workdir, 262 label ? label : raw_label, 263 reduction ? reduction : raw_reduction, 264 // expgroup ? expgroup : raw_expgroup, 265 // XXX how does expgroup get defined? 266 expgroup, 267 dvodb ? dvodb : raw_dvodb, 268 tess_id ? tess_id : raw_tess_id, 269 end_stage ? end_stage : raw_end_stage 270 )) { 214 271 if (!psDBRollback(config->dbh)) { 215 272 psError(PS_ERR_UNKNOWN, false, "database error"); … … 239 296 pxchipGetSearchArgs (config, where); // rawExp, chipRun 240 297 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 298 // we only allow a single label to match (do not use pxAddLabelSearchArgs here) 241 299 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 242 300 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 243 301 244 if (!psListLength(where->list) 245 &&!psMetadataLookupBool(NULL, config->args, "-all")) {302 if (!psListLength(where->list) && 303 !psMetadataLookupBool(NULL, config->args, "-all")) { 246 304 psFree(where); 247 305 where = NULL; … … 291 349 pxchipGetSearchArgs (config, where); //chipRun, rawExp 292 350 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 293 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "==");351 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "=="); 294 352 295 353 psString query = pxDataGet("chiptool_pendingimfile.sql"); … … 409 467 PXOPT_LOOKUP_F32(dtime_script, config->args, "-dtime_script", false, false); 410 468 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 411 PXOPT_LOOKUP_F32(n_stars, config->args, "-n_stars", false, false);412 PXOPT_LOOKUP_F32(n_psfstars, config->args, "-n_psfstars", false, false);413 PXOPT_LOOKUP_F32(n_iqstars, config->args, "-n_iqstars", false, false);414 PXOPT_LOOKUP_F32(n_extended, config->args, "-n_extended", false, false);415 PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false);416 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);417 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false);469 PXOPT_LOOKUP_F32(n_stars, config->args, "-n_stars", false, false); 470 PXOPT_LOOKUP_F32(n_psfstars, config->args, "-n_psfstars", false, false); 471 PXOPT_LOOKUP_F32(n_iqstars, config->args, "-n_iqstars", false, false); 472 PXOPT_LOOKUP_F32(n_extended, config->args, "-n_extended", false, false); 473 PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false); 474 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 475 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 418 476 419 477 // default values 420 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 478 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 479 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 421 480 422 481 if (!psDBTransaction(config->dbh)) { … … 449 508 fwhm_minor_uq, 450 509 451 iq_fwhm_major,452 iq_fwhm_major_err,453 iq_fwhm_minor,454 iq_fwhm_minor_err,455 456 iq_m2,457 iq_m2_err,458 iq_m2_lq,459 iq_m2_uq,460 461 iq_m2c,462 iq_m2c_err,463 iq_m2c_lq,464 iq_m2c_uq,465 466 iq_m2s,467 iq_m2s_err,468 iq_m2s_lq,469 iq_m2s_uq,470 471 iq_m3,472 iq_m3_err,473 iq_m3_lq,474 iq_m3_uq,475 476 iq_m4,477 iq_m4_err,478 iq_m4_lq,479 iq_m4_uq,510 iq_fwhm_major, 511 iq_fwhm_major_err, 512 iq_fwhm_minor, 513 iq_fwhm_minor_err, 514 515 iq_m2, 516 iq_m2_err, 517 iq_m2_lq, 518 iq_m2_uq, 519 520 iq_m2c, 521 iq_m2c_err, 522 iq_m2c_lq, 523 iq_m2c_uq, 524 525 iq_m2s, 526 iq_m2s_err, 527 iq_m2s_lq, 528 iq_m2s_uq, 529 530 iq_m3, 531 iq_m3_err, 532 iq_m3_lq, 533 iq_m3_uq, 534 535 iq_m4, 536 iq_m4_err, 537 iq_m4_lq, 538 iq_m4_uq, 480 539 481 540 dtime_detrend, … … 490 549 n_cr, 491 550 path_base, 492 code, 551 fault, 552 quality, 493 553 magicked 494 554 )) { … … 540 600 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 541 601 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 542 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE");602 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "LIKE"); 543 603 PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "=="); 604 605 if (!psListLength(where->list) && 606 !psMetadataLookupBool(NULL, config->args, "-all")) { 607 psFree(where); 608 psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required"); 609 return false; 610 } 544 611 545 612 psString query = pxDataGet("chiptool_processedimfile.sql"); … … 609 676 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 610 677 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 611 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE"); 678 // require a single label 679 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 612 680 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 613 PXOPT_COPY_S16(config->args, where, "- code", "chipProcessedImfile.fault", "==");681 PXOPT_COPY_S16(config->args, where, "-fault", "chipProcessedImfile.fault", "=="); 614 682 615 683 if (!psListLength(where->list) … … 652 720 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 653 721 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 654 PXOPT_LOOKUP_S16( code, config->args, "-code", true, false);655 656 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {722 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 723 724 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) { 657 725 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 658 726 return false; … … 835 903 836 904 psMetadata *where = psMetadataAlloc(); 837 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");905 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 838 906 839 907 psString query = pxDataGet("chiptool_pendingcleanuprun.sql"); … … 899 967 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 900 968 } 901 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");969 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 902 970 903 971 psString query = pxDataGet("chiptool_pendingcleanupimfile.sql"); … … 1027 1095 1028 1096 psMetadata *where = psMetadataAlloc(); 1029 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");1097 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1030 1098 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 1031 1099 … … 1088 1156 1089 1157 psMetadata *where = psMetadataAlloc(); 1090 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");1158 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1091 1159 1092 1160 // look for completed chipPendingExp … … 1273 1341 char sqlFilename[80]; 1274 1342 } ExportTable; 1275 1343 1276 1344 int numExportTables = 3; 1277 1345 1278 1346 PS_ASSERT_PTR_NON_NULL(config, NULL); 1279 1347 1280 PXOPT_LOOKUP_S64(d et_id, config->args, "-chip_id", true, false);1348 PXOPT_LOOKUP_S64(dummy, config->args, "-chip_id", true, false); 1281 1349 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1282 1350 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1351 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); 1352 1283 1353 1284 1354 FILE *f = fopen (outfile, "w"); … … 1331 1401 } 1332 1402 if (!psArrayLength(output)) { 1333 psTrace(" regtool", PS_LOG_INFO, "no rows found");1403 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1334 1404 psFree(output); 1335 return true; 1405 return false; 1406 } 1407 1408 if (clean) { 1409 bool success = true; 1410 if (!strcmp(tables[i].tableName, "chipRun")) { 1411 success = pxSetStateCleaned("chipRun", "state", output); 1412 } else if (!strcmp(tables[i].tableName, "chipProcessedImfile")) { 1413 success = pxSetStateCleaned("chipProcessedImfile", "data_state", output); 1414 } 1415 if (!success) { 1416 psFree(output); 1417 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName); 1418 return false; 1419 } 1336 1420 } 1337 1421 … … 1352 1436 bool importrunMode(pxConfig *config) 1353 1437 { 1354 unsigned int nFail; 1355 1356 int numImportTables = 2; 1357 1358 char tables[2] [80] = {"chipImfile", "chipProcessedImfile"}; 1359 1360 PS_ASSERT_PTR_NON_NULL(config, NULL); 1361 1362 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1363 1364 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1365 1366 fprintf (stdout, "---- input ----\n"); 1367 psMetadataPrint (stderr, input, 1); 1368 1369 psMetadataItem *item = psMetadataLookup (input, "chipRun"); 1370 psAssert (item, "entry not in input?"); 1371 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1372 1373 psMetadataItem *entry = psListGet (item->data.list, 0); 1374 assert (entry); 1375 assert (entry->type == PS_DATA_METADATA); 1376 chipRunRow *chipRun = chipRunObjectFromMetadata (entry->data.md); 1377 chipRunInsertObject (config->dbh, chipRun); 1378 1379 // fprintf (stdout, "---- chip run ----\n"); 1380 // psMetadataPrint (stderr, entry->data.md, 1); 1381 1382 for (int i = 0; i < numImportTables; i++) { 1383 psMetadataItem *item = psMetadataLookup (input, tables[i]); 1384 psAssert (item, "entry not in input?"); 1385 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1386 1387 switch (i) { 1388 case 0: 1389 for (int i = 0; i < item->data.list->n; i++) { 1390 psMetadataItem *entry = psListGet (item->data.list, i); 1391 assert (entry); 1392 assert (entry->type == PS_DATA_METADATA); 1393 chipImfileRow *chipImfile = chipImfileObjectFromMetadata (entry->data.md); 1394 chipImfileInsertObject (config->dbh, chipImfile); 1395 1396 // fprintf (stdout, "---- row %d ----\n", i); 1397 // psMetadataPrint (stderr, entry->data.md, 1); 1398 } 1399 break; 1400 1401 case 1: 1402 for (int i = 0; i < item->data.list->n; i++) { 1403 psMetadataItem *entry = psListGet (item->data.list, i); 1404 assert (entry); 1405 assert (entry->type == PS_DATA_METADATA); 1406 chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md); 1407 chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile); 1408 1409 // fprintf (stdout, "---- row %d ----\n", i); 1410 // psMetadataPrint (stderr, entry->data.md, 1); 1411 } 1412 break; 1413 } 1414 } 1415 1416 return true; 1417 } 1418 1419 1438 PS_ASSERT_PTR_NON_NULL(config, NULL); 1439 1440 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1441 unsigned int nFail = 0; // Number of failed lines 1442 psMetadata *input = psMetadataConfigRead(NULL, &nFail, infile, false); 1443 if (nFail) { 1444 psError(PS_ERR_IO, false, "%d failed lines in input", nFail); 1445 psFree(input); 1446 return false; 1447 } 1448 1449 psVector *identifiers = psVectorAllocEmpty(16, PS_TYPE_U64); // Identifiers inserted 1450 1451 if (!psDBTransaction(config->dbh)) { 1452 psError(PS_ERR_UNKNOWN, false, "database error"); 1453 return false; 1454 } 1455 1456 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator 1457 psMetadataItem *item; // Item from iteration 1458 while ((item = psMetadataGetAndIncrement(iter))) { 1459 PXMIRROR_PRIMARY(item, "chipRun", chipRunRow, chipRunObjectFromMetadata, identifiers, chip_id, 1460 chipRunInsertObject, config->dbh, 1461 { psFree(iter); psFree(identifiers); psFree(input); }); 1462 1463 PXMIRROR_OTHER(item, "chipImfile", chipImfileRow, chipImfileObjectFromMetadata, identifiers, chip_id, 1464 chipImfileInsertObject, config->dbh, 1465 { psFree(iter); psFree(identifiers); psFree(input); }); 1466 1467 PXMIRROR_OTHER(item, "chipProcessedImfile", chipProcessedImfileRow, 1468 chipProcessedImfileObjectFromMetadata, identifiers, chip_id, 1469 chipProcessedImfileInsertObject, config->dbh, 1470 { psFree(iter); psFree(identifiers); psFree(input); }); 1471 } 1472 psFree(iter); 1473 psFree(input); 1474 1475 if (!psDBCommit(config->dbh)) { 1476 psError(PS_ERR_UNKNOWN, false, "database error"); 1477 return false; 1478 } 1479 1480 psLogMsg("chiptool", PS_LOG_INFO, "%ld chipRuns added", identifiers->n); 1481 psFree(identifiers); 1482 1483 return true; 1484 }
Note:
See TracChangeset
for help on using the changeset viewer.
