Changeset 32851 for branches/eam_branches/ipp-20111122/ippTools/src
- Timestamp:
- Dec 2, 2011, 11:44:07 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111122/ippTools/src
- Files:
-
- 12 edited
-
. (modified) (1 prop)
-
addtool.c (modified) (13 diffs)
-
disttool.c (modified) (1 diff)
-
flatcorr.c (modified) (1 diff)
-
magictool.c (modified) (1 prop)
-
pstamptool.c (modified) (3 diffs)
-
pstamptool.h (modified) (1 diff)
-
pstamptoolConfig.c (modified) (2 diffs)
-
pxadd.c (modified) (3 diffs)
-
pxadd.h (modified) (1 diff)
-
vptool.c (modified) (3 diffs)
-
vptoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/ippTools/src
- Property svn:mergeinfo changed
/trunk/ippTools/src (added) merged: 32764,32770-32771,32786,32832-32833
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20111122/ippTools/src/addtool.c
r32711 r32851 143 143 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 144 144 } 145 145 if (strcmp(stage, "staticsky_multi")== 0) { 146 147 pxAddLabelSearchArgs (config, where, "-label", "staticskyRun.label", "=="); // define using camRun label 148 pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label 149 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyyRun.reduction", "=="); 150 //no filter here 151 } 146 152 if (!psListLength(where->list)) { 147 153 psFree(where); … … 237 243 } 238 244 239 245 if (strcmp(stage,"staticsky_multi") == 0) { 246 if (dvodb ) { 247 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage); 248 // find the cam_id of all the exposures that we want to queue up. 249 bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql"); 250 // user supplied dvodb 251 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 252 } else { 253 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage); 254 // find the cam_id of all the exposures that we want to queue up. 255 bare_query = pxDataGet("addtool_find_sky_id_multi.sql"); 256 // inherit dvodb from camRun, avoid matching NULL 257 psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)"); 258 } 259 } 240 260 241 261 if (!bare_query) { … … 292 312 psStringAppend(&query, " GROUP BY stack_id"); 293 313 } 294 314 if (strcmp(stage,"staticsky_multi") == 0) { 315 psStringAppend(&query, " GROUP BY sky_id"); //some reason it needs this 316 } 295 317 296 318 … … 405 427 } 406 428 } 429 if (strcmp(stage,"staticsky_multi") == 0) { 430 for (long i = 0; i < psArrayLength(output); i++) { 431 psMetadata *md = output->data[i]; 432 bool status = false; 433 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 434 if (!status) { 435 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs"); 436 return false; 437 } 438 if (num_inputs < 0) { 439 psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs"); 440 return false; 441 } 442 443 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 444 445 if (!row) { 446 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 447 psFree(output); 448 return false; 449 } 450 451 if (!dvodb) { //there's no staticsky.dvodb 452 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id); 453 psFree(output); 454 return false; 455 } 456 if (!workdir && !row->workdir) { 457 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id); 458 psFree(output); 459 return false; 460 } 461 462 psFree(row); 463 } 464 } 465 466 467 407 468 408 469 // start a transaction so we don't end up with an exp without any associted … … 438 499 stage, 439 500 stage_id, 501 0, 440 502 workdir ? workdir : row->workdir, 441 503 reduction ? reduction : row->reduction, … … 479 541 stage, 480 542 stage_id, 543 0, 481 544 workdir ? workdir : row->workdir, 482 545 reduction ? reduction : row->reduction, … … 520 583 stage, 521 584 stage_id, 585 0, 522 586 workdir ? workdir : row->workdir, 523 587 reduction ? reduction : row->reduction, … … 544 608 } 545 609 610 if (strcmp(stage,"staticsky_multi") == 0) { 611 for (long i = 0; i < psArrayLength(output); i++) { 612 psMetadata *md = output->data[i]; 613 psS64 stage_id =0; 614 bool status = false; 615 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 616 if (!status) { 617 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs"); 618 return false; 619 } 620 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 621 stage_id = row->sky_id; 622 623 if (!row) { 624 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 625 psFree(output); 626 return false; 627 } 628 629 // queue the exp 630 for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 631 if (!pxaddQueueByCamID(config, 632 stage, 633 stage_id, 634 filter_id, 635 workdir ? workdir : row->workdir, 636 reduction ? reduction : row->reduction, 637 label ? label : row->label, 638 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 639 dvodb ? dvodb : NULL, 640 note ? note : NULL, 641 image_only, 642 minidvodb, 643 minidvodb_group, 644 minidvodb_name 645 )) { 646 if (!psDBRollback(config->dbh)) { 647 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 648 } 649 psError(PS_ERR_UNKNOWN, false, 650 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 651 psFree(row); 652 psFree(output); 653 return false; 654 } 655 } 656 psFree(row); 657 } 658 } 659 660 661 662 546 663 psFree(output); 547 664 … … 585 702 } 586 703 if (strcmp(stage, "staticsky")==0) { 704 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 705 } 706 if (strcmp(stage, "staticsky_multi")==0) { 587 707 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 588 708 } … … 626 746 query = pxDataGet("addtool_find_pendingexp_staticsky.sql"); 627 747 } 628 748 if (strcmp(stage, "staticsky_multi")==0) { 749 query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql"); 750 } 751 629 752 630 753 if (!query) { … … 648 771 psStringAppend(&query, " GROUP BY %s", "sky_id"); 649 772 } 650 773 if (strcmp(stage, "staticsky_multi") == 0) { 774 //this group by is needed to join against all the warps (to get camera) 775 psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1"); 776 } 651 777 // treat limit == 0 as "no limit" 652 778 if (limit) { … … 838 964 query = pxDataGet("addtool_find_processedexp_staticsky.sql"); 839 965 } 966 if (strcmp (stage,"staticsky_multi") == 0) { 967 query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql"); 968 } 969 840 970 841 971 if (!query) { … … 948 1078 query = pxDataGet("addtool_revertprocessedexp_staticsky.sql"); 949 1079 } 1080 if (strcmp(stage, "staticsky_multi") == 0) { 1081 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql"); 1082 } 1083 1084 1085 950 1086 if (!query) { 951 1087 // rollback -
branches/eam_branches/ipp-20111122/ippTools/src/disttool.c
r32696 r32851 419 419 } 420 420 421 if (!strcmp(stage, "sky") && single) { 422 psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) = 1"); 421 if (!strcmp(stage, "sky")) { 422 if (single) { 423 psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) = 1"); 424 } else { 425 psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) > 1"); 426 } 423 427 } 424 428 -
branches/eam_branches/ipp-20111122/ippTools/src/flatcorr.c
r31375 r32851 666 666 "cam", 667 667 row->cam_id, 668 0, 668 669 row->workdir, 669 670 row->reduction, -
branches/eam_branches/ipp-20111122/ippTools/src/magictool.c
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/ipp-20111122/ippTools/src/pstamptool.c
r32360 r32851 56 56 static bool revertdependentMode(pxConfig *config); 57 57 static bool getwebrequestnumMode(pxConfig *config); 58 static bool addfileMode(pxConfig *config); 59 static bool listfileMode(pxConfig *config); 60 static bool deletefileMode(pxConfig *config); 58 61 59 62 # define MODECASE(caseName, func) \ … … 103 106 MODECASE(PSTAMPTOOL_MODE_REVERTDEPENDENT, revertdependentMode); 104 107 MODECASE(PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumMode); 108 MODECASE(PSTAMPTOOL_MODE_ADDFILE, addfileMode); 109 MODECASE(PSTAMPTOOL_MODE_LISTFILE, listfileMode); 110 MODECASE(PSTAMPTOOL_MODE_DELETEFILE, deletefileMode); 105 111 default: 106 112 psAbort("invalid option (this should not happen)"); … … 1476 1482 return true; 1477 1483 } 1484 1485 static bool addfileMode(pxConfig *config) 1486 { 1487 PS_ASSERT_PTR_NON_NULL(config, false); 1488 1489 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false); 1490 PXOPT_LOOKUP_STR(path, config->args, "-path", true, false); 1491 1492 if (!pstampFileInsert(config->dbh, 1493 0, // file_id 1494 job_id, 1495 path 1496 )) { 1497 psError(PS_ERR_UNKNOWN, false, "database error"); 1498 return false; 1499 } 1500 1501 psU64 affected = psDBAffectedRows(config->dbh); 1502 if (affected != 1) { 1503 psError(PS_ERR_UNKNOWN, false, 1504 "should have affected one row but %" PRIu64 " rows were modified", 1505 affected); 1506 return false; 1507 } 1508 1509 psS64 file_id = psDBLastInsertID(config->dbh); 1510 printf("%" PRId64 "\n", file_id); 1511 1512 return true; 1513 } 1514 1515 static bool listfileMode(pxConfig *config) 1516 { 1517 PS_ASSERT_PTR_NON_NULL(config, false); 1518 1519 psMetadata *where = psMetadataAlloc(); 1520 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 1521 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 1522 PXOPT_COPY_S64(config->args, where, "-file_id", "file_id", "=="); 1523 1524 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1525 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1526 1527 if (!psListLength(where->list)) { 1528 fprintf(stderr, "search arguments are required\n"); 1529 exit (1); 1530 } 1531 1532 psString query = pxDataGet("pstamptool_listfile.sql"); 1533 if (!query) { 1534 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1535 return false; 1536 } 1537 1538 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 1539 if (psListLength(where->list)) { 1540 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1541 psStringAppend(&query, " WHERE %s", whereClause); 1542 psFree(whereClause); 1543 } 1544 psFree(where); 1545 1546 // treat limit == 0 as "no limit" 1547 if (limit) { 1548 psString limitString = psDBGenerateLimitSQL(limit); 1549 psStringAppend(&query, " %s", limitString); 1550 psFree(limitString); 1551 } 1552 1553 if (!p_psDBRunQuery(config->dbh, query)) { 1554 psError(PS_ERR_UNKNOWN, false, "database error"); 1555 psFree(query); 1556 return false; 1557 } 1558 psFree(query); 1559 1560 psArray *output = p_psDBFetchResult(config->dbh); 1561 if (!output) { 1562 psError(PS_ERR_UNKNOWN, false, "database error"); 1563 return false; 1564 } 1565 if (!psArrayLength(output)) { 1566 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 1567 psFree(output); 1568 return true; 1569 } 1570 1571 // negative simple so the default is true 1572 if (!ippdbPrintMetadatas(stdout, output, "pstampFile", !simple)) { 1573 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1574 psFree(output); 1575 return false; 1576 } 1577 1578 psFree(output); 1579 1580 return true; 1581 } 1582 1583 static bool deletefileMode(pxConfig *config) 1584 { 1585 PS_ASSERT_PTR_NON_NULL(config, false); 1586 1587 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false); 1588 1589 psString query = NULL; 1590 psStringAppend(&query, "DELETE FROM pstampFile WHERE job_id = %" PRId64, job_id); 1591 1592 if (!p_psDBRunQuery(config->dbh, query)) { 1593 psError(PS_ERR_UNKNOWN, false, "database error"); 1594 psFree(query); 1595 return false; 1596 } 1597 psFree(query); 1598 1599 psU64 affected = psDBAffectedRows(config->dbh); 1600 psLogMsg("pstamptool", PS_LOG_INFO, "Deleted %" PRIu64 " rows from pstampFile", affected); 1601 1602 return true; 1603 } -
branches/eam_branches/ipp-20111122/ippTools/src/pstamptool.h
r29248 r32851 50 50 PSTAMPTOOL_MODE_REVERTDEPENDENT, 51 51 PSTAMPTOOL_MODE_GETWEBREQUESTNUM, 52 PSTAMPTOOL_MODE_ADDFILE, 53 PSTAMPTOOL_MODE_LISTFILE, 54 PSTAMPTOOL_MODE_DELETEFILE, 52 55 } pstamptoolMode; 53 56 -
branches/eam_branches/ipp-20111122/ippTools/src/pstamptoolConfig.c
r30543 r32851 274 274 psMetadata *modes = psMetadataAlloc(); 275 275 276 // -addfile 277 psMetadata *addfileArgs = psMetadataAlloc(); 278 psMetadataAddS64(addfileArgs, PS_LIST_TAIL, "-job_id", 0, "define job ID for file (required)", 0); 279 psMetadataAddStr(addfileArgs, PS_LIST_TAIL, "-path", 0, "define path for file (required)", NULL); 280 281 // -listfile 282 psMetadata *listfileArgs = psMetadataAlloc(); 283 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-file_id", 0, "select by file ID", 0); 284 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-job_id", 0, "select by job ID", 0); 285 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-req_id", 0, "select by request ID", 0); 286 psMetadataAddU64(listfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 287 psMetadataAddBool(listfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 288 289 // -deletefile 290 psMetadata *deletefileArgs = psMetadataAlloc(); 291 psMetadataAddS64(deletefileArgs, PS_LIST_TAIL, "-job_id", 0, "select by job ID (required)", 0); 292 276 293 PXOPT_ADD_MODE("-addreq", "", PSTAMPTOOL_MODE_ADDREQ, addreqArgs); 277 294 PXOPT_ADD_MODE("-pendingreq", "", PSTAMPTOOL_MODE_PENDINGREQ, pendingreqArgs); … … 302 319 PXOPT_ADD_MODE("-project", "", PSTAMPTOOL_MODE_PROJECT, projectArgs); 303 320 PXOPT_ADD_MODE("-getwebrequestnum","", PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumArgs); 321 PXOPT_ADD_MODE("-addfile", "", PSTAMPTOOL_MODE_ADDFILE, addfileArgs); 322 PXOPT_ADD_MODE("-listfile", "", PSTAMPTOOL_MODE_LISTFILE, listfileArgs); 323 PXOPT_ADD_MODE("-deletefile", "", PSTAMPTOOL_MODE_DELETEFILE, deletefileArgs); 304 324 305 325 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/eam_branches/ipp-20111122/ippTools/src/pxadd.c
r31375 r32851 131 131 char *stage, 132 132 psS64 stage_id, 133 psS32 stage_extra1, 133 134 char *workdir, 134 135 char *reduction, … … 159 160 psMemSetPersistent(query, true); 160 161 } 162 if (strcmp(stage,"staticsky_multi") == 0) { 163 query = pxDataGet("addtool_queue_sky_id_multi.sql"); 164 psMemSetPersistent(query, true); 165 } 161 166 if (!query) { 162 167 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); … … 170 175 // on 32/64 171 176 if (!p_psDBRunQueryF(config->dbh, query, 177 stage_extra1 ? stage_extra1 : 0, 172 178 "new", // state 173 179 workdir ? workdir : "NULL", -
branches/eam_branches/ipp-20111122/ippTools/src/pxadd.h
r31375 r32851 33 33 char *stage, 34 34 psS64 stage_id, 35 psS32 stage_extra1, 35 36 char *workdir, 36 37 char *reduction, -
branches/eam_branches/ipp-20111122/ippTools/src/vptool.c
r32750 r32851 178 178 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 179 179 180 psMetadata *where = psMetadataAlloc();181 pxchipGetSearchArgs (config, where); // rawExp only182 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); // define using newExp label183 184 if (!psListLength(where->list)) {185 psFree(where);186 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");187 return false;188 }189 180 190 181 PXOPT_LOOKUP_STR(label, config->args, "-set_label", true, false); … … 195 186 196 187 // default 197 PXOPT_LOOKUP_BOOL( unique, config->args, "-unique", false);188 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 198 189 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 199 190 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 191 192 psMetadata *where = psMetadataAlloc(); 193 pxchipGetSearchArgs (config, where); // rawExp only 194 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "="); // define using newExp label 195 196 if (!psListLength(where->list)) { 197 psFree(where); 198 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 199 return false; 200 } 200 201 201 202 // find the exp_id of all the exposures that we want to queue up. … … 213 214 psFree(where); 214 215 215 if ( unique) {216 psStringAppend(&query, " AND vp_id IS NULL");216 if (!rerun) { 217 psStringAppend(&query, "\n AND vp_id IS NULL\n AND (vpRun.label = '%s' OR vpRun.label IS NULL)", label); 217 218 } 218 219 -
branches/eam_branches/ipp-20111122/ippTools/src/vptoolConfig.c
r32511 r32851 50 50 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by newExp label (LIKE comparison)", NULL); 51 51 52 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label ", NULL);52 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label (required)", NULL); 53 53 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 54 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); … … 56 56 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-set_dest_id", 0, "define destination", 0); 57 57 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 58 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "- unique", 0, "only queue exposures that have no previous vpRun", false);58 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-rerun", 0, "queue exposures even if a previous vpRun exists", false); 59 59 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 60 60 // -pendingrun
Note:
See TracChangeset
for help on using the changeset viewer.
