IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27391


Ignore:
Timestamp:
Mar 22, 2010, 1:58:02 PM (16 years ago)
Author:
bills
Message:

changes to support updating only a subset of the components of a run

Location:
trunk/ippTools
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/Makefile.am

    r27192 r27391  
    3838     chiptool_run.sql \
    3939     chiptool_runstate.sql \
     40     chiptool_setimfiletoupdate.sql \
    4041     chiptool_export_imfile.sql \
    4142     chiptool_export_processed_imfile.sql \
  • trunk/ippTools/share/chiptool_pendingimfile.sql

    r26886 r27391  
    3333    OR
    3434    (chipRun.state = 'update'
    35     AND chipProcessedImfile.data_state = 'cleaned'))
     35    AND chipProcessedImfile.data_state = 'update'))
    3636-- // Restriction to prevent the processing of bad chips. Not needed now.
    3737--     AND
  • trunk/ippTools/share/difftool_todiffskyfile.sql

    r27020 r27391  
    6767    OR (diffRun.state = 'update'
    6868    AND diffSkyfile.fault = 0
    69     AND diffSkyfile.data_state = 'cleaned')
     69    AND diffSkyfile.data_state = 'update')
    7070    )
    7171-- Ensure input warps are available
    7272    AND (diffInputSkyfile.warp1 IS NULL
    73     OR (warpRun.state = 'full'
     73    OR (warpSkyfile.data_state = 'full'
    7474    AND warpSkyfile.fault = 0
     75    AND warpSkyfile.magicked >= 0
    7576    AND warpSkyfile.quality = 0))
    7677-- Ensure input stacks are available
     
    8182-- Ensure template warps are available
    8283    AND (diffInputSkyfile.warp2 IS NULL
    83     OR (warpTemplateRun.state = 'full'
     84    OR (warpTemplateSkyfile.data_state = 'full'
    8485    AND warpTemplateSkyfile.fault = 0
     86    AND warpSkyfile.magicked >= 0
    8587    AND warpTemplateSkyfile.quality = 0))
    8688-- Ensure template stacks are available
  • trunk/ippTools/share/warptool_towarped.sql

    r26567 r27391  
    1 SELECT DISTINCT
    2     warpSkyCellMap.warp_id,
    3     warpImfile.warp_skyfile_id,
    4     warpSkyCellMap.skycell_id,
    5     warpSkyCellMap.tess_id,
    6     warpRun.fake_id,
    7     warpRun.state,
    8     warpRun.reduction,
    9     camRun.cam_id,
    10     rawExp.camera,
    11     rawExp.exp_tag,
    12     warpRun.workdir,
    13     chipRun.magicked
    14 FROM warpRun
    15 JOIN warpSkyCellMap
    16     USING(warp_id)
    17 JOIN warpImfile
    18     ON warpSkyCellMap.warp_id = warpImfile.warp_id
    19     AND warpSkyCellMap.skycell_id = warpImfile.skycell_id
    20 JOIN fakeRun
    21     USING(fake_id)
    22 JOIN camRun
    23     USING(cam_id)
    24 JOIN chipRun
    25     USING(chip_id)
    26 JOIN chipProcessedImfile
    27     USING(chip_id)
    28 JOIN rawExp
    29     ON chipRun.exp_id = rawExp.exp_id
    30 LEFT JOIN warpSkyfile
    31     ON warpRun.warp_id = warpSkyfile.warp_id
    32     AND warpSkyCellMap.skycell_id = warpSkyfile.skycell_id
    33     AND warpSkyCellMap.tess_id = warpSkyfile.tess_id
    34 LEFT JOIN warpMask
    35     ON warpRun.label = warpMask.label
    36 WHERE
    37     ((warpRun.state = 'new'
     1SELECT
     2    warp_id,
     3    warp_skyfile_id,
     4    skycell_id,
     5    tess_id,
     6    fake_id,
     7    state,
     8    reduction,
     9    cam_id,
     10    camera,
     11    exp_tag,
     12    workdir,
     13    magicked
     14FROM (
     15    SELECT
     16        warpSkyCellMap.warp_id,
     17        warpImfile.warp_skyfile_id,
     18        warpSkyCellMap.skycell_id,
     19        warpSkyCellMap.tess_id,
     20        warpRun.fake_id,
     21        warpRun.state,
     22        warpRun.reduction,
     23        camRun.cam_id,
     24        rawExp.camera,
     25        rawExp.exp_tag,
     26        warpRun.workdir,
     27        chipRun.magicked
     28    FROM warpRun
     29    JOIN warpSkyCellMap
     30        USING(warp_id)
     31    JOIN warpImfile
     32        ON warpSkyCellMap.warp_id = warpImfile.warp_id
     33        AND warpSkyCellMap.skycell_id = warpImfile.skycell_id
     34    JOIN fakeRun
     35        USING(fake_id)
     36    JOIN camRun
     37        USING(cam_id)
     38    JOIN chipRun
     39        USING(chip_id)
     40    JOIN chipProcessedImfile
     41        USING(chip_id)
     42    JOIN rawExp
     43        ON chipRun.exp_id = rawExp.exp_id
     44    LEFT JOIN warpSkyfile
     45        ON warpRun.warp_id = warpSkyfile.warp_id
     46        AND warpSkyCellMap.skycell_id = warpSkyfile.skycell_id
     47        AND warpSkyCellMap.tess_id = warpSkyfile.tess_id
     48    LEFT JOIN warpMask
     49        ON warpRun.label = warpMask.label
     50    WHERE
     51        warpRun.state = 'new'
    3852        AND warpSkyfile.warp_id IS NULL
    3953        AND warpSkyfile.skycell_id IS NULL
    40         AND warpSkyfile.tess_id IS NULL)
    41     OR (warpRun.state = 'update'
    42         AND chipRun.magicked >= 0
    43         AND warpSkyfile.fault = 0
    44         AND warpSkyfile.data_state = 'cleaned')
    45     )
    46     AND fakeRun.state = 'full'
    47     AND camRun.state = 'full'
    48     AND chipRun.state = 'full'
    49     AND warpMask.label IS NULL
    50     AND warpSkyCellMap.fault = 0
     54        AND warpSkyfile.tess_id IS NULL
     55        AND fakeRun.state = 'full'
     56        AND camRun.state = 'full'
     57        AND chipRun.state = 'full'
     58        AND warpMask.label IS NULL
     59        AND warpSkyCellMap.fault = 0
     60        -- where hook 1 %s
     61    GROUP BY warp_id, skycell_id
     62UNION
     63    SELECT
     64        warpSkyCellMap.warp_id,
     65        warpImfile.warp_skyfile_id,
     66        warpSkyCellMap.skycell_id,
     67        warpSkyCellMap.tess_id,
     68        warpRun.fake_id,
     69        warpRun.state,
     70        warpRun.reduction,
     71        camRun.cam_id,
     72        rawExp.camera,
     73        rawExp.exp_tag,
     74        warpRun.workdir,
     75        MIN(chipProcessedImfile.magicked) AS magicked
     76    FROM warpRun
     77    JOIN warpSkyCellMap USING(warp_id)
     78    JOIN warpImfile USING(warp_id, skycell_id)
     79    JOIN warpSkyfile USING(warp_id, skycell_id)
     80    JOIN fakeRun USING(fake_id)
     81    JOIN camRun USING(cam_id)
     82    JOIN chipRun USING(chip_id)
     83    JOIN rawExp USING(exp_id)
     84    LEFT JOIN chipProcessedImfile USING(chip_id, class_id)
     85    WHERE warpRun.state = 'update'
     86        AND warpSkyfile.data_state = 'update'
     87        AND camRun.state = 'full'
     88        AND chipProcessedImfile.data_state = 'full'
     89        -- if warpSkyfile was magicked previously require inputs to be magicked
     90        -- this blocks processing until all the chip inputs have been destreaked
     91        AND (warpSkyfile.magicked = 0 OR chipProcessedImfile.magicked >= 0)
     92        -- where hook 2 %s
     93    GROUP BY warp_id, skycell_id
     94    HAVING COUNT(warpSkyCellMap.class_id) = COUNT(chipProcessedImfile.class_id)
     95) as towarped
     96
  • trunk/ippTools/src/addtool.c

    r26981 r27391  
    290290
    291291    // pxUpdateRun gets parameters from config->args and runs the update query
    292     bool result = pxUpdateRun(config, where, &query, "addRun", false);
     292    bool result = pxUpdateRun(config, where, &query, "addRun", "add_id",
     293        "addProcessedExp", false);
    293294
    294295    psFree(query);
     
    296297
    297298    return result;
    298 
    299 
    300 #ifdef notdef
    301     PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    302     PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
    303 
    304     if ((!state) && (!label)) {
    305         psError(PXTOOLS_ERR_CONFIG, false, "parameters are required");
    306         psFree(where);
    307         return false;
    308     }
    309 
    310     if (state) {
    311         // set addRun.state to state
    312         if (!pxaddRunSetStateByQuery(config, where, state)) {
    313             psFree(where);
    314             return false;
    315         }
    316     }
    317 
    318     if (label) {
    319         // set addRun.label to label
    320         if (!pxaddRunSetLabelByQuery(config, where, label)) {
    321             psFree(where);
    322             return false;
    323         }
    324     }
    325 
    326     psFree(where);
    327 
    328     return true;
    329 #endif
    330299}
    331300
  • trunk/ippTools/src/camtool.c

    r27300 r27391  
    267267
    268268    // pxUpdateRun gets parameters from config->args and updates
    269     bool result = pxUpdateRun(config, where, &query, "camRun", true);
     269    bool result = pxUpdateRun(config, where, &query, "camRun", "cam_id", "camProcessedExp", true);
    270270    if (!result) {
    271271        psError(psErrorCodeLast(), false, "pxUpdateRun failed");
  • trunk/ippTools/src/chiptool.c

    r27195 r27391  
    5959static bool importrunMode(pxConfig *config);
    6060static bool runstateMode(pxConfig *config);
     61static bool setimfiletoupdateMode(pxConfig *config);
    6162
    6263# define MODECASE(caseName, func) \
     
    101102        MODECASE(CHIPTOOL_MODE_IMPORTRUN,               importrunMode);
    102103        MODECASE(CHIPTOOL_MODE_RUNSTATE,                runstateMode);
     104        MODECASE(CHIPTOOL_MODE_SETIMFILETOUPDATE,       setimfiletoupdateMode);
    103105        default:
    104106            psAbort("invalid option (this should not happen)");
     
    428430        return false;
    429431    }
    430     psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id)");
     432    psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id) -- join hook %s\n");
    431433
    432434    // pxUpdateRun gets parameters from config->args and updates
    433     bool result = pxUpdateRun(config, where, &query, "chipRun", true);
     435    bool result = pxUpdateRun(config, where, &query, "chipRun", "chip_id", "chipProcessedImfile", true);
    434436    if (!result) {
    435437        psError(psErrorCodeLast(), false, "pxUpdateRun failed");
     
    17201722    return true;
    17211723}
     1724
     1725// a very specfic function to queue a cleaned chipProcessedImfile to be updated
     1726static bool setimfiletoupdateMode(pxConfig *config)
     1727{
     1728    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1729
     1730    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
     1731    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", false, false);
     1732    PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
     1733
     1734    psString query = pxDataGet("chiptool_setimfiletoupdate.sql");
     1735    if (!query) {
     1736        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1737        return false;
     1738    }
     1739
     1740    psString setHook = psStringCopy("");
     1741    if (label) {
     1742        psStringAppend(&setHook, "\n , chipRun.label = '%s'", label);
     1743    }
     1744
     1745    if (class_id) {
     1746        psStringAppend(&query, " AND (chipProcessedImfile.class_id = '%s')", class_id);
     1747    }
     1748
     1749    if (!p_psDBRunQueryF(config->dbh, query, setHook, chip_id)) {
     1750        psError(PS_ERR_UNKNOWN, false, "database error");
     1751        return false;
     1752    }
     1753
     1754    psFree(setHook);
     1755    psFree(query);
     1756
     1757    return true;
     1758}
  • trunk/ippTools/src/chiptool.h

    r27192 r27391  
    3333    CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,
    3434    CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,
     35    CHIPTOOL_MODE_SETIMFILETOUPDATE,
    3536    CHIPTOOL_MODE_ADVANCEEXP,
    3637    CHIPTOOL_MODE_BLOCK,
  • trunk/ippTools/src/chiptoolConfig.c

    r27195 r27391  
    9797    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0,   "set dist group", NULL);
    9898    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0,         "set note", NULL);
     99
     100    // -setimfiletoupdate
     101    psMetadata *setimfiletoupdateArgs = psMetadataAlloc();
     102    psMetadataAddS64(setimfiletoupdateArgs, PS_LIST_TAIL, "-chip_id", 0,   "search by chip ID (required)", 0);
     103    psMetadataAddStr(setimfiletoupdateArgs, PS_LIST_TAIL, "-class_id", 0,  "search by class_id (required)", NULL);
     104    psMetadataAddStr(setimfiletoupdateArgs, PS_LIST_TAIL, "-set_label",  0,"new value for label", NULL);
    99105
    100106    // -pendingimfile
     
    315321    PXOPT_ADD_MODE("-definecopy",           "create copy runs",                     CHIPTOOL_MODE_DEFINECOPY,        definecopyArgs);
    316322    PXOPT_ADD_MODE("-updaterun",            "change chip run properties",           CHIPTOOL_MODE_UPDATERUN,            updaterunArgs);
     323    PXOPT_ADD_MODE("-setimfiletoupdate",    "set imfile state to update",           CHIPTOOL_MODE_SETIMFILETOUPDATE,    setimfiletoupdateArgs);
    317324    PXOPT_ADD_MODE("-pendingimfile",        "show pending imfiles",                 CHIPTOOL_MODE_PENDINGIMFILE,        pendingimfileArgs);
    318325    PXOPT_ADD_MODE("-addprocessedimfile",   "add a processed imfile",               CHIPTOOL_MODE_ADDPROCESSEDIMFILE,   addprocessedimfileArgs);
  • trunk/ippTools/src/difftool.c

    r27210 r27391  
    204204
    205205    // pxUpdateRun gets parameters from config->args and updates
    206     bool result = pxUpdateRun(config, where, &query, "diffRun", true);
     206    bool result = pxUpdateRun(config, where, &query, "diffRun", "diff_id", "diffSkyfile", true);
    207207
    208208    psFree(query);
     
    210210
    211211    return result;
    212 
    213 #ifdef notdef
    214     // required options
    215     PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false);
    216     PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
    217     PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
    218 
    219     // Copy of my hacky work around from stacktool.c
    220     if ((state)&&(diff_id)) {
    221         // set detRun.state to state
    222         return setdiffRunState(config, diff_id, state, false);
    223     }
    224 
    225     if ((state)&&(label)) {
    226       return setdiffRunStateByLabel(config, label, state);
    227     }
    228 
    229     psError(PS_ERR_UNKNOWN, false, "Required options not found.");
    230 
    231     return false;
    232 #endif
    233212}
    234213
  • trunk/ippTools/src/faketool.c

    r27210 r27391  
    348348
    349349    // pxUpdateRun gets parameters from config->args and updates
    350     bool result = pxUpdateRun(config, where, &query, "fakeRun", true);
     350    bool result = pxUpdateRun(config, where, &query, "fakeRun", "fake_id", "fakeProcessedImfile", true);
    351351    if (!result) {
    352352        psError(psErrorCodeLast(), false, "pxUpdateRun failed");
  • trunk/ippTools/src/pxtools.c

    r27258 r27391  
    110110
    111111// shared code for updating the various strings for a Run
    112 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString table, bool has_dist_group)
     112bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString runTable, psString idColumn, psString fileTable, bool has_dist_group)
    113113{
    114114    PS_ASSERT_PTR_NON_NULL(config, false);
     
    116116    PS_ASSERT_PTR_NON_NULL(pQuery, false);
    117117    PS_ASSERT_PTR_NON_NULL(*pQuery, false);
     118    PS_ASSERT_PTR_NON_NULL(runTable, false);
     119    PS_ASSERT_PTR_NON_NULL(idColumn, false);
     120    PS_ASSERT_PTR_NON_NULL(fileTable, false);
    118121
    119122    // make sure that -state is not the only selection parameter
     
    158161        } while (0)
    159162
    160     addColumn(table, state);
    161     addColumn(table, data_group);
     163    addColumn(runTable, state);
     164    addColumn(runTable, data_group);
    162165    if (has_dist_group) {
    163         addColumn(table, dist_group);
    164     }
    165     addColumn(table, note);
    166     addColumn(table, label);
     166        addColumn(runTable, dist_group);
     167    }
     168    addColumn(runTable, note);
     169    addColumn(runTable, label);
     170
     171    psString joinHook = psStringCopy("");
     172    psString fileWhere = NULL;
     173    if (state && !strcmp(state, "update")) {
     174        psStringAppend(&joinHook, "\n JOIN %s USING(%s)", fileTable, idColumn);
     175        psStringAppend(pQuery, ", %s.data_state = 'update'", fileTable);
     176        psStringAppend(&fileWhere, "AND %s.data_state = 'cleaned'", fileTable);
     177    }
    167178
    168179    psString whereClause =  psDBGenerateWhereSQL(where, NULL);
    169180    psStringAppend(pQuery, " %s", whereClause);
    170181    psFree(whereClause);
     182    if (fileWhere) {
     183        psStringAppend(pQuery, fileWhere);
     184    }
    171185
    172186    bool mdok;                          // Status of MD lookup
     
    176190    }
    177191
    178     if (!p_psDBRunQuery(config->dbh, *pQuery)) {
     192    if (!p_psDBRunQueryF(config->dbh, *pQuery, joinHook)) {
    179193        psError(PS_ERR_UNKNOWN, false, "database error");
    180194        return false;
  • trunk/ippTools/src/pxtools.h

    r25851 r27391  
    6565bool pxGetOptions(FILE *stream, int argc, char **argv, pxConfig *config, psMetadata *modes, psMetadata *argSets);
    6666
    67 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString table, bool has_dist_group);
     67bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString runTable, psString idColumn, psString fileTable, bool has_dist_group);
    6868
    6969#define PXOPT_ADD_MODE(option, comment, modeval, argset) \
  • trunk/ippTools/src/stacktool.c

    r27120 r27391  
    612612
    613613    // pxUpdateRun gets parameters from config->args and updates
    614     bool result = pxUpdateRun(config, where, &query, "stackRun", true);
     614    bool result = pxUpdateRun(config, where, &query, "stackRun", "stack_id", "stackSumSkyfile", true);
    615615
    616616    psFree(query);
  • trunk/ippTools/src/warptool.c

    r27389 r27391  
    402402    }
    403403
    404     psString query = psStringCopy("UPDATE warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     404    psString query = psStringCopy("UPDATE warpRun JOIN warpSkyfile USING(warp_id) JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
    405405
    406406    // pxUpdateRun gets parameters from config->args and updates
    407     bool result = pxUpdateRun(config, where, &query, "warpRun", true);
     407    bool result = pxUpdateRun(config, where, &query, "warpRun", "warp_id", "warpSkyfile", true);
    408408
    409409    psFree(query);
     
    907907    }
    908908
     909    psString whereStr = psStringCopy("");
    909910    if (psListLength(where->list)) {
    910911        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    911         psStringAppend(&query, " AND %s", whereClause);
     912        psStringAppend(&whereStr, "\n AND %s", whereClause);
    912913        psFree(whereClause);
    913914    }
     
    921922    }
    922923
    923     if (!p_psDBRunQuery(config->dbh, query)) {
     924    if (!p_psDBRunQueryF(config->dbh, query, whereStr, whereStr)) {
    924925        psError(PS_ERR_UNKNOWN, false, "database error");
    925926        psFree(query);
    926927        return false;
    927928    }
     929    psFree(whereStr);
    928930    psFree(query);
    929931
Note: See TracChangeset for help on using the changeset viewer.