Changeset 36417
- Timestamp:
- Jan 3, 2014, 1:54:29 PM (13 years ago)
- Location:
- branches/bills_branches/bills_201312
- Files:
-
- 4 added
- 6 edited
-
dbconfig/changes.txt (modified) (3 diffs)
-
ippTasks/fullforce.pro (modified) (9 diffs)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/fftool_revertsummary.sql (added)
-
ippTools/share/fftool_summary.sql (added)
-
ippTools/share/fftool_summaryinputs.sql (added)
-
ippTools/share/fftool_toadvance.sql (added)
-
ippTools/src/fftool.c (modified) (9 diffs)
-
ippTools/src/fftool.h (modified) (1 diff)
-
ippTools/src/fftoolConfig.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/bills_branches/bills_201312/dbconfig/changes.txt
r36396 r36417 2436 2436 CREATE TABLE fullForceRun ( 2437 2437 ff_id BIGINT NOT NULL AUTO_INCREMENT, 2438 warp_id BIGINT,2439 2438 skycal_id BIGINT, 2440 2439 sources_path_base VARCHAR(255), … … 2451 2450 KEY(label), 2452 2451 KEY(data_group), 2453 KEY(warp_id),2454 2452 KEY(skycal_id), 2455 FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id),2456 2453 FOREIGN KEY(skycal_id) REFERENCES skycalRun(skycal_id) 2457 2454 ) ENGINE=innodb DEFAULT CHARSET=latin1; 2458 2455 2456 CREATE TABLE fullForceInput ( 2457 ff_id BIGINT, 2458 warp_id BIGINT, 2459 PRIMARY KEY(ff_id, warp_id), 2460 FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id), 2461 FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id) 2462 ) ENGINE=innodb DEFAULT CHARSET=latin1; 2463 2459 2464 CREATE TABLE fullForceResult ( 2465 ff_id BIGINT, 2466 warp_id BIGINT, 2467 path_base VARCHAR(255) NOT NULL, 2468 dtime_script FLOAT, 2469 quality SMALLINT NOT NULL, 2470 hostname VARCHAR(64) NOT NULL, 2471 software_ver VARCHAR(16), 2472 fault SMALLINT NOT NULL, 2473 PRIMARY KEY(ff_id, warp_id), 2474 KEY(fault), 2475 KEY(quality), 2476 FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id), 2477 FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id) 2478 ) ENGINE=innodb DEFAULT CHARSET=latin1; 2479 2480 CREATE TABLE fullForceSummary ( 2460 2481 ff_id BIGINT, 2461 2482 path_base VARCHAR(255) NOT NULL, … … 2463 2484 quality SMALLINT NOT NULL, 2464 2485 hostname VARCHAR(64) NOT NULL, 2465 software_ver VARCHAR( 64),2486 software_ver VARCHAR(16), 2466 2487 fault SMALLINT NOT NULL, 2467 2488 PRIMARY KEY(ff_id), -
branches/bills_branches/bills_201312/ippTasks/fullforce.pro
r36388 r36417 8 8 ### Initialise the books containing the tasks to do 9 9 book init fullForceRun 10 book init fullForceSummary 10 11 11 12 ### Database lists 12 13 $fullForce_DB = 0 13 14 $fullForce_revert_DB = 0 15 $fullForceSummary_DB = 0 16 $fullForceSummary_revert_DB = 0 14 17 15 18 ### Check status of fullForce tasks 16 macro full Force.status19 macro fullforce.status 17 20 book listbook fullForceRun 18 21 end 19 22 20 23 ### Reset fullForce tasks 21 macro full Force.reset24 macro fullforce.reset 22 25 book init fullForceRun 23 26 end 27 macro fullforce.summary.status 28 book listbook fullForceSummary 29 end 30 31 ### Reset fullForce tasks 32 macro fullforce.summary.reset 33 book init fullForceSummary 34 end 24 35 25 36 ### Turn fullForce tasks on 26 macro fullForce.on 27 task fullForce.load 28 active true 29 end 30 task fullForce.run 37 macro fullforce.on 38 task fullforce.load 39 active true 40 end 41 task fullforce.run 42 active true 43 end 44 task fullforce.summary.load 45 active true 46 end 47 task fullforce.summary.run 31 48 active true 32 49 end … … 34 51 35 52 ### Turn fullForce tasks off 36 macro fullForce.off 37 task fullForce.load 38 active false 39 end 40 task fullForce.run 41 active false 42 end 43 end 44 45 macro fullForce.revert.on 46 task fullForce.revert 47 active true 48 end 49 end 50 51 macro fullForce.revert.off 52 task fullForce.revert 53 active false 54 end 55 end 56 57 ### Load tasks for fullForce 53 macro fullforce.off 54 task fullforce.load 55 active false 56 end 57 task fullforce.run 58 active false 59 end 60 task fullforce.summary.load 61 active false 62 end 63 task fullforce.summary.run 64 active false 65 end 66 end 67 68 macro fullforce.revert.on 69 task fullforce.revert 70 active true 71 end 72 task fullforce.summary.revert 73 active true 74 end 75 end 76 77 macro fullforce.revert.off 78 task fullforce.revert 79 active false 80 end 81 task fullforce.summary.revert 82 active false 83 end 84 end 85 86 ### Load tasks for fullforce 58 87 ### Tasks are loaded into fullForceRun. 59 task full Force.load88 task fullforce.load 60 89 host local 61 90 … … 66 95 67 96 stdout NULL 68 stderr $LOGDIR/full Force.log97 stderr $LOGDIR/fullforce.log 69 98 70 99 task.exec … … 88 117 task.exit 0 89 118 # convert 'stdout' to book format 90 ipptool2book stdout fullForceRun -key ff_id -uniq -setword dbname $options:0 -setword pantaskState INIT119 ipptool2book stdout fullForceRun -key ff_id:warp_id -uniq -setword dbname $options:0 -setword pantaskState INIT 91 120 if ($VERBOSE > 2) 92 121 book listbook fullForceRun … … 112 141 end 113 142 114 ### Run tasks for the full Force analysis143 ### Run tasks for the fullforce analysis 115 144 ### Tasks are taken from fullForceRun. 116 task full Force.run145 task fullforce.run 117 146 periods -poll $RUNPOLL 118 147 periods -exec $RUNEXEC … … 152 181 sprintf outroot "%s/%s/%s/%s.%s.wrp.%s.ff.%s" $WORKDIR $TESS_ID $SKYCELL_ID $TESS_ID $SKYCELL_ID $WARP_ID $FF_ID 153 182 154 stdout $LOGDIR/full Force.log155 stderr $LOGDIR/full Force.log156 157 $run = psphot_fullforce_warp.pl --ff_id $FF_ID -- outroot $outroot --redirect-output --camera $CAMERA --warp_path_base $WARP_PATH_BASE --sources_path_base $SOURCES_PATH_BASE --skycell_id $SKYCELL_ID --threads @MAX_THREADS@183 stdout $LOGDIR/fullforce.log 184 stderr $LOGDIR/fullforce.log 185 186 $run = psphot_fullforce_warp.pl --ff_id $FF_ID --warp_id $WARP_ID --outroot $outroot --redirect-output --camera $CAMERA --warp_path_base $WARP_PATH_BASE --sources_path_base $SOURCES_PATH_BASE --skycell_id $SKYCELL_ID --threads @MAX_THREADS@ 158 187 if ("$REDUCTION" != "NULL") 159 188 $run = $run --reduction $REDUCTION … … 192 221 end 193 222 194 task full Force.revert223 task fullforce.revert 195 224 host local 196 225 … … 202 231 203 232 stdout NULL 204 stderr $LOGDIR/ revert.log233 stderr $LOGDIR/fullforce.revert.log 205 234 206 235 task.exec … … 243 272 end 244 273 274 ### Load tasks for fullForceSummary 275 ### Tasks are loaded into fullForceSummary. 276 task fullforce.summary.load 277 host local 278 279 periods -poll $LOADPOLL 280 periods -exec $LOADEXEC 281 periods -timeout 30 282 npending 1 283 284 stdout NULL 285 stderr $LOGDIR/fullforce.summary.log 286 287 task.exec 288 if ($LABEL:n == 0) break 289 $run = fftool -toadvance 290 if ($DB:n == 0) 291 option DEFAULT 292 else 293 # save the DB name for the exit tasks 294 option $DB:$fullForceSummary_DB 295 $run = $run -dbname $DB:$fullForceSummary_DB 296 $fullForceSummary_DB ++ 297 if ($fullForceSummary_DB >= $DB:n) set fullForceSummary_DB = 0 298 end 299 add_poll_args run 300 add_poll_labels run 301 command $run 302 end 303 304 # success 305 task.exit 0 306 # convert 'stdout' to book format 307 ipptool2book stdout fullForceSummary -key ff_id -uniq -setword dbname $options:0 -setword pantaskState INIT 308 if ($VERBOSE > 2) 309 book listbook fullForceSummary 310 end 311 312 # delete existing entries in the appropriate pantaskStates 313 process_cleanup fullForceSummary 314 end 315 316 # locked list 317 task.exit default 318 showcommand failure 319 end 320 321 task.exit crash 322 showcommand crash 323 end 324 325 # operation times out? 326 task.exit timeout 327 showcommand timeout 328 end 329 end 330 331 ### Run tasks for the fullForceSummary analyasis 332 ### Tasks are taken from fullForceSummary. 333 task fullforce.summary.run 334 periods -poll $RUNPOLL 335 periods -exec $RUNEXEC 336 periods -timeout 10800 337 338 task.exec 339 # if we are unable to run use "long" exectime 340 periods -exec $RUNEXEC 341 book npages fullForceSummary -var N 342 if ($N == 0) break 343 if ($NETWORK == 0) break 344 if ($BURNTOOLING == 1) break 345 346 347 # look for new entries in fullForceSummary (pantaskState == INIT) 348 book getpage fullForceSummary 0 -var pageName -key pantaskState INIT 349 if ("$pageName" == "NULL") break 350 351 book setword fullForceSummary $pageName pantaskState RUN 352 book getword fullForceSummary $pageName ff_id -var FF_ID 353 book getword fullForceSummary $pageName tess_id -var TESS_DIR 354 book getword fullForceSummary $pageName skycell_id -var SKYCELL_ID 355 book getword fullForceSummary $pageName camera -var CAMERA 356 book getword fullForceSummary $pageName workdir -var WORKDIR_TEMPLATE 357 book getword fullForceSummary $pageName reduction -var REDUCTION 358 book getword fullForceSummary $pageName dbname -var DBNAME 359 360 # set the host and workdir based on the skycell hash 361 # set.host.for.skycell $SKYCELL_ID 362 host anyhost 363 set.workdir.by.skycell $SKYCELL_ID $WORKDIR_TEMPLATE $default_host WORKDIR 364 365 basename $TESS_DIR -var TESS_ID 366 sprintf outroot "%s/%s/%s/%s.%s.ff.%s" $WORKDIR $TESS_ID $SKYCELL_ID $TESS_ID $SKYCELL_ID $FF_ID 367 368 stdout $LOGDIR/fullforce.summary.log 369 stderr $LOGDIR/fullforce.summary.log 370 371 $run = psphot_fullforce_summary.pl --ff_id $FF_ID --outroot $outroot --redirect-output --camera $CAMERA --threads @MAX_THREADS@ 372 if ("$REDUCTION" != "NULL") 373 $run = $run --reduction $REDUCTION 374 end 375 add_standard_args run 376 377 # save the pageName for future reference below 378 options $pageName 379 380 # create the command line 381 if ($VERBOSE > 1) 382 echo command $run 383 end 384 # since we have work to do shorten exec time 385 periods -exec .05 386 command $run 387 end 388 389 # default exit status 390 task.exit default 391 process_exit fullForceSummary $options:0 $JOB_STATUS 392 end 393 394 # locked list 395 task.exit crash 396 showcommand crash 397 echo "hostname: $JOB_HOSTNAME" 398 book setword fullForceSummary $options:0 pantaskState CRASH 399 end 400 401 # operation timed out? 402 task.exit timeout 403 showcommand timeout 404 book setword fullForceSummary $options:0 pantaskState TIMEOUT 405 end 406 end 407 408 task fullforce.summary.revert 409 host local 410 411 periods -poll 10.0 412 periods -exec 1200.0 413 periods -timeout 120.0 414 npending 1 415 active true 416 417 stdout NULL 418 stderr $LOGDIR/fullforce.summary.revert.log 419 420 task.exec 421 if ($LABEL:n == 0) break 422 # Only revert failures with fault=2 (SYS_ERROR), which tend to be 423 # temporary filesystem problems. Every other fault type is 424 # interesting and should be kept for debugging (and so it does not 425 # continue to occur). 426 $run = fftool -revertsummary -fault 2 427 if ($DB:n == 0) 428 option DEFAULT 429 else 430 # save the DB name for the exit tasks 431 option $DB:$fullForceSummary_revert_DB 432 $run = $run -dbname $DB:$fullForceSummary_revert_DB 433 $fullForceSummary_revert_DB ++ 434 if ($fullForceSummary_revert_DB >= $DB:n) set fullForceSummary_revert_DB = 0 435 end 436 add_poll_labels run 437 command $run 438 end 439 440 # success 441 task.exit 0 442 end 443 444 # locked list 445 task.exit default 446 showcommand failure 447 end 448 449 task.exit crash 450 showcommand crash 451 end 452 453 # operation times out? 454 task.exit timeout 455 showcommand timeout 456 end 457 end 458 -
branches/bills_branches/bills_201312/ippTools/share/Makefile.am
r36409 r36417 493 493 fftool_result.sql \ 494 494 fftool_revert.sql \ 495 fftool_todo.sql 495 fftool_revertsummary.sql \ 496 fftool_summary.sql \ 497 fftool_todo.sql \ 498 fftool_toadvance.sql 496 499 -
branches/bills_branches/bills_201312/ippTools/src/fftool.c
r36411 r36417 39 39 static bool revertMode(pxConfig *config); 40 40 static bool updateresultMode(pxConfig *config); 41 42 // static bool setfullForceRunState(pxConfig *config, psS64 sky_id, const char *state); 41 static bool toadvanceMode(pxConfig *config); 42 static bool addsummaryMode(pxConfig *config); 43 static bool revertsummaryMode(pxConfig *config); 44 static bool updatesummaryMode(pxConfig *config); 45 static bool summaryMode(pxConfig *config); 46 47 static bool setfullForceRunState(pxConfig *config, psS64 sky_id, const char *state); 43 48 44 49 # define MODECASE(caseName, func) \ … … 67 72 MODECASE(FFTOOL_MODE_REVERT, revertMode); 68 73 MODECASE(FFTOOL_MODE_UPDATERESULT, updateresultMode); 74 MODECASE(FFTOOL_MODE_TOADVANCE, toadvanceMode); 75 MODECASE(FFTOOL_MODE_ADDSUMMARY, addsummaryMode); 76 MODECASE(FFTOOL_MODE_REVERTSUMMARY, revertsummaryMode); 77 MODECASE(FFTOOL_MODE_UPDATESUMMARY, updatesummaryMode); 78 MODECASE(FFTOOL_MODE_SUMMARY, summaryMode); 69 79 default: 70 80 psAbort("invalid option (this should not happen)"); … … 403 413 } 404 414 405 // the where clause is required and matches the WHERE hook format string406 415 if (!p_psDBRunQuery(config->dbh, query)) { 407 416 psError(PS_ERR_UNKNOWN, false, "database error"); … … 462 471 463 472 // XXX not sure we need a transaction here... 464 if (!psDBTransaction(config->dbh)) {465 psError(PS_ERR_UNKNOWN, false, "database error");466 return false;467 }468 469 473 if (!fullForceResultInsert(config->dbh, 470 474 ff_id, … … 484 488 } 485 489 486 #ifdef notdef487 if (!fault) {488 if (!setfullForceRunState(config, ff_id, "full")) {489 if (!psDBRollback(config->dbh)) {490 psError(PS_ERR_UNKNOWN, false, "database error");491 }492 psError(PS_ERR_UNKNOWN, false, "failed to change staticskyRun state");493 return false;494 }495 }496 #endif497 498 // point of no return499 if (!psDBCommit(config->dbh)) {500 psError(PS_ERR_UNKNOWN, false, "database error");501 return false;502 }503 504 490 return true; 505 491 } … … 594 580 psMetadata *where = psMetadataAlloc(); 595 581 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 582 PXOPT_COPY_S64(config->args, where, "-warp_id", "fullForceResult.warp_id", "=="); 596 583 pxAddLabelSearchArgs(config, where, "-label", "fullForceRun.label", "=="); 597 584 PXOPT_COPY_S16(config->args, where, "-fault", "fullForceResult.fault", "=="); … … 645 632 psMetadata *where = psMetadataAlloc(); 646 633 PXOPT_COPY_S64(config->args, where, "-ff_id", "ff_id", "=="); 647 PXOPT_COPY_S64(config->args, where, "-warp_id", "ff_id", "=="); 648 634 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 649 635 650 636 if (!pxSetFaultCode(config->dbh, "fullForceResult", where, fault, quality)) { … … 656 642 return true; 657 643 } 658 #ifdef notyet 644 659 645 static bool setfullForceRunState(pxConfig *config, psS64 ff_id, const char *state) 660 646 { … … 667 653 return true; 668 654 } 669 #endif 670 655 656 static bool toadvanceMode(pxConfig *config) { 657 PS_ASSERT_PTR_NON_NULL(config, false); 658 659 psMetadata *whereMD = psMetadataAlloc(); 660 PXOPT_COPY_S64(config->args, whereMD, "-ff_id", "ff_id", "=="); 661 pxAddLabelSearchArgs (config, whereMD, "-label", "fullForceRun.label", "=="); 662 pxskycellAddWhere(config, whereMD); 663 664 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 665 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 666 667 psString query = pxDataGet("fftool_toadvance.sql"); 668 if (!query) { 669 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 670 return false; 671 } 672 673 if (!psListLength(whereMD->list)) { 674 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 675 psFree(whereMD); 676 return false; 677 } 678 679 psString whereClause = NULL; 680 psString temp = psDBGenerateWhereConditionSQL(whereMD, NULL); 681 psStringAppend(&whereClause, "\n AND %s", temp); 682 psFree(temp); 683 psFree(whereMD); 684 685 // treat limit == 0 as "no limit" 686 if (limit) { 687 psString limitString = psDBGenerateLimitSQL(limit); 688 psStringAppend(&query, " %s", limitString); 689 psFree(limitString); 690 } 691 692 // the where clause is required and is added to the query by the "WHERE hook" format string 693 if (!p_psDBRunQueryF(config->dbh, query, whereClause)) { 694 psError(PS_ERR_UNKNOWN, false, "database error"); 695 psFree(whereClause); 696 psFree(query); 697 return false; 698 } 699 psFree(whereClause); 700 psFree(query); 701 702 psArray *output = p_psDBFetchResult(config->dbh); 703 if (!output) { 704 psErrorCode err = psErrorCodeLast(); 705 switch (err) { 706 case PS_ERR_DB_CLIENT: 707 psError(PXTOOLS_ERR_SYS, false, "database error"); 708 case PS_ERR_DB_SERVER: 709 psError(PXTOOLS_ERR_PROG, false, "database error"); 710 default: 711 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 712 } 713 714 return false; 715 } 716 if (!psArrayLength(output)) { 717 psTrace("fftool", PS_LOG_INFO, "no rows found"); 718 psFree(output); 719 return true; 720 } 721 722 if (psArrayLength(output)) { 723 // negative simple so the default is true 724 if (!ippdbPrintMetadatas(stdout, output, "fullForceRun", !simple)) { 725 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 726 psFree(output); 727 return false; 728 } 729 } 730 731 psFree(output); 732 return true; 733 } 734 735 static bool addsummaryMode(pxConfig *config) { 736 PS_ASSERT_PTR_NON_NULL(config, false); 737 // required 738 PXOPT_LOOKUP_S64(ff_id, config->args, "-ff_id", true, false); 739 740 // optional 741 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 742 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", true, false); 743 PXOPT_LOOKUP_F32(dtime_script, config->args, "-dtime_script", false, false); 744 PXOPT_LOOKUP_STR(software_ver, config->args, "-software_ver", false, false); 745 746 // default values 747 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 748 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 749 750 if (!psDBTransaction(config->dbh)) { 751 psError(PS_ERR_UNKNOWN, false, "database error"); 752 return false; 753 } 754 755 if (!fullForceSummaryInsert(config->dbh, 756 ff_id, 757 path_base, 758 dtime_script, 759 quality, 760 hostname, 761 software_ver, 762 fault 763 )) { 764 if (!psDBRollback(config->dbh)) { 765 psError(PS_ERR_UNKNOWN, false, "database error"); 766 } 767 psError(PS_ERR_UNKNOWN, false, "database error"); 768 return false; 769 } 770 771 if (!fault) { 772 if (!setfullForceRunState(config, ff_id, "full")) { 773 if (!psDBRollback(config->dbh)) { 774 psError(PS_ERR_UNKNOWN, false, "database error"); 775 } 776 psError(PS_ERR_UNKNOWN, false, "failed to change staticskyRun state"); 777 return false; 778 } 779 } 780 781 // point of no return 782 if (!psDBCommit(config->dbh)) { 783 psError(PS_ERR_UNKNOWN, false, "database error"); 784 return false; 785 } 786 787 return true; 788 } 789 790 static bool revertsummaryMode(pxConfig *config) { 791 PS_ASSERT_PTR_NON_NULL(config, false); 792 793 psMetadata *where = psMetadataAlloc(); 794 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 795 pxAddLabelSearchArgs(config, where, "-label", "fullForceRun.label", "=="); 796 PXOPT_COPY_S16(config->args, where, "-fault", "fullForceSummary.fault", "=="); 797 798 if (!pxskycellAddWhere(config, where)) { 799 psError(PXTOOLS_ERR_CONFIG, false, "failed to add skycell search arguments"); 800 return false; 801 } 802 803 if (!psListLength(where->list)) { 804 psFree(where); 805 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 806 return false; 807 } 808 809 // Delete product 810 psString delete = pxDataGet("fftool_revertsummary.sql"); 811 if (!delete) { 812 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 813 return false; 814 } 815 816 if (psListLength(where->list)) { 817 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 818 psStringAppend(&delete, " AND %s", whereClause); 819 psFree(whereClause); 820 } 821 822 if (!p_psDBRunQuery(config->dbh, delete)) { 823 psError(PS_ERR_UNKNOWN, false, "database error"); 824 psFree(delete); 825 psFree(where); 826 return false; 827 } 828 psFree(delete); 829 830 int numRows = psDBAffectedRows(config->dbh); // Number of row affected 831 psLogMsg("fftool", PS_LOG_INFO, "Deleted %d rows", numRows); 832 833 psFree(where); 834 return true; 835 } 836 static bool updatesummaryMode(pxConfig *config) { 837 PS_ASSERT_PTR_NON_NULL(config, false); 838 839 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 840 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 841 842 psMetadata *where = psMetadataAlloc(); 843 PXOPT_COPY_S64(config->args, where, "-ff_id", "ff_id", "=="); 844 845 846 if (!pxSetFaultCode(config->dbh, "fullForceSummary", where, fault, quality)) { 847 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 848 psFree (where); 849 return false; 850 } 851 psFree (where); 852 return true; 853 } 854 static bool summaryMode(pxConfig *config) { 855 PS_ASSERT_PTR_NON_NULL(config, false); 856 857 psMetadata *where = psMetadataAlloc(); 858 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 859 PXOPT_COPY_S64(config->args, where, "-warp_id", "fullForceInput.warp_id", "=="); 860 PXOPT_COPY_S64(config->args, where, "-skycal_id", "fullForceRun.skycal_id", "=="); 861 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 862 PXOPT_COPY_STR(config->args, where, "-label", "fullForceRun.label", "=="); 863 PXOPT_COPY_STR(config->args, where, "-data_group", "fullForceRun.data_group", "LIKE"); 864 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "LIKE"); 865 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "LIKE"); 866 PXOPT_COPY_S16(config->args, where, "-fault", "staticskyResult.fault", "=="); 867 pxskycellAddWhere(config, where); 868 869 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 870 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 871 872 psString query = pxDataGet("fftool_summary.sql"); 873 if (!query) { 874 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 875 return false; 876 } 877 878 if (psListLength(where->list)) { 879 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 880 psStringAppend(&query, " WHERE %s", whereClause); 881 psFree(whereClause); 882 } else { 883 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 884 return false; 885 } 886 887 psFree(where); 888 889 // treat limit == 0 as "no limit" 890 if (limit) { 891 psString limitString = psDBGenerateLimitSQL(limit); 892 psStringAppend(&query, "\n%s", limitString); 893 psFree(limitString); 894 } 895 896 if (!p_psDBRunQuery(config->dbh, query)) { 897 psError(PS_ERR_UNKNOWN, false, "database error"); 898 psFree(query); 899 return false; 900 } 901 psFree(query); 902 903 psArray *output = p_psDBFetchResult(config->dbh); 904 if (!output) { 905 psErrorCode err = psErrorCodeLast(); 906 switch (err) { 907 case PS_ERR_DB_CLIENT: 908 psError(PXTOOLS_ERR_SYS, false, "database error"); 909 case PS_ERR_DB_SERVER: 910 psError(PXTOOLS_ERR_PROG, false, "database error"); 911 default: 912 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 913 } 914 915 return false; 916 } 917 if (!psArrayLength(output)) { 918 psTrace("fftool", PS_LOG_INFO, "no rows found"); 919 psFree(output); 920 return true; 921 } 922 923 if (psArrayLength(output)) { 924 if (!ippdbPrintMetadatas(stdout, output, "fullForceSummary", !simple)) { 925 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 926 psFree(output); 927 return false; 928 } 929 } 930 931 psFree(output); 932 933 return true; 934 } -
branches/bills_branches/bills_201312/ippTools/src/fftool.h
r36386 r36417 32 32 FFTOOL_MODE_REVERT, 33 33 FFTOOL_MODE_UPDATERESULT, 34 FFTOOL_MODE_TOADVANCE, 35 FFTOOL_MODE_ADDSUMMARY, 36 FFTOOL_MODE_REVERTSUMMARY, 37 FFTOOL_MODE_UPDATESUMMARY, 38 FFTOOL_MODE_SUMMARY 34 39 } fftoolMode; 35 40 -
branches/bills_branches/bills_201312/ippTools/src/fftoolConfig.c
r36409 r36417 123 123 psMetadata *revertArgs= psMetadataAlloc(); 124 124 psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-ff_id", 0, "search by full force ID", 0); 125 psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 125 126 psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", 0); 126 127 psMetadataAddS16(revertArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); … … 134 135 psMetadataAddS16(updateresultArgs, PS_LIST_TAIL, "-quality", 0, "set quality code", 0); 135 136 137 // -toadvance 138 psMetadata *toadvanceArgs = psMetadataAlloc(); 139 psMetadataAddS64(toadvanceArgs, PS_LIST_TAIL, "-ff_id", 0, "search by full force ID", 0); 140 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 141 pxskycellAddArguments(toadvanceArgs); 142 psMetadataAddU64(toadvanceArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 143 psMetadataAddBool(toadvanceArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 144 145 // -addsummary 146 psMetadata *addsummaryArgs = psMetadataAlloc(); 147 psMetadataAddS64(addsummaryArgs, PS_LIST_TAIL, "-ff_id", 0, "define full force ID (required)", 0); 148 psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location(required)", 0); 149 psMetadataAddF32(addsummaryArgs, PS_LIST_TAIL, "-dtime_script", 0, "define elapsed time in script (seconds)", NAN); 150 psMetadataAddS16(addsummaryArgs, PS_LIST_TAIL, "-quality", 0, "set quality", 0); 151 psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 152 psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-software_ver", 0, "define software version", 0); 153 psMetadataAddS16(addsummaryArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 154 155 // -updatesummary 156 psMetadata *updatesummaryArgs = psMetadataAlloc(); 157 psMetadataAddS64(updatesummaryArgs, PS_LIST_TAIL, "-ff_id", 0, "define full force ID (required)", 0); 158 psMetadataAddStr(updatesummaryArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", 0); 159 psMetadataAddF32(updatesummaryArgs, PS_LIST_TAIL, "-dtime_script", 0, "define elapsed time in script (seconds)", NAN); 160 psMetadataAddS16(updatesummaryArgs, PS_LIST_TAIL, "-quality", 0, "set quality", 0); 161 psMetadataAddStr(updatesummaryArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 162 psMetadataAddStr(updatesummaryArgs, PS_LIST_TAIL, "-software_ver", 0, "define software version", 0); 163 psMetadataAddS16(updatesummaryArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 164 165 // -summary 166 psMetadata *summaryArgs= psMetadataAlloc(); 167 psMetadataAddS64(summaryArgs, PS_LIST_TAIL, "-ff_id", 0, "search by full force ID", 0); 168 psMetadataAddS64(summaryArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 169 psMetadataAddS64(summaryArgs, PS_LIST_TAIL, "-skycal_id", 0, "search by skycal ID", 0); 170 psMetadataAddS64(summaryArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack ID", 0); 171 psMetadataAddStr(summaryArgs, PS_LIST_TAIL, "-filter", 0, "search by filter (LIKE comparison)", 0); 172 psMetadataAddStr(summaryArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tess ID (LIKE comparison)", 0); 173 psMetadataAddStr(summaryArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID (LIKE comparison)", 0); 174 psMetadataAddStr(summaryArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 175 psMetadataAddStr(summaryArgs, PS_LIST_TAIL, "-data_group", 0, "search by data_group (LIKE comparison)", NULL); 176 pxskycellAddArguments(summaryArgs); 177 psMetadataAddS16(summaryArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 178 psMetadataAddU64(summaryArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 179 psMetadataAddBool(summaryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 180 181 // -revertsummary 182 psMetadata *revertsummaryArgs= psMetadataAlloc(); 183 psMetadataAddS64(revertsummaryArgs, PS_LIST_TAIL, "-ff_id", 0, "search by full force ID", 0); 184 psMetadataAddStr(revertsummaryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", 0); 185 psMetadataAddS16(revertsummaryArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 186 pxskycellAddArguments(revertsummaryArgs); 187 136 188 psFree(now); 137 189 … … 142 194 PXOPT_ADD_MODE("-updaterun", "Update a run", FFTOOL_MODE_UPDATERUN, updaterunArgs); 143 195 PXOPT_ADD_MODE("-todo", "Get runs to do", FFTOOL_MODE_TODO, todoArgs); 144 PXOPT_ADD_MODE("-addresult", "Add result of run", FFTOOL_MODE_ADDRESULT, addresultArgs); 145 PXOPT_ADD_MODE("-result", "Get result of run", FFTOOL_MODE_RESULT, resultArgs); 146 PXOPT_ADD_MODE("-revert", "Revert failed run", FFTOOL_MODE_REVERT, revertArgs); 147 PXOPT_ADD_MODE("-updateresult", "Update fault for run", FFTOOL_MODE_UPDATERESULT, updateresultArgs); 196 PXOPT_ADD_MODE("-addresult", "Add result for fullforce run on a warp", FFTOOL_MODE_ADDRESULT, addresultArgs); 197 PXOPT_ADD_MODE("-result", "Get result fullforce run on a warp", FFTOOL_MODE_RESULT, resultArgs); 198 PXOPT_ADD_MODE("-revert", "Revert failed fullforce run on a warp", FFTOOL_MODE_REVERT, revertArgs); 199 PXOPT_ADD_MODE("-updateresult", "Update result for fullforce run on a warp", FFTOOL_MODE_UPDATERESULT, updateresultArgs); 200 PXOPT_ADD_MODE("-toadvance", "list completed runs to summarize", FFTOOL_MODE_TOADVANCE, toadvanceArgs); 201 PXOPT_ADD_MODE("-addsummary", "insert summary result", FFTOOL_MODE_ADDSUMMARY, addsummaryArgs); 202 PXOPT_ADD_MODE("-updatesummary", "update summary result", FFTOOL_MODE_UPDATESUMMARY, updatesummaryArgs); 203 PXOPT_ADD_MODE("-revertsummary", "revert faulted summary", FFTOOL_MODE_REVERTSUMMARY, revertsummaryArgs); 204 PXOPT_ADD_MODE("-summary", "list summary results", FFTOOL_MODE_SUMMARY, summaryArgs); 148 205 149 206 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note:
See TracChangeset
for help on using the changeset viewer.
