IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ippTools/src

    • Property svn:ignore
      •  

        old new  
         1*.la
         2*.lo
        13.deps
        24.gdb_history
         
        46Makefile
        57Makefile.in
         8addtool
         9caltool
         10camtool
         11chiptool
        612config.h
        713config.h.in
        8 stamp-h1
        9 *.la
        10 *.lo
         14detselect
         15dettool
         16difftool
         17disttool
         18dqstatstool
         19faketool
         20flatcorr
         21guidetool
         22magicdstool
         23magictool
         24pstamptool
         25pubtool
         26pxadmin
         27pxdata.c
         28pxinject
        1129pxtoolsErrorCodes.c
        1230pxtoolsErrorCodes.h
        13 pxadmin
        14 pxinject
        15 pztool
        1631pzgetexp
        1732pzgetimfiles
         33pztool
         34receivetool
        1835regtool
        19 guidetool
        20 chiptool
        21 camtool
         36stacktool
         37stamp-h1
        2238warptool
        23 difftool
        24 stacktool
        25 faketool
        26 dettool
        27 detselect
        28 pxdata.c
        29 magictool
        30 magicdstool
        31 caltool
        32 flatcorr
        33 pstamptool
        34 disttool
        35 receivetool
        36 
        37 pubtool
  • branches/simtest_nebulous_branches/ippTools/src/magictool.c

    r24949 r27840  
    114114    // Required
    115115    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
     116    PXOPT_LOOKUP_STR(label, config->args, "-label", true, false);
    116117
    117118    // Optional
    118     PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
     119    PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", false, false);
     120    PXOPT_LOOKUP_STR(note, config->args, "-note", false, false);
    119121    PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false);
    120122    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
     
    133135        psString query = pxDataGet("magictool_definebyquery_select.sql");
    134136        if (!query) {
    135             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     137            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    136138            return false;
    137139        }
     
    149151        // what if no skycells for the diff run completed?
    150152
    151         if (!rerun) {
    152             psStringAppend(&queryWhereStr, "\n%s magic_id IS NULL", queryWhereStr ? "AND" : "WHERE");
     153        psStringAppend(&queryWhereStr, "\n%s magic_id IS NULL", queryWhereStr ? "AND" : "WHERE");
     154        psString rerunWhereStr = NULL;
     155        if (rerun) {
     156            psStringAppend(&rerunWhereStr, "\n WHERE magicRun.label = '%s'", label);
    153157        }
    154158
     
    174178            queryWhereStr = psStringCopy("");
    175179        }
    176 
    177         if (!p_psDBRunQueryF(config->dbh, query, diffWhereStr, diffWhereStr, queryWhereStr)) {
     180        if (!rerunWhereStr) {
     181            rerunWhereStr = psStringCopy("");
     182        }
     183
     184        if (!p_psDBRunQueryF(config->dbh, query, diffWhereStr, diffWhereStr, rerunWhereStr, queryWhereStr)) {
    178185            psError(PS_ERR_UNKNOWN, false, "database error");
    179186            psFree(diffWhereStr);
    180187            psFree(queryWhereStr);
     188            psFree(rerunWhereStr);
    181189            psFree(query);
    182190            return false;
     
    184192        psFree(diffWhereStr);
    185193        psFree(queryWhereStr);
     194        psFree(rerunWhereStr);
    186195        psFree(query);
    187196    }
     
    236245
    237246        // create a new magicRun for this group
    238         magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, inverse, "new", workdir, "dirty", label,
    239                                             dvodb, registered, 0);
     247        magicRunRow *run = magicRunRowAlloc(0,
     248                                            exp_id,
     249                                            diff_id,
     250                                            inverse,
     251                                            "new",      // state
     252                                            workdir,
     253                                            "dirty",    // workdir_state
     254                                            label,
     255                                            data_group ? data_group : label,
     256                                            dvodb,
     257                                            registered,
     258                                            0,          // fault
     259                                            note);
    240260        if (!run) {
    241261            psAbort("failed to alloc magicRun object");
     
    331351            "dirty",    // workdir_state
    332352            label,
     353            NULL,       // data_group
    333354            dvodb,
    334355            registered,
    335             0
     356            0,          // fault
     357            NULL
    336358    );
    337359
     
    412434    psString query = pxDataGet("magictool_inputskyfile.sql");
    413435    if (!query) {
    414         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     436        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    415437        return false;
    416438    }
     
    485507    psString query = pxDataGet("magictool_totree.sql");
    486508    if (!query) {
    487         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     509        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    488510        return false;
    489511    }
     
    558580
    559581    if (fault > 0) {
    560         char *query = "UPDATE magicRun SET fault = %d, state = 'full' WHERE magic_id = %" PRId64;
     582        char *query = "UPDATE magicRun SET fault = %d WHERE magic_id = %" PRId64;
    561583        if (!p_psDBRunQueryF(config->dbh, query, fault, magic_id)) {
    562584            psError(PS_ERR_UNKNOWN, false,
     
    597619        return false;
    598620    }
     621    psS32 numUpdated = psDBAffectedRows(config->dbh);
     622    psLogMsg("magictool", PS_LOG_INFO, "Reverted %d magic runs", numUpdated);
     623
    599624    return true;
    600625}
     
    620645    psString query = pxDataGet("magictool_inputs.sql");
    621646    if (!query) {
    622         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     647        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    623648        return false;
    624649    }
     
    790815    psString query = pxDataGet("magictool_toprocess_inputs.sql");
    791816    if (!query) {
    792         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     817        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    793818        return false;
    794819    }
     
    852877
    853878    // look for tree nodes that need to be processed
     879
     880    // first find incomplete magicRuns
    854881    query = pxDataGet("magictool_toprocess_runs.sql");
    855882    if (!query) {
    856         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    857         return false;
    858     }
    859 
     883        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     884        return false;
     885    }
     886
     887    // we limit the query even though it is cheap (only magic_id is selected)
     888
     889    // XXX: if the first 1000 unfinished magicRuns have no ready nodes
     890    // that haven't faulted, later runs won't get returned even though
     891    // they have work to do. When we used a limit of 100 we actually ran
     892    // into this problem. Since we're using labels a limit of 1000 will
     893    // probably be ok.
    860894    {
    861         psString limitString = psDBGenerateLimitSQL( 100 );
     895        psString limitString = psDBGenerateLimitSQL( 1000 );
    862896        psStringAppend(&query, " %s", limitString);
    863897        psFree(limitString);
     
    895929    query = pxDataGet("magictool_toprocess_tree.sql");
    896930    if (!query) {
    897         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     931        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    898932        return false;
    899933    }
     
    908942            psAbort("failed to lookup value for magic_id column");
    909943        }
    910        
     944
    911945        whereString = NULL;
    912946        psStringAppend(&whereString, "\nAND (magic_id = %" PRId64 ")", magic_id);
     
    10261060    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    10271061    PXOPT_COPY_STR(config->args, where, "-node", "node", "==");
    1028     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    10291062    PXOPT_COPY_S16(config->args, where, "-fault", "magicNodeResult.fault", "==");
     1063    pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "==");
    10301064
    10311065    psString query = pxDataGet("magictool_revertnode.sql");
    10321066    if (!query) {
    1033         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1067        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10341068        return false;
    10351069    }
     
    10521086
    10531087    psS32 numUpdated = psDBAffectedRows(config->dbh);
    1054     psLogMsg("magictool", PS_LOG_INFO, "Updated %d magic nodes", numUpdated);
     1088    psLogMsg("magictool", PS_LOG_INFO, "Reverted %d magic nodes", numUpdated);
    10551089
    10561090    return true;
     
    10681102    psString query = pxDataGet("magictool_tomask.sql");
    10691103    if (!query) {
    1070         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1104        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10711105        return false;
    10721106    }
     
    11561190    psString query = pxDataGet("magictool_addmask.sql");
    11571191    if (!query) {
    1158         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1192        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    11591193        if (!psDBRollback(config->dbh)) {
    11601194            psError(PS_ERR_UNKNOWN, false, "database error");
     
    12631297    psString query = pxDataGet("magictool_mask.sql");
    12641298    if (!query) {
    1265         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1299        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    12661300        return false;
    12671301    }
     
    13931427}
    13941428
    1395 static bool censorStage(pxConfig *config, psString stage, psString whereClause)
    1396 {
    1397     psString queryFile = NULL;
    1398     psStringAppend(&queryFile, "magictool_censor_%s.sql", stage);
    1399     psString query = pxDataGet(queryFile);
    1400     if (!query) {
    1401         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", queryFile);
    1402         psFree(queryFile);
    1403         if (!psDBRollback(config->dbh)) {
    1404             psError(PS_ERR_UNKNOWN, false, "database error");
    1405         }
    1406         return false;
    1407     }
    1408     psFree(queryFile);
    1409 
    1410     psStringAppend(&query, " WHERE %s",  whereClause);
    1411 
    1412     if (!p_psDBRunQuery(config->dbh, query)) {
    1413         psError(PS_ERR_UNKNOWN, false, "database error");
    1414         psFree(query);
    1415         if (!psDBRollback(config->dbh)) {
    1416             psError(PS_ERR_UNKNOWN, false, "database error");
    1417         }
    1418         return false;
    1419     }
    1420     psFree(query);
    1421 
    1422     return true;
    1423 }
    1424 
    14251429static bool censorrunMode(pxConfig *config)
    14261430{
    14271431    PS_ASSERT_PTR_NON_NULL(config, false);
    14281432
    1429     psError(PS_ERR_PROGRAMMING, true, "-censorrun mode not ready yet");
    1430     return false;
    1431 
    14321433    psMetadata *where = psMetadataAlloc();
     1434
     1435    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", false, false);
     1436    PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);
     1437    PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
     1438
     1439    if (!magic_id) {
     1440        if (!exp_id && !label) {
     1441            psError(PS_ERR_UNKNOWN, true, "either -magic_id or exp_id and label is required");
     1442            return false;
     1443        }
     1444    }
    14331445
    14341446    // at least one of these required
    14351447    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    14361448    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     1449    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    14371450
    14381451    if (!psListLength(where->list)) {
     
    14701483    // Now queue any destreaked files to be re-verted
    14711484
    1472     // note: on failure censorStage issues the rollback
    1473     if (!censorStage(config, "raw", whereClause)) {
     1485    // note: on failure pxmagicRestoreStage issues the rollback
     1486    if (!pxmagicRestoreStage(config, "raw", whereClause, "goto_censored")) {
    14741487        psFree(whereClause);
    14751488        return false;
    14761489    }
    1477     if (!censorStage(config, "chip", whereClause)) {
     1490    if (!pxmagicRestoreStage(config, "chip", whereClause, "goto_censored")) {
    14781491        psFree(whereClause);
    14791492        return false;
    14801493    }
    1481     if (!censorStage(config, "camera", whereClause)) {
     1494    if (!pxmagicRestoreStage(config, "camera", whereClause, "goto_censored")) {
    14821495        psFree(whereClause);
    14831496        return false;
    14841497    }
    1485     if (!censorStage(config, "warp", whereClause)) {
     1498    if (!pxmagicRestoreStage(config, "warp", whereClause, "goto_censored")) {
    14861499        psFree(whereClause);
    14871500        return false;
    14881501    }
    1489     if (!censorStage(config, "diff", whereClause)) {
     1502    if (!pxmagicRestoreStage(config, "diff", whereClause, "goto_censored")) {
    14901503        psFree(whereClause);
    14911504        return false;
Note: See TracChangeset for help on using the changeset viewer.