IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 2, 2011, 11:44:07 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20111122/ippTools/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/ippTools/src

  • branches/eam_branches/ipp-20111122/ippTools/src/addtool.c

    r32711 r32851  
    143143    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
    144144    }
    145    
     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", "==");
     150    //no filter here
     151    }
    146152    if (!psListLength(where->list)) {
    147153        psFree(where);
     
    237243    }
    238244
    239 
     245    if (strcmp(stage,"staticsky_multi") == 0) {
     246      if (dvodb ) {
     247        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
     248        // find the cam_id of all the exposures that we want to queue up.
     249        bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
     250        // user supplied dvodb
     251        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     252    } else {
     253      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
     254        // find the cam_id of all the exposures that we want to queue up.
     255        bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
     256        // inherit dvodb from camRun, avoid matching NULL
     257        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
     258    }
     259    }
    240260
    241261    if (!bare_query) {
     
    292312        psStringAppend(&query, " GROUP BY stack_id");
    293313      }
    294 
     314    if (strcmp(stage,"staticsky_multi") == 0) {
     315      psStringAppend(&query, " GROUP BY sky_id");  //some reason it needs this
     316      }
    295317
    296318
     
    405427    }
    406428    }
     429    if (strcmp(stage,"staticsky_multi") == 0) {
     430    for (long i = 0; i < psArrayLength(output); i++) {
     431        psMetadata *md = output->data[i];
     432        bool status = false;
     433        psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     434        if (!status) {
     435          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     436          return false;
     437        }
     438        if (num_inputs < 0) {
     439          psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
     440          return false;
     441        }
     442
     443        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     444       
     445        if (!row) {
     446            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     447            psFree(output);
     448            return false;
     449        }
     450
     451        if (!dvodb) {  //there's no staticsky.dvodb
     452            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     453            psFree(output);
     454            return false;
     455        }
     456        if (!workdir && !row->workdir) {
     457            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     458            psFree(output);
     459            return false;
     460        }
     461
     462        psFree(row);
     463    }
     464    }
     465
     466
     467
    407468
    408469    // start a transaction so we don't end up with an exp without any associted
     
    438499                               stage,
    439500                               stage_id,
     501                               0,
    440502                               workdir     ? workdir   : row->workdir,
    441503                               reduction   ? reduction : row->reduction,
     
    479541                               stage,
    480542                               stage_id,
     543                               0,
    481544                               workdir     ? workdir   : row->workdir,
    482545                               reduction   ? reduction : row->reduction,
     
    520583                               stage,
    521584                               stage_id,
     585                               0,
    522586                               workdir     ? workdir   : row->workdir,
    523587                               reduction   ? reduction : row->reduction,
     
    544608      }
    545609
     610    if (strcmp(stage,"staticsky_multi") == 0) {
     611    for (long i = 0; i < psArrayLength(output); i++) {
     612        psMetadata *md = output->data[i];
     613        psS64 stage_id =0;
     614        bool status = false;
     615        psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     616        if (!status) {
     617          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     618          return false;
     619        }
     620        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     621        stage_id = row->sky_id;
     622       
     623        if (!row) {
     624            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     625            psFree(output);
     626            return false;
     627        }
     628
     629        // queue the exp
     630        for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
     631        if (!pxaddQueueByCamID(config,
     632                               stage,
     633                               stage_id,
     634                               filter_id,
     635                               workdir     ? workdir   : row->workdir,
     636                               reduction   ? reduction : row->reduction,
     637                               label       ? label     : row->label,
     638                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     639                               dvodb       ? dvodb     : NULL,
     640                               note        ? note      : NULL,
     641                               image_only,
     642                               minidvodb,
     643                               minidvodb_group,
     644                               minidvodb_name
     645        )) {
     646            if (!psDBRollback(config->dbh)) {
     647                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     648            }
     649            psError(PS_ERR_UNKNOWN, false,
     650                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     651            psFree(row);
     652            psFree(output);
     653            return false;
     654        }
     655        }
     656        psFree(row);
     657    }
     658      }
     659
     660
     661
     662
    546663    psFree(output);
    547664
     
    585702    }
    586703    if (strcmp(stage, "staticsky")==0) {
     704    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     705    }
     706    if (strcmp(stage, "staticsky_multi")==0) {
    587707    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
    588708    }
     
    626746    query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
    627747    }
    628 
     748    if (strcmp(stage, "staticsky_multi")==0) {
     749    query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
     750    }
     751   
    629752
    630753    if (!query) {
     
    648771      psStringAppend(&query, " GROUP BY %s", "sky_id");
    649772    }
    650 
     773    if (strcmp(stage, "staticsky_multi") == 0) {
     774      //this group by is needed to join against all the warps (to get camera)
     775      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
     776    }
    651777    // treat limit == 0 as "no limit"
    652778    if (limit) {
     
    838964    query = pxDataGet("addtool_find_processedexp_staticsky.sql");
    839965    }
     966    if (strcmp (stage,"staticsky_multi") == 0) {
     967    query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
     968    }
     969
    840970   
    841971    if (!query) {
     
    9481078         query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
    9491079      }
     1080   if (strcmp(stage, "staticsky_multi") == 0) {
     1081         query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
     1082      }
     1083
     1084
     1085     
    9501086      if (!query) {
    9511087            // rollback
  • branches/eam_branches/ipp-20111122/ippTools/src/disttool.c

    r32696 r32851  
    419419    }
    420420
    421     if (!strcmp(stage, "sky") && single) {
    422         psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) = 1");
     421    if (!strcmp(stage, "sky")) {
     422        if (single) {
     423            psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) = 1");
     424        } else {
     425            psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) > 1");
     426        }
    423427    }
    424428
  • branches/eam_branches/ipp-20111122/ippTools/src/flatcorr.c

    r31375 r32851  
    666666                "cam",
    667667                row->cam_id,
     668                0,
    668669                row->workdir,
    669670                row->reduction,
  • branches/eam_branches/ipp-20111122/ippTools/src/magictool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20111122/ippTools/src/pstamptool.c

    r32360 r32851  
    5656static bool revertdependentMode(pxConfig *config);
    5757static bool getwebrequestnumMode(pxConfig *config);
     58static bool addfileMode(pxConfig *config);
     59static bool listfileMode(pxConfig *config);
     60static bool deletefileMode(pxConfig *config);
    5861
    5962# define MODECASE(caseName, func) \
     
    103106        MODECASE(PSTAMPTOOL_MODE_REVERTDEPENDENT, revertdependentMode);
    104107        MODECASE(PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumMode);
     108        MODECASE(PSTAMPTOOL_MODE_ADDFILE, addfileMode);
     109        MODECASE(PSTAMPTOOL_MODE_LISTFILE, listfileMode);
     110        MODECASE(PSTAMPTOOL_MODE_DELETEFILE, deletefileMode);
    105111        default:
    106112            psAbort("invalid option (this should not happen)");
     
    14761482    return true;
    14771483}
     1484
     1485static bool addfileMode(pxConfig *config)
     1486{
     1487    PS_ASSERT_PTR_NON_NULL(config, false);
     1488
     1489    PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false);
     1490    PXOPT_LOOKUP_STR(path,   config->args, "-path",   true, false);
     1491
     1492    if (!pstampFileInsert(config->dbh,
     1493            0, // file_id
     1494            job_id,
     1495            path
     1496            )) {
     1497        psError(PS_ERR_UNKNOWN, false, "database error");
     1498        return false;
     1499    }
     1500
     1501    psU64 affected = psDBAffectedRows(config->dbh);
     1502    if (affected != 1) {
     1503        psError(PS_ERR_UNKNOWN, false,
     1504            "should have affected one row but %" PRIu64 " rows were modified",
     1505            affected);
     1506        return false;
     1507    }
     1508
     1509    psS64 file_id = psDBLastInsertID(config->dbh);
     1510    printf("%" PRId64 "\n", file_id);
     1511
     1512    return true;
     1513}
     1514
     1515static bool listfileMode(pxConfig *config)
     1516{
     1517    PS_ASSERT_PTR_NON_NULL(config, false);
     1518
     1519    psMetadata *where = psMetadataAlloc();
     1520    PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "==");
     1521    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
     1522    PXOPT_COPY_S64(config->args, where, "-file_id", "file_id", "==");
     1523
     1524    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1525    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1526
     1527    if (!psListLength(where->list)) {
     1528        fprintf(stderr, "search arguments are required\n");
     1529        exit (1);
     1530    }
     1531
     1532    psString query = pxDataGet("pstamptool_listfile.sql");
     1533    if (!query) {
     1534        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1535        return false;
     1536    }
     1537
     1538    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
     1539    if (psListLength(where->list)) {
     1540        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1541        psStringAppend(&query, " WHERE %s", whereClause);
     1542        psFree(whereClause);
     1543    }
     1544    psFree(where);
     1545
     1546    // treat limit == 0 as "no limit"
     1547    if (limit) {
     1548        psString limitString = psDBGenerateLimitSQL(limit);
     1549        psStringAppend(&query, " %s", limitString);
     1550        psFree(limitString);
     1551    }
     1552
     1553    if (!p_psDBRunQuery(config->dbh, query)) {
     1554        psError(PS_ERR_UNKNOWN, false, "database error");
     1555        psFree(query);
     1556        return false;
     1557    }
     1558    psFree(query);
     1559
     1560    psArray *output = p_psDBFetchResult(config->dbh);
     1561    if (!output) {
     1562        psError(PS_ERR_UNKNOWN, false, "database error");
     1563        return false;
     1564    }
     1565    if (!psArrayLength(output)) {
     1566        psTrace("pstamptool", PS_LOG_INFO, "no rows found");
     1567        psFree(output);
     1568        return true;
     1569    }
     1570
     1571    // negative simple so the default is true
     1572    if (!ippdbPrintMetadatas(stdout, output, "pstampFile", !simple)) {
     1573        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1574        psFree(output);
     1575        return false;
     1576    }
     1577
     1578    psFree(output);
     1579
     1580    return true;
     1581}
     1582
     1583static bool deletefileMode(pxConfig *config)
     1584{
     1585    PS_ASSERT_PTR_NON_NULL(config, false);
     1586
     1587    PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false);
     1588
     1589    psString query = NULL;
     1590    psStringAppend(&query, "DELETE FROM pstampFile WHERE job_id = %" PRId64, job_id);
     1591
     1592    if (!p_psDBRunQuery(config->dbh, query)) {
     1593        psError(PS_ERR_UNKNOWN, false, "database error");
     1594        psFree(query);
     1595        return false;
     1596    }
     1597    psFree(query);
     1598
     1599    psU64 affected = psDBAffectedRows(config->dbh);
     1600    psLogMsg("pstamptool", PS_LOG_INFO, "Deleted %" PRIu64 " rows from pstampFile", affected);
     1601
     1602    return true;
     1603}
  • branches/eam_branches/ipp-20111122/ippTools/src/pstamptool.h

    r29248 r32851  
    5050    PSTAMPTOOL_MODE_REVERTDEPENDENT,
    5151    PSTAMPTOOL_MODE_GETWEBREQUESTNUM,
     52    PSTAMPTOOL_MODE_ADDFILE,
     53    PSTAMPTOOL_MODE_LISTFILE,
     54    PSTAMPTOOL_MODE_DELETEFILE,
    5255} pstamptoolMode;
    5356
  • branches/eam_branches/ipp-20111122/ippTools/src/pstamptoolConfig.c

    r30543 r32851  
    274274    psMetadata *modes = psMetadataAlloc();
    275275
     276    // -addfile
     277    psMetadata *addfileArgs = psMetadataAlloc();
     278    psMetadataAddS64(addfileArgs, PS_LIST_TAIL, "-job_id",       0, "define job ID for file (required)", 0);
     279    psMetadataAddStr(addfileArgs, PS_LIST_TAIL, "-path",         0, "define path for file (required)", NULL);
     280
     281    // -listfile
     282    psMetadata *listfileArgs = psMetadataAlloc();
     283    psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-file_id",     0, "select by file ID", 0);
     284    psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-job_id",      0, "select by job ID", 0);
     285    psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-req_id",      0, "select by request ID", 0);
     286    psMetadataAddU64(listfileArgs, PS_LIST_TAIL, "-limit",       0, "limit result set to N items", 0);
     287    psMetadataAddBool(listfileArgs, PS_LIST_TAIL, "-simple",     0, "use the simple output format", false);
     288
     289    // -deletefile
     290    psMetadata *deletefileArgs = psMetadataAlloc();
     291    psMetadataAddS64(deletefileArgs, PS_LIST_TAIL, "-job_id",      0, "select by job ID (required)", 0);
     292
    276293    PXOPT_ADD_MODE("-addreq",          "", PSTAMPTOOL_MODE_ADDREQ,       addreqArgs);
    277294    PXOPT_ADD_MODE("-pendingreq",      "", PSTAMPTOOL_MODE_PENDINGREQ,   pendingreqArgs);
     
    302319    PXOPT_ADD_MODE("-project",         "", PSTAMPTOOL_MODE_PROJECT,    projectArgs);
    303320    PXOPT_ADD_MODE("-getwebrequestnum","", PSTAMPTOOL_MODE_GETWEBREQUESTNUM,   getwebrequestnumArgs);
     321    PXOPT_ADD_MODE("-addfile",         "", PSTAMPTOOL_MODE_ADDFILE,   addfileArgs);
     322    PXOPT_ADD_MODE("-listfile",        "", PSTAMPTOOL_MODE_LISTFILE,   listfileArgs);
     323    PXOPT_ADD_MODE("-deletefile",      "", PSTAMPTOOL_MODE_DELETEFILE,   deletefileArgs);
    304324
    305325    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
  • branches/eam_branches/ipp-20111122/ippTools/src/pxadd.c

    r31375 r32851  
    131131                       char *stage,
    132132                       psS64 stage_id,
     133                       psS32 stage_extra1,
    133134                       char *workdir,
    134135                       char *reduction,
     
    159160        psMemSetPersistent(query, true);
    160161      }
     162      if (strcmp(stage,"staticsky_multi") == 0) {
     163        query = pxDataGet("addtool_queue_sky_id_multi.sql");
     164        psMemSetPersistent(query, true);
     165      }
    161166        if (!query) {
    162167            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     
    170175    // on 32/64
    171176    if (!p_psDBRunQueryF(config->dbh, query,
     177                         stage_extra1 ? stage_extra1 : 0,
    172178                         "new", // state
    173179                         workdir  ? workdir   : "NULL",
  • branches/eam_branches/ipp-20111122/ippTools/src/pxadd.h

    r31375 r32851  
    3333                       char *stage,
    3434                       psS64 stage_id,
     35                       psS32 stage_extra1,
    3536                       char *workdir,
    3637                       char *reduction,
  • branches/eam_branches/ipp-20111122/ippTools/src/vptool.c

    r32750 r32851  
    178178    PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);
    179179
    180     psMetadata *where = psMetadataAlloc();
    181     pxchipGetSearchArgs (config, where); // rawExp only
    182     pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); // define using newExp label
    183 
    184     if (!psListLength(where->list)) {
    185         psFree(where);
    186         psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    187         return false;
    188     }
    189180
    190181    PXOPT_LOOKUP_STR(label, config->args, "-set_label", true, false);
     
    195186
    196187    // default
    197     PXOPT_LOOKUP_BOOL(unique, config->args, "-unique", false);
     188    PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false);
    198189    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
    199190    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     191
     192    psMetadata *where = psMetadataAlloc();
     193    pxchipGetSearchArgs (config, where); // rawExp only
     194    pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "="); // define using newExp label
     195
     196    if (!psListLength(where->list)) {
     197        psFree(where);
     198        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     199        return false;
     200    }
    200201
    201202    // find the exp_id of all the exposures that we want to queue up.
     
    213214    psFree(where);
    214215
    215     if (unique) {
    216       psStringAppend(&query, "AND vp_id IS NULL");
     216    if (!rerun) {
     217      psStringAppend(&query, "\n  AND vp_id IS NULL\n  AND (vpRun.label = '%s' OR vpRun.label IS NULL)", label);
    217218    }
    218219   
  • branches/eam_branches/ipp-20111122/ippTools/src/vptoolConfig.c

    r32511 r32851  
    5050    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by newExp label (LIKE comparison)", NULL);
    5151
    52     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label",  0,            "define label", NULL);
     52    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label",  0,            "define label (required)", NULL);
    5353    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group",  0,      "define data group", NULL);
    5454    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir",  0,            "define workdir (required)", NULL);
     
    5656    psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-set_dest_id",  0,      "define destination", 0);
    5757    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend",  0,            "do not actually modify the database", false);
    58     psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-unique",   0,           "only queue exposures that have no previous vpRun", false);
     58    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-rerun",   0,           "queue exposures even if a previous vpRun exists", false);
    5959    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
    6060    // -pendingrun
Note: See TracChangeset for help on using the changeset viewer.