Changeset 35960
- Timestamp:
- Aug 15, 2013, 4:05:13 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
-
ippScripts/scripts/dist_advancerun.pl (modified) (2 diffs)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/disttool_pending_skycal.sql (modified) (1 diff)
-
ippTools/share/disttool_toadvance.sql (modified) (1 diff)
-
ippTools/share/staticskytool_export_skycalresult.sql (added)
-
ippTools/share/staticskytool_export_skycalrun.sql (added)
-
ippTools/share/staticskytool_skycalresult.sql (modified) (1 diff)
-
ippTools/src/staticskytool.c (modified) (4 diffs)
-
ippTools/src/staticskytool.h (modified) (1 diff)
-
ippTools/src/staticskytoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/dist_advancerun.pl
r31565 r35960 115 115 $list_mode = "-result"; 116 116 $component_key = "skycell_id"; 117 } elsif ($stage eq "skycal") { 118 $tool_cmd = "$staticskytool -skycal_id"; 119 $list_mode = "-skycalresult"; 120 $component_key = "skycell_id"; 117 121 } elsif ($stage eq "diff") { 118 122 $tool_cmd = "$difftool -diff_id"; … … 134 138 } elsif ($stage eq 'warp_bg') { 135 139 $exportarg = '-exportwarp'; 140 } elsif ($stage eq 'skycal') { 141 $exportarg = '-exportskycalrun'; 136 142 } 137 143 -
trunk/ippTools/share/Makefile.am
r35955 r35960 410 410 staticskytool_export_input.sql \ 411 411 staticskytool_export_result.sql \ 412 staticskytool_export_skycalrun.sql \ 413 staticskytool_export_skycalresult.sql \ 412 414 staticskytool_inputs.sql \ 413 415 staticskytool_todo.sql \ -
trunk/ippTools/share/disttool_pending_skycal.sql
r35955 r35960 38 38 JOIN chipRun 39 39 USING(chip_id) 40 -- ON camRun.chip_id = chipRun.chip_id41 40 JOIN rawExp 42 41 USING (exp_id) -
trunk/ippTools/share/disttool_toadvance.sql
r32710 r35960 262 262 AND distComponent.fault = 0 263 263 UNION 264 -- skycal stage 265 -- NOTE this assumes that there is only one component per skycalRun 266 -- (one skycell) 267 SELECT 268 distRun.dist_id, 269 stage, 270 stage_id, 271 outroot, 272 label, 273 clean 274 FROM distRun 275 JOIN skycalResult on stage_id = skycal_id 276 LEFT JOIN distComponent 277 ON distRun.dist_id = distComponent.dist_id 278 WHERE 279 distRun.state = 'new' 280 AND distRun.fault = 0 281 AND distRun.stage = 'skycal' 282 AND distComponent.component IS NOT NULL 283 AND distComponent.fault = 0 284 UNION 264 285 -- SSdiff stage 265 286 SELECT -
trunk/ippTools/share/staticskytool_skycalresult.sql
r35952 r35960 2 2 skycalResult.*, 3 3 skycalRun.stack_id, 4 skycalRun.workdir, 4 5 stackRun.filter, 5 6 skycalRun.state, -
trunk/ippTools/src/staticskytool.c
r35194 r35960 50 50 static bool revertskycalresultMode(pxConfig *config); 51 51 static bool updateskycalresultMode(pxConfig *config); 52 static bool exportskycalrunMode(pxConfig *config); 53 static bool importskycalrunMode(pxConfig *config); 52 54 53 55 static bool setstaticskyRunState(pxConfig *config, psS64 sky_id, const char *state); … … 88 90 MODECASE(STATICSKYTOOL_MODE_REVERTSKYCALRESULT,revertskycalresultMode); 89 91 MODECASE(STATICSKYTOOL_MODE_SKYCALRESULT, skycalresultMode); 92 MODECASE(STATICSKYTOOL_MODE_EXPORTSKYCALRUN, exportskycalrunMode); 93 MODECASE(STATICSKYTOOL_MODE_IMPORTSKYCALRUN, importskycalrunMode); 90 94 default: 91 95 psAbort("invalid option (this should not happen)"); … … 895 899 bool importrunMode(pxConfig *config) 896 900 { 897 # if (0) 898 unsigned int nFail; 899 900 int numImportTables = 2; 901 902 char tables[2] [80] = {"stackInputSkyfile", "stackSumSkyfile"}; 901 return false; 902 } 903 904 bool exportskycalrunMode(pxConfig *config) 905 { 906 typedef struct ExportTable { 907 char tableName[80]; 908 char sqlFilename[80]; 909 } ExportTable; 910 911 int numExportTables = 2; 903 912 904 913 PS_ASSERT_PTR_NON_NULL(config, NULL); 905 914 906 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 907 908 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 909 910 #ifdef notdef 911 fprintf (stderr, "---- input ----\n"); 912 psMetadataPrint (stderr, input, 1); 913 #endif 914 915 if (!pxCheckImportVersion(config, input)) { 916 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 915 // XXX unused PXOPT_LOOKUP_S64(det_id, config->args, "-sky_id", true, false); 916 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 917 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); 918 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 919 920 FILE *f = fopen (outfile, "w"); 921 if (f == NULL) { 922 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 917 923 return false; 918 924 } 919 psMetadataItem *item = psMetadataLookup (input, "stackRun"); 920 psAssert (item, "entry not in input?"); 921 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 922 923 psMetadataItem *entry = psListGet (item->data.list, 0); 924 assert (entry); 925 assert (entry->type == PS_DATA_METADATA); 926 stackRunRow *stackRun = stackRunObjectFromMetadata (entry->data.md); 927 stackRunInsertObject (config->dbh, stackRun); 928 929 // fprintf (stdout, "---- stack run ----\n"); 930 // psMetadataPrint (stderr, entry->data.md, 1); 931 932 for (int i = 0; i < numImportTables; i++) { 933 psMetadataItem *item = psMetadataLookup (input, tables[i]); 934 psAssert (item, "entry not in input?"); 935 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 936 937 switch (i) { 938 case 0: 939 for (int i = 0; i < item->data.list->n; i++) { 940 entry = psListGet (item->data.list, i); 941 assert (entry); 942 assert (entry->type == PS_DATA_METADATA); 943 stackInputSkyfileRow *stackInputSkyfile = stackInputSkyfileObjectFromMetadata (entry->data.md); 944 stackInputSkyfileInsertObject (config->dbh, stackInputSkyfile); 945 946 // fprintf (stdout, "---- row %d ----\n", i); 947 // psMetadataPrint (stderr, entry->data.md, 1); 948 } 949 break; 950 951 case 1: 952 for (int i = 0; i < item->data.list->n; i++) { 953 entry = psListGet (item->data.list, i); 954 assert (entry); 955 assert (entry->type == PS_DATA_METADATA); 956 stackSumSkyfileRow *stackSumSkyfile = stackSumSkyfileObjectFromMetadata (entry->data.md); 957 stackSumSkyfileInsertObject (config->dbh, stackSumSkyfile); 958 959 // fprintf (stdout, "---- row %d ----\n", i); 960 // psMetadataPrint (stderr, entry->data.md, 1); 961 } 962 break; 963 } 925 926 if (!pxExportVersion(config, f)) { 927 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 928 return false; 964 929 } 965 966 # endif 967 return true; 930 psMetadata *where = psMetadataAlloc(); 931 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycal_id", "=="); 932 933 ExportTable tables [] = { 934 {"skycalRun", "staticskytool_export_skycalrun.sql"}, 935 {"skycalResult", "staticskytool_export_skycalresult.sql"}, 936 }; 937 938 for (int i=0; i < numExportTables; i++) { 939 psString query = pxDataGet(tables[i].sqlFilename); 940 if (!query) { 941 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 942 return false; 943 } 944 945 if (where && psListLength(where->list)) { 946 psString whereClause = psDBGenerateWhereSQL(where, NULL); 947 psStringAppend(&query, " %s", whereClause); 948 psFree(whereClause); 949 } 950 951 // treat limit == 0 as "no limit" 952 if (limit) { 953 psString limitString = psDBGenerateLimitSQL(limit); 954 psStringAppend(&query, " %s", limitString); 955 psFree(limitString); 956 } 957 958 if (!p_psDBRunQuery(config->dbh, query)) { 959 psError(PS_ERR_UNKNOWN, false, "database error"); 960 psFree(query); 961 return false; 962 } 963 psFree(query); 964 965 psArray *output = p_psDBFetchResult(config->dbh); 966 if (!output) { 967 psError(PS_ERR_UNKNOWN, false, "database error"); 968 return false; 969 } 970 if (!psArrayLength(output)) { 971 psError(PS_ERR_UNKNOWN, true, "no rows found"); 972 psFree(output); 973 return false; 974 } 975 976 if (clean) { 977 if (!strcmp(tables[i].tableName, "skycalRun")) { 978 if (!pxSetStateCleaned("skycalRun", "state", output)) { 979 psFree(output); 980 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName); 981 return false; 982 } 983 } 984 } 985 986 // we must write the export table in non-simple (true) format 987 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 988 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 989 psFree(output); 990 return false; 991 } 992 993 psFree(output); 994 } 995 996 fclose (f); 997 998 return true; 999 } 1000 1001 bool importskycalrunMode(pxConfig *config) 1002 { 1003 return false; 968 1004 } 969 1005 … … 986 1022 987 1023 } 988 989 # if (0)990 // now we need to loop over all requested filters and check that each is found991 // XXX is this needed? haven't we required that we only match the requested filters992 // and that N unique filters are found?993 994 psVector *found = psVectorAlloc(inputs->n, PS_TYPE_U8);995 psVectorInit (found, 0);996 997 psMetadataItem *filter = NULL;998 psListIterator *iter = psListIteratorAlloc (filters->data.list, PS_LIST_HEAD, false);999 while ((filter = psListGetAndIncrement(iter))) {1000 1001 bool foundOne = false;1002 1003 psAssert (filter->type == PS_DATA_STR, "filter is not a string?");1004 for (int j = 0; !foundOne && (j < inputs->n); j++) {1005 if (found->data.U8[j]) continue;1006 psMetadata *inputRow = inputs->data[j]; // Row from select1007 1008 // pull out the skycell_id, tess_id, filter1009 psString inFilter = psMetadataLookupStr(&status, row, "filter");1010 psAssert (status);1011 1012 found->data.U8[j] = true;1013 foundOne = true;1014 }1015 if (!foundOne) {1016 // this required filter was not found in the inputs, skip the entry1017 skip();1018 }1019 }1020 # endif1021 1024 1022 1025 static bool defineskycalrunMode(pxConfig *config) -
trunk/ippTools/src/staticskytool.h
r32960 r35960 43 43 STATICSKYTOOL_MODE_SKYCALRESULT, 44 44 STATICSKYTOOL_MODE_REVERTSKYCALRESULT, 45 STATICSKYTOOL_MODE_EXPORTSKYCALRUN, 46 STATICSKYTOOL_MODE_IMPORTSKYCALRUN, 45 47 } staticskytoolMode; 46 48 -
trunk/ippTools/src/staticskytoolConfig.c
r35197 r35960 269 269 psMetadataAddBool(skycalresultArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 270 270 271 // -exportskycalrun 272 psMetadata *exportskycalrunArgs = psMetadataAlloc(); 273 psMetadataAddS64(exportskycalrunArgs, PS_LIST_TAIL, "-skycal_id", 0, "export this skycal ID (required)", 0); 274 psMetadataAddStr(exportskycalrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 275 psMetadataAddU64(exportskycalrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 276 psMetadataAddBool(exportskycalrunArgs, PS_LIST_TAIL, "-clean", 0, "mark tables as cleaned", false); 277 278 // -importrun 279 psMetadata *importskycalrunArgs = psMetadataAlloc(); 280 psMetadataAddStr(importskycalrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 281 282 271 283 psFree(now); 272 284 … … 291 303 PXOPT_ADD_MODE("-updateskycal", "revert faulted skycal run", STATICSKYTOOL_MODE_UPDATESKYCALRESULT, updateskycalresultArgs); 292 304 PXOPT_ADD_MODE("-skycalresult", "Get result of skycal run", STATICSKYTOOL_MODE_SKYCALRESULT, skycalresultArgs); 305 PXOPT_ADD_MODE("-exportskycalrun", "Export skycal run", STATICSKYTOOL_MODE_EXPORTSKYCALRUN, exportskycalrunArgs); 306 PXOPT_ADD_MODE("-importskycalrun", "Import skycal run", STATICSKYTOOL_MODE_IMPORTSKYCALRUN, importskycalrunArgs); 293 307 294 308 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note:
See TracChangeset
for help on using the changeset viewer.
