IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2012, 5:24:19 PM (14 years ago)
Author:
mhuber
Message:

merging latest r34040 trunk changes to branch

Location:
branches/meh_branches/ppstack_test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/meh_branches/ppstack_test

  • branches/meh_branches/ppstack_test/ippTools/src

  • branches/meh_branches/ppstack_test/ippTools/src/addtool.c

    r33415 r34041  
    141141    pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
    142142    PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
    143     pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
    144     }
    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", "==");
    150143    //no filter here
    151144    }
     
    227220    }
    228221    }
     222 
    229223    if (strcmp(stage,"staticsky") == 0) {
    230     if (dvodb ) {
    231       psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_dvo.sql\n%s\n", dvodb,stage);
    232         // find the cam_id of all the exposures that we want to queue up.
    233         bare_query = pxDataGet("addtool_find_sky_id_dvo.sql");
    234         // user supplied dvodb
    235         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    236     } else {
    237       psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id.sql\n%s\n",stage);
    238         // find the cam_id of all the exposures that we want to queue up.
    239         bare_query = pxDataGet("addtool_find_sky_id.sql");
    240         // inherit dvodb from camRun, avoid matching NULL
    241         psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
    242     }
    243     }
    244 
    245     if (strcmp(stage,"staticsky_multi") == 0) {
    246224      if (dvodb ) {
    247225        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
     
    310288        psStringAppend(&query, " GROUP BY stack_id");
    311289      }
     290      //   if (strcmp(stage,"staticsky") == 0) {
     291      //   psStringAppend(&query, " GROUP BY stack_id");
     292      // }
    312293    if (strcmp(stage,"staticsky") == 0) {
    313         psStringAppend(&query, " GROUP BY stack_id");
    314       }
    315     if (strcmp(stage,"staticsky_multi") == 0) {
    316       psStringAppend(&query, " GROUP BY sky_id");  //some reason it needs this
     294      psStringAppend(&query, " GROUP BY sky_id, stack_id");  //some reason it needs this
    317295      }
    318296
     
    402380    }
    403381    }
     382   
    404383    if (strcmp(stage,"staticsky") == 0) {
    405     for (long i = 0; i < psArrayLength(output); i++) {
    406         psMetadata *md = output->data[i];
    407 
    408         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    409        
    410         if (!row) {
    411             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    412             psFree(output);
    413             return false;
    414         }
    415 
    416         if (!dvodb) {  //there's no staticsky.dvodb
    417             psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    418             psFree(output);
    419             return false;
    420         }
    421         if (!workdir && !row->workdir) {
    422             psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    423             psFree(output);
    424             return false;
    425         }
    426 
    427         psFree(row);
    428     }
    429     }
    430     if (strcmp(stage,"staticsky_multi") == 0) {
    431384    for (long i = 0; i < psArrayLength(output); i++) {
    432385        psMetadata *md = output->data[i];
     
    566519    }
    567520      }
     521   
    568522    if (strcmp(stage,"staticsky") == 0) {
    569523    for (long i = 0; i < psArrayLength(output); i++) {
    570524        psMetadata *md = output->data[i];
    571525        psS64 stage_id =0;
    572        
     526        bool status = false;
     527        //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     528        psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");
     529
     530        if (!status) {
     531          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");
     532          return false;
     533        }
    573534        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    574535        stage_id = row->sky_id;
     
    581542
    582543        // queue the exp
    583         if (!pxaddQueueByCamID(config,
     544        //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
     545          if (!pxaddQueueByCamID(config,
    584546                               stage,
    585                                stage_id,
    586                                0,
     547                               stage_id,
     548                               stack_id,
    587549                               workdir     ? workdir   : row->workdir,
    588550                               reduction   ? reduction : row->reduction,
     
    595557                               minidvodb_group,
    596558                               minidvodb_name
    597         )) {
     559                                )) {
    598560            if (!psDBRollback(config->dbh)) {
    599                 psError(PS_ERR_UNKNOWN, false, "database error sfg");
     561              psError(PS_ERR_UNKNOWN, false, "database error sfg");
    600562            }
    601563            psError(PS_ERR_UNKNOWN, false,
     
    604566            psFree(output);
    605567            return false;
    606         }
    607         psFree(row);
    608     }
    609       }
    610 
    611     if (strcmp(stage,"staticsky_multi") == 0) {
    612     for (long i = 0; i < psArrayLength(output); i++) {
    613         psMetadata *md = output->data[i];
    614         psS64 stage_id =0;
    615         bool status = false;
    616         psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
    617         if (!status) {
    618           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
    619           return false;
    620         }
    621         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    622         stage_id = row->sky_id;
    623        
    624         if (!row) {
    625             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    626             psFree(output);
    627             return false;
    628         }
    629 
    630         // queue the exp
    631         for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
    632         if (!pxaddQueueByCamID(config,
    633                                stage,
    634                                stage_id,
    635                                filter_id,
    636                                workdir     ? workdir   : row->workdir,
    637                                reduction   ? reduction : row->reduction,
    638                                label       ? label     : row->label,
    639                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    640                                dvodb       ? dvodb     : NULL,
    641                                note        ? note      : NULL,
    642                                image_only,
    643                                minidvodb,
    644                                minidvodb_group,
    645                                minidvodb_name
    646         )) {
    647             if (!psDBRollback(config->dbh)) {
    648                 psError(PS_ERR_UNKNOWN, false, "database error sfg");
    649             }
    650             psError(PS_ERR_UNKNOWN, false,
    651                     "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    652             psFree(row);
    653             psFree(output);
    654             return false;
    655         }
    656         }
     568          }
     569          //}
    657570        psFree(row);
    658571    }
     
    705618    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
    706619    }
    707     if (strcmp(stage, "staticsky_multi")==0) {
    708     query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
    709     }
     620   
    710621
    711622    // pxUpdateRun gets parameters from config->args and runs the update query
     
    745656    }
    746657    if (strcmp(stage, "staticsky")==0) {
    747     query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
    748     }
    749     if (strcmp(stage, "staticsky_multi")==0) {
    750658    query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
    751659    }
     
    768676      psStringAppend(&query, " GROUP BY %s", "stack_id");
    769677    }
     678    //if (strcmp(stage, "staticsky") == 0) {
     679    //  //this group by is needed to join against all the warps (to get camera)
     680    //  psStringAppend(&query, " GROUP BY %s", "sky_id");
     681    //}
    770682    if (strcmp(stage, "staticsky") == 0) {
    771       //this group by is needed to join against all the warps (to get camera)
    772       psStringAppend(&query, " GROUP BY %s", "sky_id");
    773     }
    774     if (strcmp(stage, "staticsky_multi") == 0) {
    775683      //this group by is needed to join against all the warps (to get camera)
    776684      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
     
    787695        return false;
    788696    }
     697    psTrace("addtool.c", PS_LOG_INFO, "used this query:\n %s\n",query);
    789698    psFree(query);
    790699
     
    977886    }
    978887    if (strcmp (stage,"staticsky") == 0) {
    979     query = pxDataGet("addtool_find_processedexp_staticsky.sql");
    980     }
    981     if (strcmp (stage,"staticsky_multi") == 0) {
    982888    query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
    983889    }
     
    1090996         query = pxDataGet("addtool_revertprocessedexp_stack.sql");
    1091997      }
    1092      if (strcmp(stage, "staticsky") == 0) {
    1093          query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
    1094       }
    1095    if (strcmp(stage, "staticsky_multi") == 0) {
     998    if (strcmp(stage, "staticsky") == 0) {
    1096999         query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
    10971000      }
     
    14801383  PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "==");
    14811384  PXOPT_COPY_STR(config->args, where, "-state", "minidvodbRun.state", "==");
    1482 
    1483 
     1385  PXOPT_LOOKUP_STR(minidvodb_group,  config->args, "-minidvodb_group", false, false);
     1386 
    14841387  PXOPT_LOOKUP_U64(limit,      config->args, "-limit", false, false);
    14851388  PXOPT_LOOKUP_BOOL(all_addrun_states, config->args, "-all_addrun_states", false);
     
    14931396  }
    14941397
    1495   psString query = pxDataGet("addtool_checkminidvodbaddrun.sql");
    1496 
    1497   if (!query) {
     1398  if (!minidvodb_group) {
     1399    psError(PXTOOLS_ERR_CONFIG, false, "minidvodb_group  required");
     1400    return false;
     1401  }
     1402
     1403
     1404  psString bare_query = pxDataGet("addtool_checkminidvodbaddrun.sql");
     1405 
     1406  if (!bare_query) {
    14981407        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    14991408        return false;
    15001409  }
    15011410
    1502 
     1411  psString where_string = NULL;
    15031412  if (psListLength(where->list)) {
    15041413    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1505         psStringAppend(&query, " WHERE %s", whereClause);
     1414        psStringAppend(&where_string, " WHERE %s", whereClause);
    15061415        psFree(whereClause);
    1507   }
    1508 
     1416        //search params are defined above
     1417  }
     1418
     1419  psString query = NULL;
     1420  psStringAppend(&query, bare_query, minidvodb_group);
     1421  psStringAppend(&query," %s ", where_string);
     1422
     1423
     1424
     1425
     1426 
    15091427  if (!all_addrun_states) {
    15101428    psStringAppend(&query, " AND (cnt2 = cnt) ");
     
    15191437
    15201438  if (!p_psDBRunQuery(config->dbh, query)) {
    1521     psError(PS_ERR_UNKNOWN, false, "database error");
     1439    psError(PS_ERR_UNKNOWN, false, "database error,\n\n%s", query);
    15221440    psFree(query);
    15231441    return false;
Note: See TracChangeset for help on using the changeset viewer.