IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 14, 2009, 11:06:18 AM (17 years ago)
Author:
bills
Message:

Add data_group, dist_group, and note to the pipeline. These new columns will be used
for some of the tasks that label was used previously.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/magicdstool.c

    r25822 r25835  
    3333
    3434static bool definebyqueryMode(pxConfig *config);
    35 static psS64 definerunMode(pxConfig *config);
    3635static bool updaterunMode(pxConfig *config);
    3736static bool todestreakMode(pxConfig *config);
     
    4645
    4746static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psMetadata *where, const char *state);
    48 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id);
    4947
    5048# define MODECASE(caseName, func) \
     
    6765    switch (config->mode) {
    6866        MODECASE(MAGICDSTOOL_MODE_DEFINEBYQUERY,       definebyqueryMode);
    69         MODECASE(MAGICDSTOOL_MODE_DEFINERUN,           definerunMode);
    7067        MODECASE(MAGICDSTOOL_MODE_UPDATERUN,           updaterunMode);
    7168        MODECASE(MAGICDSTOOL_MODE_TODESTREAK,          todestreakMode);
     
    110107    PXOPT_LOOKUP_BOOL(noreplace, config->args, "-noreplace", false);
    111108    PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false);
     109    PXOPT_LOOKUP_STR(set_data_group, config->args, "-set_data_group", false, false);
     110    PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false);
    112111    PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false);
    113112    PXOPT_LOOKUP_BOOL(dry_run, config->args, "-dry_run", false);
     
    248247        psS64 cam_id = psMetadataLookupS64(NULL, row, "cam_id");
    249248        psString magicRunLabel = psMetadataLookupStr(NULL, row, "label");
     249        psString magicRunDataGroup = psMetadataLookupStr(NULL, row, "data_group");
    250250        psString magicRunWorkdir = psMetadataLookupStr(NULL, row, "workdir");
    251251       
     
    269269                cam_id,
    270270                set_label ? set_label : magicRunLabel,
     271                set_data_group ? set_data_group : magicRunDataGroup,
    271272                outroot,
    272273                recoveryroot,
    273274                noreplace ? 0 :1,   // re_place
    274                 0); // remove
     275                0,      // remove
     276                0,      // fault
     277                note);  // remove
    275278
    276279        psFree(outroot);
     
    315318}
    316319
    317 static psS64 definerunMode(pxConfig *config)
    318 {
    319     PS_ASSERT_PTR_NON_NULL(config, false);
    320 
    321     // required
    322     PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
    323     PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);
    324     PXOPT_LOOKUP_STR(outroot, config->args, "-outroot", true, false);
    325 
    326     // optional
    327     PXOPT_LOOKUP_STR(recoveryroot, config->args, "-recoveryroot", false, false);
    328     PXOPT_LOOKUP_BOOL(re_place, config->args, "-replace", false);
    329     PXOPT_LOOKUP_BOOL(remove, config->args, "-remove", false);
    330     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    331     PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
    332 
    333     psS64 stage_id = 0, cam_id = 0;
    334 
    335     if (!magicDSGetIDs(config, stage, magic_id, &stage_id, &cam_id)) {
    336         psError(PS_ERR_UNKNOWN, false, "failed to get ids");
    337         return false;
    338     }
    339 
    340     magicDSRunRow *run = magicDSRunRowAlloc(
    341             0,          // ID
    342             magic_id,
    343             0,          // inv_magic_id
    344             "new",      // state
    345             stage,
    346             stage_id,
    347             cam_id,
    348             label,
    349             outroot,
    350             recoveryroot,
    351             re_place,
    352             remove
    353     );
    354 
    355     if (!run) {
    356         psError(PS_ERR_UNKNOWN, false, "failed to alloc magicRun object");
    357         return false;
    358     }
    359     if (!magicDSRunInsertObject(config->dbh, run)) {
    360         psError(PS_ERR_UNKNOWN, false, "database error");
    361         psFree(run);
    362         return false;
    363     }
    364 
    365     psS64 magic_ds_id = psDBLastInsertID(config->dbh);
    366     run->magic_ds_id = magic_ds_id;
    367 
    368     if (!magicDSRunPrintObject(stdout, run, !simple)) {
    369             psError(PS_ERR_UNKNOWN, false, "failed to print object");
    370             psFree(run);
    371             return false;
    372     }
    373 
    374     psFree(run);
    375 
    376     return magic_id;
    377 }
    378 
    379320
    380321static bool updaterunMode(pxConfig *config)
     
    696637}
    697638
    698 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id)
    699 {
    700     PS_ASSERT_PTR_NON_NULL(config, false);
    701     PS_ASSERT_PTR_NON_NULL(stage, false);
    702     PS_ASSERT_PTR_NON_NULL(stage_id, false);
    703     PS_ASSERT_PTR_NON_NULL(cam_id, false);
    704 
    705     int stageNum = ippStringToStage(stage);;
    706     if (stageNum == IPP_STAGE_NONE) {
    707         psError(PXTOOLS_ERR_DATA, false, "%s is not a valid value for stage", stage);
    708         return false;
    709     }
    710 
    711     psString query = pxDataGet("magicdstool_getrunids.sql");
    712     if (!query) {
    713         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    714         return false;
    715     }
    716 
    717     if (!p_psDBRunQueryF(config->dbh, query, magic_id)) {
    718         psError(PS_ERR_UNKNOWN, false, "database error");
    719         psFree(query);
    720         return false;
    721     }
    722     psFree(query);
    723 
    724     psArray *output = p_psDBFetchResult(config->dbh);
    725     if (!output) {
    726         psError(PS_ERR_UNKNOWN, false, "database error");
    727         return false;
    728     }
    729     if (!psArrayLength(output)) {
    730         psTrace("magicdstool", PS_LOG_INFO, "no rows found");
    731         psFree(output);
    732         return true;
    733     }
    734     if (psArrayLength(output) > 1) {
    735         psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_id %" PRId64,
    736             psArrayLength(output), magic_id);
    737         return false;
    738     }
    739     psMetadata *row = output->data[0];
    740 
    741     *cam_id = psMetadataLookupS64(NULL, row, "cam_id");
    742     switch (stageNum) {
    743     case IPP_STAGE_RAW:
    744         *stage_id = psMetadataLookupS64(NULL, row, "exp_id");
    745         break;
    746     case IPP_STAGE_CHIP:
    747         *stage_id = psMetadataLookupS64(NULL, row, "chip_id");
    748         break;
    749     case IPP_STAGE_CAMERA:
    750         *stage_id = *cam_id;
    751         return true;
    752     case IPP_STAGE_WARP:
    753         *stage_id = psMetadataLookupS64(NULL, row, "warp_id");
    754         break;
    755     case IPP_STAGE_DIFF:
    756         *stage_id = psMetadataLookupS64(NULL, row, "diff_id");
    757         break;
    758     }
    759 
    760     return true;
    761 }
    762639
    763640static bool advancerunMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.