Changeset 37551 for trunk/ippTools/src/addtool.c
- Timestamp:
- Nov 3, 2014, 2:41:20 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/addtool.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/addtool.c
r35304 r37551 122 122 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 123 123 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 124 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 125 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 126 124 127 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 125 128 if (strcmp(stage, "cam")== 0) { … … 146 149 PXOPT_COPY_STR(config->args, where, "-reduction", "skycalRun.reduction", "=="); 147 150 } 148 151 if (strcmp(stage, "diff")==0) { 152 pxAddLabelSearchArgs (config, where, "-label", "diffRun.label", "=="); //define using skycalRun label 153 pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "=="); 154 PXOPT_COPY_STR(config->args, where, "-reduction", "diffRun.reduction", "=="); 155 } 156 if (strcmp(stage, "fullforce")==0) { 157 pxAddLabelSearchArgs (config, where, "-label", "fullForceRun.label", "=="); //define using skycalRun label 158 pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "=="); 159 PXOPT_COPY_STR(config->args, where, "-reduction", "fullForceRun.reduction", "=="); 160 } 161 162 163 149 164 if (!psListLength(where->list)) { 150 165 psFree(where); … … 258 273 } 259 274 260 275 if (strcmp(stage,"diff") == 0) { 276 if (dvodb ) { 277 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_diff_id_dvo.sql\n%s\n", dvodb,stage); 278 // find the skycal_id of all the exposures that we want to queue up. 279 bare_query = pxDataGet("addtool_find_diff_id_dvo.sql"); 280 // user supplied dvodb 281 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 282 } else { 283 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_diff_id.sql\n%s\n",stage); 284 // find the skycal_id of all the exposures that we want to queue up. 285 bare_query = pxDataGet("addtool_find_diff_id.sql"); 286 // inherit dvodb from skycalRun, avoid matching NULL 287 psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)"); 288 // this is silly, there is no dvodb in skycalRun...? 289 } 290 } 291 292 if (strcmp(stage,"fullforce") == 0) { 293 if (dvodb ) { 294 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ff_id_dvo.sql\n%s\n", dvodb,stage); 295 // find the skycal_id of all the exposures that we want to queue up. 296 bare_query = pxDataGet("addtool_find_ff_id_dvo.sql"); 297 // user supplied dvodb 298 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 299 } else { 300 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ff_id.sql\n%s\n",stage); 301 // find the skycal_id of all the exposures that we want to queue up. 302 bare_query = pxDataGet("addtool_find_ff_id.sql"); 303 // inherit dvodb from skycalRun, avoid matching NULL 304 psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)"); 305 // this is silly, there is no dvodb in skycalRun...? 306 } 307 } 261 308 262 309 … … 324 371 psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 325 372 } 373 //needs to be checked HAF xxx 374 if (strcmp(stage,"diff") == 0) { 375 psStringAppend(&query, " GROUP BY diff_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 376 } 377 //needs to be checked HAF xxx 378 if (strcmp(stage,"fullforce") == 0) { 379 psStringAppend(&query, " GROUP BY ff_id, skycal_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 380 } 381 382 383 326 384 327 385 psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query); … … 476 534 } 477 535 536 if (strcmp(stage,"diff") == 0) { 537 for (long i = 0; i < psArrayLength(output); i++) { 538 psMetadata *md = output->data[i]; 539 540 diffRunRow *row = diffRunObjectFromMetadata(md); 541 542 if (!row) { 543 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 544 psFree(output); 545 return false; 546 } 547 548 if (!dvodb) { // there's no skycalRun.dvodb 549 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id); 550 psFree(output); 551 return false; 552 } 553 if (!workdir && !row->workdir) { 554 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id); 555 psFree(output); 556 return false; 557 } 558 559 psFree(row); 560 } 561 } 562 563 if (strcmp(stage,"fullforce") == 0) { 564 for (long i = 0; i < psArrayLength(output); i++) { 565 psMetadata *md = output->data[i]; 566 567 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 568 569 if (!row) { 570 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 571 psFree(output); 572 return false; 573 } 574 575 if (!dvodb) { // there's no skycalRun.dvodb 576 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id); 577 psFree(output); 578 return false; 579 } 580 if (!workdir && !row->workdir) { 581 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id); 582 psFree(output); 583 return false; 584 } 585 586 psFree(row); 587 } 588 } 478 589 479 590 … … 672 783 } 673 784 785 if (strcmp(stage,"diff") == 0) { 786 for (long i = 0; i < psArrayLength(output); i++) { 787 psMetadata *md = output->data[i]; 788 psS64 stage_id =0; 789 790 diffRunRow *row = diffRunObjectFromMetadata(md); 791 stage_id = row->diff_id; 792 793 if (!row) { 794 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 795 psFree(output); 796 return false; 797 } 798 799 // queue the exp 800 if (!pxaddQueueByCamID(config, 801 stage, 802 stage_id, 803 0, 804 workdir ? workdir : row->workdir, 805 reduction ? reduction : row->reduction, 806 label ? label : row->label, 807 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 808 dvodb ? dvodb : NULL, 809 note ? note : NULL, 810 image_only, 811 minidvodb, 812 minidvodb_group, 813 minidvodb_name 814 )) { 815 if (!psDBRollback(config->dbh)) { 816 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 817 } 818 psError(PS_ERR_UNKNOWN, false, 819 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 820 psFree(row); 821 psFree(output); 822 return false; 823 } 824 psFree(row); 825 } 826 } 827 828 if (strcmp(stage,"fullforce") == 0) { 829 for (long i = 0; i < psArrayLength(output); i++) { 830 psMetadata *md = output->data[i]; 831 psS64 stage_id =0; 832 833 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 834 stage_id = row->ff_id; 835 836 if (!row) { 837 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 838 psFree(output); 839 return false; 840 } 841 842 // queue the exp 843 if (!pxaddQueueByCamID(config, 844 stage, 845 stage_id, 846 0, 847 workdir ? workdir : row->workdir, 848 reduction ? reduction : row->reduction, 849 label ? label : row->label, 850 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 851 dvodb ? dvodb : NULL, 852 note ? note : NULL, 853 image_only, 854 minidvodb, 855 minidvodb_group, 856 minidvodb_name 857 )) { 858 if (!psDBRollback(config->dbh)) { 859 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 860 } 861 psError(PS_ERR_UNKNOWN, false, 862 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 863 psFree(row); 864 psFree(output); 865 return false; 866 } 867 psFree(row); 868 } 869 } 870 871 872 674 873 675 874 … … 695 894 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 696 895 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 896 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 897 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 898 697 899 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 698 900 pxcamGetSearchArgs (config, where); // most search arguments based on camera … … 709 911 psString query = NULL; 710 912 if (strcmp(stage, "cam")==0) { 711 query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_idJOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");913 query = psStringCopy("UPDATE addRun JOIN camRun on (cam_id = stage_id and stage = 'cam') JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 712 914 } 713 915 if (strcmp(stage, "stack")==0) { 714 query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");916 query = psStringCopy("UPDATE addRun JOIN stackRun on (stack_id = stage_id and stage = 'stack')"); 715 917 } 716 918 if (strcmp(stage, "staticsky")==0) { 717 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");919 query = psStringCopy("UPDATE addRun JOIN staticskyRun on (sky_id = stage_id and stage = 'staticsky')"); 718 920 } 719 921 if (strcmp(stage, "skycal")==0) { 720 query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id"); 922 query = psStringCopy("UPDATE addRun JOIN skycalRun on (skycal_id = stage_id and stage = 'skycal')"); 923 } 924 if (strcmp(stage, "diff")==0) { 925 query = psStringCopy("UPDATE addRun JOIN diffInputSkyfile on (diff_id = stage_id and diff_skyfile_id = stage_extra1 and stage = 'diff') JOIN diffSkyfile on (diff_id, skycell_id) JOIN diffRun using (diff_id)"); 926 } 927 if (strcmp(stage, "fullforce")==0) { 928 query = psStringCopy("UPDATE addRun JOIN fullForceResult on (ff_id = stage_id and warp_id = stage_extra1 and stage = 'fullforce') JOIN fullForceRun on (ff_id)"); 721 929 } 722 930 … … 743 951 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 744 952 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 953 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 954 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 745 955 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 746 956 pxcamGetSearchArgs (config, where); … … 764 974 query = pxDataGet("addtool_find_pendingexp_skycal.sql"); 765 975 } 976 if (strcmp(stage, "diff")==0) { 977 query = pxDataGet("addtool_find_pendingexp_diff.sql"); 978 } 979 if (strcmp(stage, "fullforce")==0) { 980 query = pxDataGet("addtool_find_pendingexp_ff.sql"); 981 } 766 982 767 983 … … 790 1006 psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1"); 791 1007 } 1008 if (strcmp(stage, "diff") == 0) { 1009 //this group by is needed to join against all the warps (to get camera) 1010 psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1"); 1011 } 1012 if (strcmp(stage, "fullforce") == 0) { 1013 //this group by is needed to join against all the warps (to get camera) 1014 psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1"); 1015 } 1016 1017 1018 792 1019 // treat limit == 0 as "no limit" 793 1020 if (limit) { … … 994 1221 } else if (strcmp (stage,"skycal") == 0) { 995 1222 query = pxDataGet("addtool_find_processedexp_skycal.sql"); 1223 } else if (strcmp (stage,"diff") == 0) { 1224 query = pxDataGet("addtool_find_processedexp_diff.sql"); 1225 } else if (strcmp (stage,"fullforce") == 0) { 1226 query = pxDataGet("addtool_find_processedexp_ff.sql"); 1227 996 1228 } else { 997 1229 psFree(where); … … 1112 1344 if (strcmp(stage, "skycal") == 0) { 1113 1345 query = pxDataGet("addtool_revertprocessedexp_skycal.sql"); 1346 } 1347 if (strcmp(stage, "diff") == 0) { 1348 query = pxDataGet("addtool_revertprocessedexp_diff.sql"); 1349 } 1350 if (strcmp(stage, "fullforce") == 0) { 1351 query = pxDataGet("addtool_revertprocessedexp_ff.sql"); 1114 1352 } 1115 1353
Note:
See TracChangeset
for help on using the changeset viewer.
