IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31280


Ignore:
Timestamp:
Apr 14, 2011, 2:57:53 PM (15 years ago)
Author:
heather
Message:

addrun branch

Location:
branches/haf_branches/haf_add2011
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/haf_branches/haf_add2011/dbconfig/add.md

    r28181 r31280  
    22addRun METADATA
    33    add_id          S64     0       # Primary Key AUTO_INCREMENT
    4     cam_id          S64     0       # Key INDEX(add_id,cam_id) fkey(cam_id) ref camRun(cam_id)
     4    stage           STR     64      # what the stage is (warp, cam, diff,
     5    stage_id          S64     0       # Key INDEX(add_id,cam_id) fkey(cam_id) ref camRun(cam_id)
    56    state           STR     64      # Key
    67    workdir         STR     255
  • branches/haf_branches/haf_add2011/dbconfig/changes.txt

    r31038 r31280  
    20582058UPDATE dbversion set schema_version = '1.1.69', updated= CURRENT_TIMESTAMP();
    20592059
    2060 
    2061 
     2060ALTER TABLE addRun ADD COLUMN stage VARCHAR(64) AFTER add_id;
     2061 ALTER TABLE addRun ADD COLUMN stage_id bigint(20) after stage;
     2062UPDATE addRun set stage_id = cam_id;
     2063##alter table addRun drop cam_id;  (those stupid keys?)
     2064alter table addRun modify cam_id bigint(20) after minidvodb_name;
     2065
     2066
     2067
     2068##ALTER TABLE addRun CHANGE cam_id stage_id bigint(20);
     2069
     2070
     2071
  • branches/haf_branches/haf_add2011/ippScripts/scripts/addstar_run.pl

    r30326 r31280  
    3737}
    3838my $minidvodb_path;
    39 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
     39my ( $add_id, $camera, $stage, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
    4040     $no_op, $redirect, $save_temps);
    4141GetOptions(
    42     'exp_tag=s'          => \$exp_tag, # Exposure identifier
    4342    'add_id=s'          => \$add_id, # Camtool identifier
    4443    'camera|c=s'        => \$camera, # Camera
     44    'stage|s=s'        => \$stage, # Camera
     45   
    4546    'dbname|d=s'        => \$dbname, # Database name
    4647    'outroot|w=s'       => \$outroot, # output file base name
    47     'camroot|w=s'       => \$camroot, # camera stage root name.
     48    'stageroot|w=s'       => \$stageroot, # stage root name.
    4849    'reduction=s'       => \$reduction, # Reduction class
    4950    'dvodb|w=s'         => \$dvodb,  # output DVO database
     
    6162pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    6263pod2usage(
    63           -msg => "Required options: --exp_tag --add_id --camera --outroot --dvodb --camroot",
     64          -msg => "Required options: --add_id --camera --outroot --dvodb --stageroot --stage",
    6465          -exitval => 3,
    6566          ) unless
    66     defined $exp_tag and
     67    defined $stage and
    6768    defined $add_id and
    6869    defined $outroot and
    69     defined $camroot and
     70    defined $stageroot and
    7071    defined $dvodb and
    7172    defined $camera;
     
    8687# Recipes to use based on reduction class
    8788$reduction = 'DEFAULT' unless defined $reduction;
    88 
     89my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR');
    8990# XXX This is now not used: do we still need it?
    90 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
     91if ($stage =~/cam/) {
     92  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
     93}
     94if ($stage =~/stack/) {
     95  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR_STACK'); # Recipe to use
     96}
     97if ($stage =~/staticsky/) {
     98  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR_STATICSKY'); # Recipe to use
     99}
    91100&my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
    92101
     
    97106
    98107# the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs
    99 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $camroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     108my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    100109my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    101110
  • branches/haf_branches/haf_add2011/ippTasks/addstar.pro

    r30327 r31280  
    1717
    1818macro addstar.on
    19   task addstar.exp.load
     19  task addstar.exp.load.stack
     20    active true
     21  end
     22  task addstar.exp.load.cam
     23    active true
     24  end
     25  task addstar.exp.load.staticsky
    2026    active true
    2127  end
     
    2632
    2733macro addstar.off
    28   task addstar.exp.load
     34  task addstar.exp.load.stack
     35    active false
     36  end
     37  task addstar.exp.load.cam
     38    active false
     39  end
     40  task addstar.exp.load.staticsky
    2941    active false
    3042  end
     
    5466# new entries are added to addPendingExp
    5567# skip already-present entries
    56 task           addstar.exp.load
     68task           addstar.exp.load.stack
    5769  host         local
    5870
     
    6779  task.exec
    6880   # if ($LABEL:n == 0) break
    69     $run = addtool -pendingexp
     81    $run = addtool -pendingexp -stage stack
    7082    if ($DB:n == 0)
    7183      option DEFAULT
     
    109121end
    110122
     123task           addstar.exp.load.cam
     124  host         local
     125
     126  periods      -poll $LOADPOLL
     127  periods      -exec $LOADEXEC
     128  periods      -timeout 30
     129  npending     1
     130
     131  stdout NULL
     132  stderr $LOGDIR/addstar.exp.log
     133
     134  task.exec
     135   # if ($LABEL:n == 0) break
     136    $run = addtool -pendingexp -stage cam
     137    if ($DB:n == 0)
     138      option DEFAULT
     139    else
     140      # save the DB name for the exit tasks
     141      option $DB:$addstar_DB
     142      $run = $run -dbname $DB:$addstar_DB
     143      $addstar_DB ++
     144      if ($addstar_DB >= $DB:n) set addstar_DB = 0
     145    end
     146    add_poll_args run
     147    add_poll_labels run
     148    command $run
     149  end
     150
     151  # success
     152  task.exit    0
     153    # convert 'stdout' to book format
     154    ipptool2book stdout addPendingExp -key add_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     155    if ($VERBOSE > 2)
     156      book listbook addPendingExp
     157    end
     158
     159    # delete existing entries in the appropriate pantaskStates
     160    process_cleanup addPendingExp
     161  end
     162
     163  # default exit status
     164  task.exit    default
     165    showcommand failure
     166  end
     167
     168  task.exit    crash
     169    showcommand crash
     170  end
     171
     172  # operation times out?
     173  task.exit    timeout
     174    showcommand timeout
     175  end
     176end
     177task           addstar.exp.load.staticsky
     178  host         local
     179
     180  periods      -poll $LOADPOLL
     181  periods      -exec $LOADEXEC
     182  periods      -timeout 30
     183  npending     1
     184
     185  stdout NULL
     186  stderr $LOGDIR/addstar.exp.log
     187
     188  task.exec
     189   # if ($LABEL:n == 0) break
     190    $run = addtool -pendingexp -stage staticsky
     191    if ($DB:n == 0)
     192      option DEFAULT
     193    else
     194      # save the DB name for the exit tasks
     195      option $DB:$addstar_DB
     196      $run = $run -dbname $DB:$addstar_DB
     197      $addstar_DB ++
     198      if ($addstar_DB >= $DB:n) set addstar_DB = 0
     199    end
     200    add_poll_args run
     201    add_poll_labels run
     202    command $run
     203  end
     204
     205  # success
     206  task.exit    0
     207    # convert 'stdout' to book format
     208    ipptool2book stdout addPendingExp -key add_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     209    if ($VERBOSE > 2)
     210      book listbook addPendingExp
     211    end
     212
     213    # delete existing entries in the appropriate pantaskStates
     214    process_cleanup addPendingExp
     215  end
     216
     217  # default exit status
     218  task.exit    default
     219    showcommand failure
     220  end
     221
     222  task.exit    crash
     223    showcommand crash
     224  end
     225
     226  # operation times out?
     227  task.exit    timeout
     228    showcommand timeout
     229  end
     230end
    111231# run the addstar script on pending exposures
    112232task           addstar.exp.run
     
    162282    stderr $LOGDIR/addstar.exp.log
    163283
    164     $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA --dvodb $DVODB --camroot $CAMROOT --outroot $outroot --redirect-output
     284    $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA --dvodb $DVODB --stage $STAGE --stageroot $STAGEROOT --outroot $outroot --redirect-output
    165285    if ("$REDUCTION" != "NULL")
    166286      $run = $run --reduction $REDUCTION
  • branches/haf_branches/haf_add2011/ippTasks/survey.pro

    r30531 r31280  
    232232macro survey.add.addstar
    233233  if ($0 != 4)
    234     echo "USAGE: survey.add.addstar (label) (dvodb) (minidvodb_group)"
     234    echo "USAGE: survey.add.addstar (label) (dvodb) (minidvodb_group) (stage)"
    235235    break
    236236  end
     
    238238  book setword SURVEY_ADDSTAR $1 DVODB $2
    239239  book setword SURVEY_ADDSTAR $1 MINIDVODB_GROUP $3
     240  book setwork SURVEY_ADDSTAR $1 STAGE $4 
    240241  book setword SURVEY_ADDSTAR $1 STATE PENDING
    241242end
     
    753754    book getword SURVEY_ADDSTAR $label DVODB -var dvodb
    754755    book getword SURVEY_ADDSTAR $label MINIDVODB_GROUP -var minidvodb_group
     756    book getword SURVEY_ADDSTAR $label STAGE -var stage
     757   
    755758 
    756759 #   $run = addtool -definebyquery -destreaked -label $label -set_dvodb $dbodb
     
    763766    end
    764767   
    765     $run = $run -definebyquery -destreaked -label $label -set_dvodb $dvodb -set_minidvodb_group $minidvodb_group -set_minidvodb -set_label $minidvodb_group
     768    $run = $run -definebyquery -label $label -set_dvodb $dvodb -set_minidvodb_group $minidvodb_group -set_minidvodb -set_label $minidvodb_group -stage $stage
    766769    # echo $run
     770    if ($stage == 'cam')
     771        #only queue destreaked cams. stacks and staticsky don't need this
     772        $run = $run -destreaked
     773    end
     774   
     775
    767776    command $run
    768777  end
  • branches/haf_branches/haf_add2011/ippTools/share/Makefile.am

    r30373 r31280  
    88        addtool_find_cam_id_dvo.sql \
    99        addtool_find_cam_id.sql \
     10        addtool_find_sky_id_dvo.sql \
     11        addtool_find_sky_id.sql \
     12        addtool_find_stack_id_dvo.sql \
     13        addtool_find_stack_id.sql \
    1014        addtool_find_pendingexp.sql \
     15        addtool_find_pendingexp_cam.sql \
     16        addtool_find_pendingexp_stack.sql \
     17        addtool_find_pendingexp_staticsky.sql \
    1118        addtool_find_pendingmergeprocess.sql \
    12         addtool_find_processedexp.sql \
     19        addtool_find_processedexp_cam.sql \
     20        addtool_find_processedexp_stack.sql \
     21        addtool_find_processedexp_staticsky.sql \
    1322        addtool_find_minidvodbprocessed.sql \
    1423        addtool_find_minidvodbrun.sql \
     
    1625        addtool_pendingcleanuprun.sql \
    1726        addtool_queue_cam_id.sql \
     27        addtool_queue_stack_id.sql \
     28        addtool_queue_sky_id.sql \
    1829        addtool_queue_minidvodbrun.sql \
    1930        addtool_revertminidvodbprocessed.sql \
    20         addtool_revertprocessedexp.sql \
     31        addtool_revertprocessedexp_cam.sql \
     32        addtool_revertprocessedexp_stack.sql \
     33        addtool_revertprocessedexp_staticsky.sql \
    2134        bgtool_advancechip.sql \
    2235        bgtool_advancewarp.sql \
  • branches/haf_branches/haf_add2011/ippTools/share/addtool_find_cam_id.sql

    r29407 r31280  
    1111                  addRun.dvodb AS previous_dvodb
    1212           FROM addRun
    13            JOIN camRun USING(cam_id)
     13           JOIN camRun on cam_id=stage_id
    1414           JOIN chipRun USING(chip_id)
    1515          ) as foo
    1616     ON exp_id = added_exp_id
     17     AND stage = 'cam'
    1718     -- hook for qualifying the join on the previous_dvodb
    1819     AND %s
  • branches/haf_branches/haf_add2011/ippTools/share/addtool_find_cam_id_dvo.sql

    r29407 r31280  
    66    AND exp_id NOT IN (SELECT exp_id
    77       FROM addRun
    8        JOIN camRun USING(cam_id)
     8       JOIN camRun on cam_id=stage_id
    99       JOIN chipRun USING(chip_id)
    10        WHERE %s
     10       WHERE stage = 'cam' AND %s
    1111      )
  • branches/haf_branches/haf_add2011/ippTools/share/addtool_find_pendingexp.sql

    r25816 r31280  
    11SELECT
    2     addRun.*,
    3     camProcessedExp.path_base as camroot,
    4     rawExp.exp_tag,
    5     rawExp.exp_id,
    6     rawExp.exp_name,
    7     rawExp.camera,
    8     rawExp.telescope,
    9     rawExp.filelevel
     2    addRun.*
    103FROM addRun
    11 JOIN camRun
    12     USING(cam_id)
    13 JOIN camProcessedExp
    14     USING(cam_id)
    15 JOIN chipRun
    16     USING(chip_id)
    17 JOIN rawExp
    18     USING(exp_id)
    194LEFT JOIN addProcessedExp
    205    USING(add_id)
     
    227    ON addRun.label = addMask.label
    238WHERE
    24     camRun.state = 'full'
    25     AND ((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update')
     9((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update')
    2610    AND addRun.dvodb IS NOT NULL
    2711    AND addRun.workdir IS NOT NULL
  • branches/haf_branches/haf_add2011/ippTools/share/addtool_queue_cam_id.sql

    r28181 r31280  
    22    SELECT
    33        0,              -- add_id
    4         cam_id,         -- cam_id
     4        'cam',          -- stage
     5        cam_id,         -- stage_id
    56        '%s',           -- state
    67        '%s',           -- workdir
  • branches/haf_branches/haf_add2011/ippTools/src/addtool.c

    r30912 r31280  
    119119    pxcamGetSearchArgs (config, where);
    120120    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
     121    PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
     122 PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
     123    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
     124    if (strcmp(stage, "cam")== 0) {
     125
    121126    pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
    122127    pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    123128    PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    124 
    125 
     129    }
     130    if (strcmp(stage, "stack")== 0) {
     131
     132    pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
     133    pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
     134    PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
     135    }
     136    if (strcmp(stage, "staticsky")== 0) {
     137
     138    pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
     139    pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     140    PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
     141    }
     142   
    126143    if (!psListLength(where->list)) {
    127144        psFree(where);
     
    129146        return false;
    130147    }
    131 
     148    // PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    132149    PXOPT_LOOKUP_STR(workdir,     config->args, "-set_workdir", false, false);
    133150    PXOPT_LOOKUP_STR(dvodb,       config->args, "-set_dvodb", false, false);
     
    148165    psString dvodb_string = NULL;
    149166    psString bare_query = NULL;
     167
     168    if (strcmp(stage,"cam") == 0 ) {
    150169    if (dvodb) {
    151       psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n", dvodb);
     170      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);
    152171        // find the cam_id of all the exposures that we want to queue up.
    153172        bare_query = pxDataGet("addtool_find_cam_id_dvo.sql");
     
    155174        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    156175    } else {
    157         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n");
     176      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);
    158177        // find the cam_id of all the exposures that we want to queue up.
    159178        bare_query = pxDataGet("addtool_find_cam_id.sql");
     
    161180        psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)");
    162181    }
     182    }
     183    if (strcmp(stage,"stack") == 0) {
     184    if (dvodb ) {
     185      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);
     186        // find the cam_id of all the exposures that we want to queue up.
     187        bare_query = pxDataGet("addtool_find_stack_id_dvo.sql");
     188        // user supplied dvodb
     189        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     190    } else {
     191      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);
     192        // find the cam_id of all the exposures that we want to queue up.
     193        bare_query = pxDataGet("addtool_find_stack_id.sql");
     194        // inherit dvodb from camRun, avoid matching NULL
     195        psStringAppend(&dvodb_string, "(stackRun.dvodb IS NOT NULL AND previous_dvodb = stackRun.dvodb)");
     196    }
     197    }
     198    if (strcmp(stage,"staticsky") == 0) {
     199    if (dvodb ) {
     200      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_dvo.sql\n%s\n", dvodb,stage);
     201        // find the cam_id of all the exposures that we want to queue up.
     202        bare_query = pxDataGet("addtool_find_sky_id_dvo.sql");
     203        // user supplied dvodb
     204        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     205    } else {
     206      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id.sql\n%s\n",stage);
     207        // find the cam_id of all the exposures that we want to queue up.
     208        bare_query = pxDataGet("addtool_find_sky_id.sql");
     209        // inherit dvodb from camRun, avoid matching NULL
     210        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
     211    }
     212    }
     213
     214
     215
    163216    if (!bare_query) {
    164217        psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     
    184237
    185238    if (destreaked) {
     239      if (strcmp(stage,"cam") == 0) {
    186240        psStringAppend(&query, " AND (camRun.magicked > 0)");
    187     }
     241      }
     242      if (strcmp(stage,"stack") == 0) {
     243        psStringAppend(&query, " AND (stackRun.magicked > 0)");
     244      }
     245      // staticSky has no magicked column.
     246    }
     247
     248    psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query);
    188249
    189250    if (!p_psDBRunQuery(config->dbh, query)) {
    190         psError(PS_ERR_UNKNOWN, false, "database error");
     251      psError(PS_ERR_UNKNOWN, false, "database error, \n%s\n", query);
    191252        psFree(query);
    192253        return false;
     
    217278
    218279    // loop over our list of camRun rows to check the supplied and selected dvodb and workdir values:
     280    if (strcmp(stage,"cam") == 0) {
    219281    for (long i = 0; i < psArrayLength(output); i++) {
    220282        psMetadata *md = output->data[i];
    221283
    222         camRunRow *row = camRunObjectFromMetadata(md);
     284        camRunRow *row = camRunObjectFromMetadata(md);
     285       
    223286        if (!row) {
    224287            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     
    240303        psFree(row);
    241304    }
     305    }
     306    if (strcmp(stage,"stack") == 0) {
     307    for (long i = 0; i < psArrayLength(output); i++) {
     308        psMetadata *md = output->data[i];
     309
     310        stackRunRow *row = stackRunObjectFromMetadata(md);
     311       
     312        if (!row) {
     313            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     314            psFree(output);
     315            return false;
     316        }
     317
     318        if (!dvodb && !row->dvodb) {
     319            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     320            psFree(output);
     321            return false;
     322        }
     323        if (!workdir && !row->workdir) {
     324            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     325            psFree(output);
     326            return false;
     327        }
     328
     329        psFree(row);
     330    }
     331    }
     332    if (strcmp(stage,"staticsky") == 0) {
     333    for (long i = 0; i < psArrayLength(output); i++) {
     334        psMetadata *md = output->data[i];
     335
     336        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     337       
     338        if (!row) {
     339            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     340            psFree(output);
     341            return false;
     342        }
     343
     344        if (!dvodb) {  //there's no staticsky.dvodb
     345            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     346            psFree(output);
     347            return false;
     348        }
     349        if (!workdir && !row->workdir) {
     350            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     351            psFree(output);
     352            return false;
     353        }
     354
     355        psFree(row);
     356    }
     357    }
    242358
    243359    // start a transaction so we don't end up with an exp without any associted
     
    255371
    256372    // loop over our list of camRun rows
     373    if (strcmp(stage,"cam") == 0) {
    257374    for (long i = 0; i < psArrayLength(output); i++) {
    258375        psMetadata *md = output->data[i];
    259 
    260         camRunRow *row = camRunObjectFromMetadata(md);
     376        psS64 stage_id =0;
     377       
     378                  camRunRow *row = camRunObjectFromMetadata(md);
     379          stage_id = row->cam_id;
     380       
    261381        if (!row) {
    262382            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     
    267387        // queue the exp
    268388        if (!pxaddQueueByCamID(config,
    269                                row->cam_id,
     389                               stage,
     390                               stage_id,
    270391                               workdir     ? workdir   : row->workdir,
    271392                               reduction   ? reduction : row->reduction,
     
    283404            }
    284405            psError(PS_ERR_UNKNOWN, false,
    285                     "failed to trying to queue chip_id: %" PRId64, row->cam_id);
     406                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    286407            psFree(row);
    287408            psFree(output);
     
    290411        psFree(row);
    291412    }
     413      }
     414    if (strcmp(stage,"stack") == 0) {
     415    for (long i = 0; i < psArrayLength(output); i++) {
     416        psMetadata *md = output->data[i];
     417        psS64 stage_id =0;
     418       
     419                  stackRunRow *row = stackRunObjectFromMetadata(md);
     420          stage_id = row->stack_id;
     421       
     422        if (!row) {
     423            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     424            psFree(output);
     425            return false;
     426        }
     427
     428        // queue the exp
     429        if (!pxaddQueueByCamID(config,
     430                               stage,
     431                               stage_id,
     432                               workdir     ? workdir   : row->workdir,
     433                               reduction   ? reduction : row->reduction,
     434                               label       ? label     : row->label,
     435                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     436                               dvodb       ? dvodb     : row->dvodb,
     437                               note        ? note      : NULL,
     438                               image_only,
     439                               minidvodb,
     440                               minidvodb_group,
     441                               minidvodb_name
     442        )) {
     443            if (!psDBRollback(config->dbh)) {
     444                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     445            }
     446            psError(PS_ERR_UNKNOWN, false,
     447                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     448            psFree(row);
     449            psFree(output);
     450            return false;
     451        }
     452        psFree(row);
     453    }
     454      }
     455    if (strcmp(stage,"staticsky") == 0) {
     456    for (long i = 0; i < psArrayLength(output); i++) {
     457        psMetadata *md = output->data[i];
     458        psS64 stage_id =0;
     459       
     460        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     461        stage_id = row->sky_id;
     462       
     463        if (!row) {
     464            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     465            psFree(output);
     466            return false;
     467        }
     468
     469        // queue the exp
     470        if (!pxaddQueueByCamID(config,
     471                               stage,
     472                               stage_id,
     473                               workdir     ? workdir   : row->workdir,
     474                               reduction   ? reduction : row->reduction,
     475                               label       ? label     : row->label,
     476                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     477                               dvodb       ? dvodb     : NULL,
     478                               note        ? note      : NULL,
     479                               image_only,
     480                               minidvodb,
     481                               minidvodb_group,
     482                               minidvodb_name
     483        )) {
     484            if (!psDBRollback(config->dbh)) {
     485                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     486            }
     487            psError(PS_ERR_UNKNOWN, false,
     488                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     489            psFree(row);
     490            psFree(output);
     491            return false;
     492        }
     493        psFree(row);
     494    }
     495      }
     496
    292497    psFree(output);
    293498
     
    308513    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
    309514    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
     515    PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackRun.stack_id", "==");
     516   PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
     517   
     518    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    310519    pxcamGetSearchArgs (config, where); // most search arguments based on camera
    311520    PXOPT_COPY_STR(config->args, where, "-label",     "addRun.label", "==");
     
    319528        return false;
    320529    }
    321 
    322     psString query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     530    psString query = NULL;
     531    if (strcmp(stage, "cam")==0) {
     532    query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     533    }
     534    if (strcmp(stage, "stack")==0) {
     535    query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");
     536    }
     537    if (strcmp(stage, "staticsky")==0) {
     538    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     539    }
    323540
    324541    // pxUpdateRun gets parameters from config->args and runs the update query
     
    340557    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
    341558    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
     559    PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackRun.stack_id", "==");
     560    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
     561    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    342562    pxcamGetSearchArgs (config, where);
    343563    pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");
     
    345565    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    346566    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    347 
    348     psString query = pxDataGet("addtool_find_pendingexp.sql");
     567   
     568    psString query = NULL;
     569   
     570    if (strcmp(stage, "cam")==0) {
     571    query = pxDataGet("addtool_find_pendingexp_cam.sql");
     572    }
     573    if (strcmp(stage, "stack")==0) {
     574    query = pxDataGet("addtool_find_pendingexp_stack.sql");
     575    }
     576    if (strcmp(stage, "staticsky")==0) {
     577    query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
     578    }
     579
     580
    349581    if (!query) {
    350582        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     
    359591    }
    360592    psFree(where);
     593    if (strcmp(stage, "stack") == 0) {
     594      //this group by is needed to join against all the warps (to get camera)
     595      psStringAppend(&query, " GROUP BY %s", "stack_id");
     596    }
     597    if (strcmp(stage, "staticsky") == 0) {
     598      //this group by is needed to join against all the warps (to get camera)
     599      psStringAppend(&query, " GROUP BY %s", "sky_id");
     600    }
    361601
    362602    // treat limit == 0 as "no limit"
     
    522762    psMetadata *where = psMetadataAlloc();
    523763    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",    "==");
    524     PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",    "==");
     764    PXOPT_COPY_S64(config->args, where, "-stage_id",    "addRun.stage_id",    "==");
     765    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    525766    pxcamGetSearchArgs (config, where);
    526767    pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
     
    537778        return false;
    538779    }
    539 
    540     psString query = pxDataGet("addtool_find_processedexp.sql");
     780    psString query = NULL;
     781
     782    if (strcmp (stage,"cam") == 0) {
     783    query = pxDataGet("addtool_find_processedexp_cam.sql");
     784    }
     785    if (strcmp (stage,"stack") == 0) {
     786    query = pxDataGet("addtool_find_processedexp_stack.sql");
     787    }
     788    if (strcmp (stage,"staticsky") == 0) {
     789    query = pxDataGet("addtool_find_processedexp_staticsky.sql");
     790    }
     791   
    541792    if (!query) {
    542793        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     
    567818        psStringAppend(&query, " %s", " WHERE addProcessedExp.fault = 0");
    568819    }
     820    psStringAppend(&query, " AND stage = '%s'", stage);
     821
    569822    psFree(where);
    570823
     
    616869    psMetadata *where = psMetadataAlloc();
    617870    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",         "==");
    618     PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",         "==");
     871    PXOPT_COPY_S64(config->args, where, "-stage_id",    "addRun.stage_id",         "==");
     872    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    619873    pxcamGetSearchArgs (config, where);
    620874    pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
     
    634888
    635889    {
    636         psString query = pxDataGet("addtool_revertprocessedexp.sql");
    637         if (!query) {
     890      psString query = NULL;
     891      if (strcmp(stage, "cam") == 0) {
     892         query = pxDataGet("addtool_revertprocessedexp_cam.sql");
     893        }
     894       
     895    if (strcmp(stage, "stack") == 0) {
     896         query = pxDataGet("addtool_revertprocessedexp_stack.sql");
     897      }
     898     if (strcmp(stage, "staticsky") == 0) {
     899         query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
     900      }
     901      if (!query) {
    638902            // rollback
    639             if (!psDBRollback(config->dbh)) {
     903        if (!psDBRollback(config->dbh)) {
    640904                psError(PS_ERR_UNKNOWN, false, "database error");
    641905            }
     
    681945    psMetadata *where = psMetadataAlloc();
    682946    PXOPT_COPY_S64(config->args, where, "-add_id",   "add_id",   "==");
    683     PXOPT_COPY_S64(config->args, where, "-cam_id",  "cam_id",  "==");
     947    PXOPT_COPY_S64(config->args, where, "-stage_id",  "stage_id",  "==");
     948    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    684949    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
    685950
  • branches/haf_branches/haf_add2011/ippTools/src/addtoolConfig.c

    r30912 r31280  
    4949    // -definebyquery
    5050    psMetadata *definebyqueryArgs = psMetadataAlloc();
     51    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-stage",             0, "set the stage (required)", NULL);
    5152    psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-cam_id",             0, "search by cam_id", 0);
     53    psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-stack_id",             0, "search by stack_id", 0);
     54    psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-sky_id",             0, "search by sky_id", 0);
    5255    pxcamSetSearchArgs(definebyqueryArgs);
    5356    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL);
     
    7275    // -updaterun
    7376    psMetadata *updaterunArgs = psMetadataAlloc();
     77    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-stage",             0, "set the stage (required)", NULL);
    7478    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-add_id",                 0, "search by add_id", 0);
    7579    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-cam_id",                 0, "search by cam_id", 0);
     80    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stack_id",                 0, "search by stack_id", 0);
     81    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-sky_id",                 0, "search by sky_id", 0);
    7682    pxcamSetSearchArgs(updaterunArgs);
    7783    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label",                  0, "search by addRun label", NULL);
     
    8995    // -pendingexp
    9096    psMetadata *pendingexpArgs = psMetadataAlloc();
     97    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-stage",             0, "set the stage (required)", NULL);
    9198    psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-add_id",            0, "search by add_id", 0);
    9299    psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id",            0, "search by cam_id", 0);
     100    psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-stack_id",                 0, "search by stack_id", 0);
     101    psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-sky_id",                 0, "search by sky_id", 0);
    93102    pxcamSetSearchArgs(pendingexpArgs);
    94103    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL);
     
    109118    psMetadata *processedexpArgs = psMetadataAlloc();
    110119    psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
    111     psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id",   0,            "search by cam_id", 0);
     120    psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-stage_id",   0,            "search by stage_id", 0);
     121    psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-stage",             0, "set the stage", NULL);
    112122    pxcamSetSearchArgs(processedexpArgs);
    113123    psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL);
     
    122132    psMetadata *revertprocessedexpArgs = psMetadataAlloc();
    123133    psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
    124     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id",   0,            "search by cam_id", 0);
     134    psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-stage_id",   0,            "search by stage_id", 0);
     135    psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-stage",             0, "set the stage", NULL);
    125136    pxcamSetSearchArgs(revertprocessedexpArgs);
    126137    psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label",    PS_META_DUPLICATE_OK, "search by addRun label", NULL);
     
    132143    psMetadata *updateprocessedexpArgs = psMetadataAlloc();
    133144    psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0,            "search by addtool ID", 0);
    134     psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-cam_id",  0,            "search by camtool ID", 0);
     145    psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-stage_id",  0,            "search by stage_id", 0);
     146    psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-stage",             0, "set the stage", NULL);
    135147    psMetadataAddS16(updateprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
    136148
  • branches/haf_branches/haf_add2011/ippTools/src/flatcorr.c

    r28181 r31280  
    664664        if (!pxaddQueueByCamID(
    665665                config,
     666                "cam",
    666667                row->cam_id,
    667668                row->workdir,
  • branches/haf_branches/haf_add2011/ippTools/src/pxadd.c

    r28181 r31280  
    3737    if (!pxIsValidState(state)) {
    3838        psError(PS_ERR_UNKNOWN, false,
    39                 "invalid camRun state: %s", state);
     39                "invalid stageRun state: %s", state);
    4040        return false;
    4141    }
     
    5151
    5252
    53 bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)
     53bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *stage, const char *state)
    5454{
    5555    PS_ASSERT_PTR_NON_NULL(config, false);
     
    5959    if (!pxIsValidState(state)) {
    6060        psError(PS_ERR_UNKNOWN, false,
    61                 "invalid chipRun state: %s", state);
     61                "invalid stageRun state: %s", state);
    6262        return false;
    6363    }
    64 
    65     psString query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET addRun.state = '%s'");
    66 
     64    psString query = NULL;
     65    if (strcmp(stage, "cam") == 0) {
     66      query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET addRun.state = '%s'");
     67    }
     68    if (strcmp(stage, "stack") == 0) {
     69      ///xxx this needs to be fixed
     70     
     71      /// psString query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET addRun.state = '%s'");
     72    }
    6773    if (where) {
    6874        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     
    98104}
    99105
    100 bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)
     106bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *stage, const char *label)
    101107{
    102108    PS_ASSERT_PTR_NON_NULL(config, false);
    103109    // note label == NULL should be explicitly allowed
    104 
     110    //xxx fix for stack
    105111    psString query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET addRun.label = '%s'");
    106112
     
    123129
    124130bool pxaddQueueByCamID(pxConfig *config,
    125                        psS64 cam_id,
     131                       char *stage,
     132                       psS64 stage_id,
    126133                       char *workdir,
    127134                       char *reduction,
     
    140147    static psString query = NULL;
    141148    if (!query) {
     149      if (strcmp( stage , "cam") == 0) {
    142150        query = pxDataGet("addtool_queue_cam_id.sql");
    143151        psMemSetPersistent(query, true);
     152      }
     153      if (strcmp(stage,"stack") == 0) {
     154        query = pxDataGet("addtool_queue_stack_id.sql");
     155        psMemSetPersistent(query, true);
     156      }
     157      if (strcmp(stage,"staticsky") == 0) {
     158        query = pxDataGet("addtool_queue_sky_id.sql");
     159        psMemSetPersistent(query, true);
     160      }
    144161        if (!query) {
    145162            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     
    148165    }
    149166
     167    psTrace("addtool.c", PS_LOG_INFO, "pxadd query \n%s\n",query);
    150168    // queue the exp
    151169    // Note: cam_id is being cast here work around psS64 have a different type different
    152170    // on 32/64
    153171    if (!p_psDBRunQueryF(config->dbh, query,
    154                         "new", // state
     172                        "new", // state
    155173                         workdir  ? workdir   : "NULL",
    156                          "dirty", //workdir_state
     174                          "dirty", //workdir_state
    157175                         reduction? reduction : "NULL",
    158176                         label    ? label     : "NULL",
     
    164182                         minidvodb_group,
    165183                         minidvodb_name,
    166                          (long long) cam_id
     184                         (long long) stage_id
    167185    )) {
    168186      psError(PS_ERR_UNKNOWN, false, "database error %s", query);
  • branches/haf_branches/haf_add2011/ippTools/src/pxadd.h

    r28181 r31280  
    2626
    2727bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state);
    28 bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state);
     28bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *stage, const char *state);
    2929bool pxaddRunSetLabel(pxConfig *config, psS64 add_id, const char *label);
    30 bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label);
     30bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *stage, const char *label);
    3131
    3232bool pxaddQueueByCamID(pxConfig *config,
    33                        psS64 cam_id,
     33                       char *stage,
     34                       psS64 stage_id,
    3435                       char *workdir,
    3536                       char *reduction,
Note: See TracChangeset for help on using the changeset viewer.