IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2015, 2:05:35 PM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20140904
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904

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

    r35304 r37804  
    122122    PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
    123123    PXOPT_COPY_S64(config->args, where,  "-skycal_id",  "skycalRun.skycal_id", "==");
     124    PXOPT_COPY_S64(config->args, where,  "-diff_id",  "diffRun.diff_id", "==");
     125    PXOPT_COPY_S64(config->args, where,  "-ff_id",  "fullForceRun.ff_id", "==");
     126
    124127    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    125128    if (strcmp(stage, "cam")== 0) {
     
    146149      PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction",  "==");
    147150    }
    148 
     151    if (strcmp(stage, "diff")==0) {
     152      pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "=="); //define using skycalRun label
     153      pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "==");
     154      PXOPT_COPY_STR(config->args, where,  "-reduction", "diffRun.reduction",  "==");
     155    }
     156    if (strcmp(stage, "fullforce")==0) {
     157      pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "=="); //define using skycalRun label
     158      pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
     159      PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
     160    }
     161
     162 
     163 
    149164    if (!psListLength(where->list)) {
    150165        psFree(where);
     
    258273    }
    259274
    260 
     275    if (strcmp(stage,"diff") == 0) {
     276      if (dvodb ) {
     277        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_diff_id_dvo.sql\n%s\n", dvodb,stage);
     278        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     279        bare_query = pxDataGet("addtool_find_diff_id_dvo.sql");
     280        // user supplied dvodb                                                                                                                                             
     281        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     282      } else {
     283        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_diff_id.sql\n%s\n",stage);
     284        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     285        bare_query = pxDataGet("addtool_find_diff_id.sql");
     286        // inherit dvodb from skycalRun, avoid matching NULL                                                                                                                   
     287        psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)");
     288        // this is silly, there is no dvodb in skycalRun...?
     289      }
     290    }
     291
     292    if (strcmp(stage,"fullforce") == 0) {
     293      if (dvodb ) {
     294        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ff_id_dvo.sql\n%s\n", dvodb,stage);
     295        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     296        bare_query = pxDataGet("addtool_find_ff_id_dvo.sql");
     297        // user supplied dvodb                                                                                                                                             
     298        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     299      } else {
     300        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ff_id.sql\n%s\n",stage);
     301        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     302        bare_query = pxDataGet("addtool_find_ff_id.sql");
     303        // inherit dvodb from skycalRun, avoid matching NULL                                                                                                                   
     304        psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
     305        // this is silly, there is no dvodb in skycalRun...?
     306      }
     307    }
    261308
    262309
     
    324371        psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
    325372      }
     373      //needs to be checked HAF xxx
     374      if (strcmp(stage,"diff") == 0) {
     375        psStringAppend(&query, " GROUP BY diff_id, diff_skyfile_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
     376      }
     377      //needs to be checked HAF xxx
     378      if (strcmp(stage,"fullforce") == 0) {
     379        psStringAppend(&query, " GROUP BY ff_id, warp_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
     380      }
     381
     382
     383
    326384
    327385    psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query);
     
    476534    }
    477535
     536    if (strcmp(stage,"diff") == 0) {
     537     
     538      for (long i = 0; i < psArrayLength(output); i++) {
     539        psMetadata *md = output->data[i];
     540
     541        diffRunRow *row = diffRunObjectFromMetadata(md);
     542       
     543        if (!row) {
     544          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
     545          psFree(output);
     546          return false;
     547        }
     548
     549        if (!dvodb) {  // there's no skycalRun.dvodb
     550          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     551          psFree(output);
     552          return false;
     553        }
     554        if (!workdir && !row->workdir) {
     555          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     556          psFree(output);
     557          return false;
     558        }
     559
     560        psFree(row);
     561      }
     562    }
     563
     564    if (strcmp(stage,"fullforce") == 0) {
     565      for (long i = 0; i < psArrayLength(output); i++) {
     566        psMetadata *md = output->data[i];
     567
     568        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     569
     570        if (!row) {
     571          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     572          psFree(output);
     573          return false;
     574        }
     575
     576        if (!dvodb) {  // there's no skycalRun.dvodb
     577          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     578          psFree(output);
     579          return false;
     580        }
     581        if (!workdir && !row->workdir) {
     582          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     583          psFree(output);
     584          return false;
     585        }
     586
     587        psFree(row);
     588      }
     589    }
    478590
    479591
     
    672784      }
    673785   
     786    if (strcmp(stage,"diff") == 0) {
     787     
     788    for (long i = 0; i < psArrayLength(output); i++) {
     789        psMetadata *md = output->data[i];
     790        psS64 stage_id =0;
     791        //      psS64 stage_extra1 = 0;
     792        diffRunRow *row = diffRunObjectFromMetadata(md);
     793        stage_id = row->diff_id;
     794        bool status = false;
     795        psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
     796        if (!status) {
     797          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
     798          return false;
     799        }
     800
     801       
     802        if (!row) {
     803            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     804            psFree(output);
     805            return false;
     806        }
     807       
     808        // queue the exp
     809        if (!pxaddQueueByCamID(config,
     810                               stage,
     811                               stage_id,
     812                               stage_extra1,
     813                               workdir     ? workdir   : row->workdir,
     814                               reduction   ? reduction : row->reduction,
     815                               label       ? label     : row->label,
     816                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     817                               dvodb       ? dvodb     : NULL,
     818                               note        ? note      : NULL,
     819                               image_only,
     820                               minidvodb,
     821                               minidvodb_group,
     822                               minidvodb_name
     823        )) {
     824            if (!psDBRollback(config->dbh)) {
     825                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     826            }
     827            psError(PS_ERR_UNKNOWN, false,
     828                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     829            psFree(row);
     830            psFree(output);
     831            return false;
     832        }
     833        psFree(row);
     834    }
     835      }
     836 
     837    if (strcmp(stage,"fullforce") == 0) {
     838    for (long i = 0; i < psArrayLength(output); i++) {
     839        psMetadata *md = output->data[i];
     840        psS64 stage_id =0;
     841       
     842        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     843        stage_id = row->ff_id;
     844        bool status = false;
     845        psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
     846        if (!status) {
     847          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
     848          return false;
     849        }
     850
     851        if (!row) {
     852            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     853            psFree(output);
     854            return false;
     855        }
     856
     857        // queue the exp
     858        if (!pxaddQueueByCamID(config,
     859                               stage,
     860                               stage_id,
     861                               stage_extra1,
     862                               workdir     ? workdir   : row->workdir,
     863                               reduction   ? reduction : row->reduction,
     864                               label       ? label     : row->label,
     865                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     866                               dvodb       ? dvodb     : NULL,
     867                               note        ? note      : NULL,
     868                               image_only,
     869                               minidvodb,
     870                               minidvodb_group,
     871                               minidvodb_name
     872        )) {
     873            if (!psDBRollback(config->dbh)) {
     874                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     875            }
     876            psError(PS_ERR_UNKNOWN, false,
     877                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     878            psFree(row);
     879            psFree(output);
     880            return false;
     881        }
     882        psFree(row);
     883    }
     884      }
     885
     886
     887
    674888
    675889
     
    695909    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    696910    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
     911    PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "==");
     912    PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "==");
     913
    697914    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    698915    pxcamGetSearchArgs (config, where); // most search arguments based on camera
     
    709926    psString query = NULL;
    710927    if (strcmp(stage, "cam")==0) {
    711       query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     928      query = psStringCopy("UPDATE addRun JOIN camRun on (cam_id = stage_id and stage = 'cam') JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
    712929    }
    713930    if (strcmp(stage, "stack")==0) {
    714       query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");
     931      query = psStringCopy("UPDATE addRun JOIN stackRun on (stack_id = stage_id and stage = 'stack')");
    715932    }
    716933    if (strcmp(stage, "staticsky")==0) {
    717       query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     934      query = psStringCopy("UPDATE addRun JOIN staticskyRun on (sky_id = stage_id and stage = 'staticsky')");
    718935    }
    719936    if (strcmp(stage, "skycal")==0) {
    720       query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id");
     937      query = psStringCopy("UPDATE addRun JOIN skycalRun on (skycal_id = stage_id and stage = 'skycal')");
     938    }
     939    if (strcmp(stage, "diff")==0) {
     940      query = psStringCopy("UPDATE addRun JOIN diffInputSkyfile on (diff_id = stage_id and diff_skyfile_id = stage_extra1 and stage = 'diff') JOIN diffSkyfile on (diff_id, skycell_id) JOIN diffRun using (diff_id)");
     941    }
     942    if (strcmp(stage, "fullforce")==0) {
     943      query = psStringCopy("UPDATE addRun JOIN fullForceResult on (ff_id = stage_id and warp_id = stage_extra1 and stage = 'fullforce') JOIN fullForceRun on (ff_id)");
    721944    }
    722945
     
    743966    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    744967    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
     968    PXOPT_COPY_S64(config->args, where, "-ff_id",    "fullForceRun.ff_id", "==");
     969    PXOPT_COPY_S64(config->args, where, "-diff_id",    "diffRun.diff_id", "==");
    745970    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    746971    pxcamGetSearchArgs (config, where);
     
    764989      query = pxDataGet("addtool_find_pendingexp_skycal.sql");
    765990    }
     991    if (strcmp(stage, "diff")==0) {
     992      query = pxDataGet("addtool_find_pendingexp_diff.sql");
     993    }
     994    if (strcmp(stage, "fullforce")==0) {
     995      query = pxDataGet("addtool_find_pendingexp_ff.sql");
     996    }
    766997
    767998
     
    7901021      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
    7911022    }
     1023    if (strcmp(stage, "diff") == 0) {
     1024      //this group by is needed to join against all the warps (to get camera)
     1025      psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1");
     1026    }
     1027    if (strcmp(stage, "fullforce") == 0) {
     1028      //this group by is needed to join against all the warps (to get camera)
     1029      psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1");
     1030    }
     1031
     1032
     1033
    7921034    // treat limit == 0 as "no limit"
    7931035    if (limit) {
     
    9941236    } else if (strcmp (stage,"skycal") == 0) {
    9951237      query = pxDataGet("addtool_find_processedexp_skycal.sql");
     1238    } else if (strcmp (stage,"diff") == 0) {
     1239      query = pxDataGet("addtool_find_processedexp_diff.sql");
     1240    } else if (strcmp (stage,"fullforce") == 0) {
     1241      query = pxDataGet("addtool_find_processedexp_ff.sql");
     1242
    9961243    } else {
    9971244        psFree(where);
     
    11121359    if (strcmp(stage, "skycal") == 0) {
    11131360      query = pxDataGet("addtool_revertprocessedexp_skycal.sql");
     1361    }
     1362    if (strcmp(stage, "diff") == 0) {
     1363      query = pxDataGet("addtool_revertprocessedexp_diff.sql");
     1364    }
     1365    if (strcmp(stage, "fullforce") == 0) {
     1366      query = pxDataGet("addtool_revertprocessedexp_ff.sql");
    11141367    }
    11151368
Note: See TracChangeset for help on using the changeset viewer.