IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11011


Ignore:
Timestamp:
Jan 10, 2007, 12:12:35 PM (19 years ago)
Author:
eugene
Message:

first pass on convering queues to books

Location:
branches/eam_branch_00/ippTasks
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_00/ippTasks/detrend.norm.pro

    r10745 r11011  
    1 
    2 ## this file contains the tasks for running the detrend normalization stage
    3 
    4 ## these tasks use the queue DetrendNorm
    5 ## the DetrendNorm queue contains:
    6 ## STATE DET_ID ITER
    7 
    8 queueinit DetrendNorm
    9 queueinit DetrendNormStat
    10 queueinit DetrendNormExp
     1## this file contains the tasks for running the detrend normalization stages
     2
    113if ($?network == 0)
    124  $network = 1
     
    157  $parallel = 0
    168end
    17 
    18 $DetrendNormFail = 0
    19 $DetrendNormStatFail = 0
    20 $DetrendNormExpFail = 0
    21 
    229if ($?VERBOSE == 0)
    2310  echo "VERBOSE not defined: load pantasks.pro first"
     
    2815  break
    2916end
     17
    3018$LOGSUBDIR = $LOGDIR/detrend
    3119exec mkdir -p $LOGSUBDIR
    3220
     21book init DetrendNormStat
     22book init DetrendNorm
     23book init DetrendNormExp
     24
    3325macro detnorm.status
    34   queueprint DetrendNorm
    35   queueprint DetrendNormStat
    36   queueprint DetrendNormExp
    37   echo "DetrendNormFail: $DetrendNormFail"
    38   echo "DetrendNormStatFail: $DetrendNormStatFail"
    39   echo "DetrendNormExpFail: $DetrendNormExpFail"
     26  book listbook DetrendNormStat
     27  book listbook DetrendNorm
     28  book listbook DetrendNormExp
    4029end
    4130
     
    5443
    5544  task.exec
    56     command      dettool -tonormalizedstat -simple -limit {$DetrendNormStatFail + 20}
     45    command dettool -tonormalizedstat -limit 20
    5746  end
    5847
    5948  # success
    6049  task.exit    0
    61     # XXX is it necessary for these to be local?
    62     # drop after this task macro is done?
    63     local i Nqueue
    64 
    65     # compare output with newImage queue
    66     # only add entries which don't exist in queue
    67     queuesize stdout -var Nqueue
    68     for i 0 $Nqueue
    69       queuepop stdout -var line
    70       if ($VERBOSE > 2)
    71         echo $line
    72       end
    73       list word -split $line
    74       $DET_ID   = $word:0
    75       $DET_TYPE = $word:1
    76       $ITER     = $word:2
    77       $CAMERA   = $word:3
    78       queuepush DetrendNormStat -uniq -key 1:3 "NEW $DET_ID $DET_TYPE $ITER $CAMERA"
     50    # convert 'stdout' to book format
     51    ipptool2book stdout DetrendNormStat -key det_id:iter -uniq
     52    if ($VERBOSE > 2)
     53      book listbook DetrendNormStat
    7954    end
    8055
    8156    # delete existing entries which are DONE
    82     queuedrop DetrendNormStat -key 0 DONE
    83   end
    84 
    85   # locked list
     57    book delpage DetrendNormStat -key state DONE
     58  end
     59
    8660  # default exit status
    8761  task.exit    default
     
    10276
    10377  task.exec
    104     queuesize DetrendNormStat -var N
     78    book npages DetrendNormStat -var N
    10579    if ($N == 0) break
    10680    if ($network == 0) break
    10781   
    108     # look for new images on the internal DetrendNormStat queue
    109     # caution with these 'if' statements: syntax errors
    110     # will make the task fail without given a good status
    111     queuepop DetrendNormStat -var line -key 0 NEW
    112     if ("$line" == "NULL") break
    113 
    114     strpop line state
    115     queuepush DetrendNormStat -replace -key 1:3 "RUN $line"
    116 
    117     # the DetrendNormStat queue contains:
    118     # STATE DET_ID ITER
    119     list word -split $line
    120     $DET_ID   = $word:0
    121     $DET_TYPE = $word:1
    122     $ITER     = $word:2
    123     $CAMERA   = $word:3
    124 
    125     # XXX add $WORKDIR/$LOG_DIR
    126     stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
    127     stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     82    # look for new images in DetrendNormStat
     83    book getpage DetrendNormStat 0 -var pageName -key state NULL
     84    if ($pageName == NULL) break
     85
     86    book setword DetrendNormStat $pageName state RUN
     87    book getword DetrendNormStat $pageName DET_ID   -var DET_ID
     88    book getword DetrendNormStat $pageName DET_TYPE -var DET_TYPE
     89    book getword DetrendNormStat $pageName ITER     -var ITER
     90    book getword DetrendNormStat $pageName CAMERA   -var CAMERA 
    12891
    12992    # specify choice of remote host:
     
    13497    end
    13598
     99    # XXX add $WORKDIR/$LOG_DIR
     100    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     101    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     102
     103    # save the pageName for future reference below
     104    options $pageName
     105
    136106    # create example job options as a demonstration
    137     options "$line"
    138107    if ($VERBOSE > 1)
    139108      echo command detrend_norm_calc.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE
     
    144113  # success
    145114  task.exit 0
    146     queuepush DetrendNormStat -replace -key 1:3 "DONE $options:0"
    147   end
    148 
    149   # default exit status
    150   task.exit    default
    151     showcommand failure
    152     queuepush DetrendNormStat -replace -key 1:3 "FAIL $options:0"
    153     $DetrendNormStatFail ++
    154   end
    155 
    156   # operation times out?
    157   task.exit    timeout
    158     showcommand timeout
    159     queuepush DetrendNormStat -replace -key 1:3 "TIMEOUT $options:0"
    160    $DetrendNormStatFail ++
     115    book setword DetrendNormStat $options:0 state DONE
     116  end
     117
     118  # default exit status
     119  task.exit    default
     120    showcommand failure
     121    book setword DetrendNormStat $options:0 state FAIL
     122  end
     123
     124  # operation times out?
     125  task.exit    timeout
     126    showcommand timeout
     127    book setword DetrendNormStat $options:0 state TIMEOUT
    161128  end
    162129end
    163130
    164131# select images ready for copy
    165 # new entries are added to queue DetrendNorm
     132# new entries are added to DetrendNorm
    166133# compare the new list with the ones already selected
    167134task           dettool.norm.load
     
    176143
    177144  task.exec
    178     command      dettool -tonormalize -simple -limit {$DetrendNormFail + 20}
     145    command dettool -tonormalize -limit 20
    179146  end
    180147
    181148  # success
    182149  task.exit    0
    183     # XXX is it necessary for these to be local?
    184     # drop after this task macro is done?
    185     local i Nqueue
    186 
    187     # compare output with newImage queue
    188     # only add entries which don't exist in queue
    189     queuesize stdout -var Nqueue
    190     for i 0 $Nqueue
    191       queuepop stdout -var line
    192       if ($VERBOSE > 2)
    193         echo $line
    194       end
    195       list word -split $line
    196       $DET_TYPE = $word:0
    197       $CAMERA   = $word:1
    198       $URI      = $word:2
    199       $DET_ID   = $word:3
    200       $ITER     = $word:4
    201       $CLASS_ID = $word:5
    202       $NORM     = $word:6
    203       queuepush DetrendNorm -uniq -key 4:5 "NEW $DET_TYPE $CAMERA $URI $DET_ID $ITER $CLASS_ID $NORM"
     150    # convert 'stdout' to book format
     151    ipptool2book stdout DetrendNorm -key det_id:iter -uniq
     152    if ($VERBOSE > 2)
     153      book listbook DetrendNorm
    204154    end
    205155
    206156    # delete existing entries which are DONE
    207     queuedrop DetrendNorm -key 0 DONE
    208   end
    209 
    210   # locked list
     157    book delpage DetrendNorm -key state DONE
     158  end
     159
    211160  # default exit status
    212161  task.exit    default
     
    227176
    228177  task.exec
    229     queuesize DetrendNorm -var N
     178    book npages DetrendNorm -var N
    230179    if ($N == 0) break
    231180    if ($network == 0) break
    232181   
    233     # look for new images on the internal DetrendNorm queue
    234     # caution with these 'if' statements: syntax errors
    235     # will make the task fail without given a good status
    236     queuepop DetrendNorm -var line -key 0 NEW
    237     if ("$line" == "NULL") break
    238 
    239     strpop line state
    240     queuepush DetrendNorm -replace -key 4:5 "RUN $line"
    241 
    242     # the DetrendNorm queue contains:
    243     # STATE DET_ID ITER
    244     list word -split $line
    245     $DET_TYPE = $word:0
    246     $CAMERA   = $word:1
    247     $URI      = $word:2
    248     $DET_ID   = $word:3
    249     $ITER     = $word:4
    250     $CLASS_ID = $word:5
    251     $NORM     = $word:6
    252 
    253     stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
    254     stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     182    # look for new images in DetrendNorm
     183    book getpage DetrendNorm 0 -var pageName -key state NULL
     184    if ($pageName == NULL) break
     185
     186    book setword DetrendNorm $pageName state RUN
     187    book getword DetrendNorm $pageName det_type -var DET_TYPE
     188    book getword DetrendNorm $pageName camera   -var CAMERA   
     189    book getword DetrendNorm $pageName uri      -var URI     
     190    book getword DetrendNorm $pageName det_id   -var DET_ID   
     191    book getword DetrendNorm $pageName iter     -var ITER     
     192    book getword DetrendNorm $pageName class_id -var CLASS_ID
     193    book getword DetrendNorm $pageName norm     -var NORM     
    255194
    256195    # specify choice of remote host:
     
    261200    end
    262201
     202    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     203    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     204
     205    # save the pageName for future reference below
     206    options $pageName
     207
    263208    # create example job options as a demonstration
    264     options "$line"
    265209    if ($VERBOSE > 1)
    266210      echo command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --value $NORM --input_uri $URI --camera $CAMERA --det_type $DET_TYPE
     
    271215  # success
    272216  task.exit 0
    273     queuepush DetrendNorm -replace -key 4:5 "DONE $options:0"
    274   end
    275 
    276   # default exit status
    277   task.exit    default
    278     showcommand failure
    279     queuepush DetrendNorm -replace -key 4:5 "FAIL $options:0"
    280     $DetrendNormFail ++
    281   end
    282 
    283   # operation times out?
    284   task.exit    timeout
    285     showcommand timeout
    286     queuepush DetrendNorm -replace -key 4:5 "TIMEOUT $options:0"
    287     $DetrendNormFail ++
     217    book setword DetrendNorm $options:0 state DONE
     218  end
     219
     220  # default exit status
     221  task.exit    default
     222    showcommand failure
     223    book setword DetrendNorm $options:0 state FAIL
     224  end
     225
     226  # operation times out?
     227  task.exit    timeout
     228    showcommand timeout
     229    book setword DetrendNorm $options:0 state TIMEOUT
    288230  end
    289231end
     
    303245
    304246  task.exec
    305     command      dettool -tonormalizedexp -simple -limit {$DetrendNormExpFail + 20}
     247    command dettool -tonormalizedexp -limit 20
    306248  end
    307249
    308250  # success
    309251  task.exit    0
    310     # XXX is it necessary for these to be local?
    311     # drop after this task macro is done?
    312     local i Nqueue
    313 
    314     # compare output with newImage queue
    315     # only add entries which don't exist in queue
    316     queuesize stdout -var Nqueue
    317     for i 0 $Nqueue
    318       queuepop stdout -var line
    319       if ($VERBOSE > 2)
    320         echo $line
    321       end
    322       list word -split $line
    323       $DET_ID   = $word:0
    324       $ITER     = $word:1
    325       $DET_TYPE = $word:2
    326       $CAMERA   = $word:3
    327       #$TELESCOPE= $word:4
    328       #$EXP_TYPE = $word:5
    329       #$IMFILES  = $word:6
    330       queuepush DetrendNormExp -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $CAMERA"
     252    # convert 'stdout' to book format
     253    ipptool2book stdout DetrendNormExp -key det_id:iter -uniq
     254    if ($VERBOSE > 2)
     255      book listbook DetrendNormExp
    331256    end
    332257
    333258    # delete existing entries which are DONE
    334     queuedrop DetrendNormExp -key 0 DONE
    335   end
    336 
    337   # locked list
     259    book delpage DetrendNormExp -key state DONE
     260  end
     261
    338262  # default exit status
    339263  task.exit    default
     
    354278
    355279  task.exec
    356     queuesize DetrendNormExp -var N
    357    
     280    book npages DetrendNormExp -var N
    358281    if ($N == 0) break
    359282    if ($network == 0) break
    360283   
    361     # look for new images on the internal DetrendNormExp queue
    362     # caution with these 'if' statements: syntax errors
    363     # will make the task fail without given a good status
    364     queuepop DetrendNormExp -var line -key 0 NEW
    365     if ("$line" == "NULL") break
    366 
    367     strpop line state
    368     queuepush DetrendNormExp -replace -key 1:2 "RUN $line"
    369 
    370     # the DetrendNormExp queue contains:
    371     # STATE DET_ID ITER
    372     list word -split $line
    373     $DET_ID   = $word:0
    374     $ITER     = $word:1
    375     $DET_TYPE = $word:2
    376     $CAMERA   = $word:3
    377     #$TELESCOPE= $word:4
    378     #$EXP_TYPE = $word:5
    379     #$IMFILES  = $word:6
    380 
    381     # XXX add $WORKDIR/$LOG_DIR
    382     stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
    383     stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     284    # look for new images in DetrendNormExp
     285    book getpage DetrendNormExp 0 -var pageName -key state NULL
     286    if ($pageName == NULL) break
     287
     288    book setword DetrendNormExp $pageName state RUN
     289    book getword DetrendNormExp $pageName det_id   -var DET_ID 
     290    book getword DetrendNormExp $pageName iter     -var ITER   
     291    book getword DetrendNormExp $pageName det_type -var DET_TYPE
     292    book getword DetrendNormExp $pageName camera   -var CAMERA 
    384293
    385294    # specify choice of remote host:
     
    390299    end
    391300
     301    # XXX add $WORKDIR/$LOG_DIR
     302    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     303    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     304
     305    # save the pageName for future reference below
     306    options $pageName
     307
    392308    # create example job options as a demonstration
    393     options "$line"
    394309    if ($VERBOSE > 1)
    395310      echo command detrend_norm_exp.pl --det_id $DET_ID --iteration $ITER --camera $CAMERA --det_type $DET_TYPE
     
    400315  # success
    401316  task.exit 0
    402     queuepush DetrendNormExp -replace -key 1:2 "DONE $options:0"
    403   end
    404 
    405   # default exit status
    406   task.exit    default
    407     showcommand failure
    408     queuepush DetrendNormExp -replace -key 1:2 "FAIL $options:0"
    409     $DetrendNormExpFail ++
    410   end
    411 
    412   # operation times out?
    413   task.exit    timeout
    414     showcommand timeout
    415     queuepush DetrendNormExp -replace -key 1:2 "TIMEOUT $options:0"
    416     $DetrendNormExpFail ++
    417   end
    418 end
     317    book setword DetrendNormExp $options:0 state DONE
     318  end
     319
     320  # default exit status
     321  task.exit    default
     322    showcommand failure
     323    book setword DetrendNormExp $options:0 state FAIL
     324  end
     325
     326  # operation times out?
     327  task.exit    timeout
     328    showcommand timeout
     329    book setword DetrendNormExp $options:0 state TIMEOUT
     330  end
     331end
  • branches/eam_branch_00/ippTasks/detrend.process.pro

    r10745 r11011  
    11## this file contains the tasks for running the detrend processing stage
    2 
    3 # query for pending imfiles to process:
    4 # dettool -raw -simple
    5 # 1 bias 850131b fpa mc 850131b.fits BIAS r.MP9601 1.656000 5.496118 0.349071 0.000000 1155.934692 107.037283 46.214947 37.160000 105.480000 -133.067001 0.000000
    6 # this returns many columns for manual operations. we strip all but the first few:
    7 
    8 # process a single imfile
    9 # detrend_process.pl 1 850131b mc bias 850131b.fits 850131b
    10 
    11 ## these tasks use the queue DetrendProcessImfiles
    12 ## the DetrendProcessImfiles queue contains:
    13 ## STATE DET_ID TYPE EXP_TAG CLASS CLASS_ID URI
    14 
    15 queueinit DetrendProcessImfiles
    16 queueinit DetrendProcessExposures
     2## these tasks use the books DetrendProcessImfiles and DetrendProcessExposures
     3
    174if ($?network == 0)
    185  $network = 1
     
    218  $parallel = 0
    229end
    23 
    24 $DetrendProcessImfileFail = 0
    25 $DetrendProcessExpFail = 0
    26 
    2710if ($?VERBOSE == 0)
    2811  echo "VERBOSE not defined: load pantasks.pro first"
     
    3316  break
    3417end
     18
    3519$LOGSUBDIR = $LOGDIR/detrend
    3620exec mkdir -p $LOGSUBDIR
    3721
     22book init DetrendProcessImfiles
     23book init DetrendProcessExposures
     24
    3825macro detproc.status
    39   queueprint DetrendProcessImfiles
    40   queueprint DetrendProcessExposures
    41   echo "DetrendProcessImfileFail: $DetrendProcessImfileFail"
    42   echo "DetrendProcessExpFail: $DetrendProcessExpFail"
     26  book listbook DetrendProcessImfiles
     27  book listbook DetrendProcessExposures
    4328end
    4429
     
    5742
    5843  task.exec
    59     command dettool -toprocessedimfile -simple -limit {$DetrendProcessImfileFail + 20}
     44    command dettool -toprocessedimfile -limit 20
    6045  end
    6146
    6247  # success
    6348  task.exit    0
    64     # XXX is it necessary for these to be local?
    65     # drop after this task macro is done?
    66     local i Nqueue
    67 
    68     # compare output with newImage queue
    69     # only add entries which don't exist in queue
    70     queuesize stdout -var Nqueue
    71     for i 0 $Nqueue
    72       queuepop stdout -var line
    73       if ($VERBOSE > 2)
    74         echo $line
    75       end
    76       list word -split $line
    77       $DET_ID   = $word:0
    78       $DET_TYPE = $word:1
    79       $EXP_TAG  = $word:2
    80       $CLASS    = $word:3
    81       $CLASS_ID = $word:4
    82       $URI      = $word:5
    83       $CAMERA   = $word:21
    84       queuepush DetrendProcessImfiles -uniq -key 1:3:5 "NEW $DET_ID $DET_TYPE $EXP_TAG $CLASS $CLASS_ID $URI $CAMERA"
     49    # convert 'stdout' to book format
     50    ipptool2book stdout DetrendProcessImfiles -key det_id:exp_tag:class_id -uniq
     51    if ($VERBOSE > 2)
     52      book listbook DetrendProcessImfiles
    8553    end
    8654
    8755    # delete existing entries which are DONE
    88     queuedrop DetrendProcessImfiles -key 0 DONE
     56    book delpage DetrendProcessImfiles -key state DONE
    8957  end
    9058
     
    10068end
    10169
    102 # copy new images, sending job to desired host
     70# run detrend_process_imfile.ps on pending images
    10371task           dettool.process.run
    10472  periods      -poll $runpoll
     
    10775
    10876  task.exec
    109     queuesize DetrendProcessImfiles -var N
     77    book npages DetrendProcessImfiles -var N
    11078    if ($N == 0) break
    11179    if ($network == 0) break
    11280   
    113     # look for new images on the internal DetrendProcessImfiles queue
    114     # caution with these 'if' statements: syntax errors
    115     # will make the task fail without given a good status
    116     queuepop DetrendProcessImfiles -var line -key 0 NEW
    117     if ("$line" == "NULL") break
    118 
    119     strpop line state
    120     queuepush DetrendProcessImfiles -replace -key 1:3:5 "RUN $line"
    121 
    122     ## the DetrendProcessImfiles queue contains:
    123     # STATE DET_ID TYPE EXP_TAG CLASS CLASS_ID URI
    124     ## NOTE: the queue has the STATE prepended
    125     list word -split $line
    126     $DET_ID   = $word:0
    127     $DET_TYPE = $word:1
    128     $EXP_TAG  = $word:2
    129     $CLASS    = $word:3
    130     $CLASS_ID = $word:4
    131     $URI      = $word:5
    132     $CAMERA   = $word:6
     81    # look for new images in DetrendProcessImfiles queue
     82    book getpage DetrendProcessImfiles 0 -var pageName -key state NULL
     83    if ($pageName == NULL) break
     84
     85    book setword DetrendProcessImfiles $pageName state RUN
     86    book getword DetrendProcessImfiles $pageName det_id   -var DET_ID   
     87    book getword DetrendProcessImfiles $pageName det_type -var DET_TYPE
     88    book getword DetrendProcessImfiles $pageName exp_tag  -var EXP_TAG 
     89    book getword DetrendProcessImfiles $pageName class    -var CLASS   
     90    book getword DetrendProcessImfiles $pageName class_id -var CLASS_ID
     91    book getword DetrendProcessImfiles $pageName uri      -var URI     
     92    book getword DetrendProcessImfiles $pageName camera   -var CAMERA   
     93
     94    # specify choice of remote host:
     95    if ($parallel)
     96      host anyhost
     97    else
     98      host local
     99    end
    133100
    134101    $word = `basename $EXP_TAG | tr '.' ' '`
     
    139106    exec mkdir -p $LOGSUBDIR/$base
    140107
     108    # save the pageName for future reference below
     109    options $pageName
     110
     111    # create example job options as a demonstration
     112    setcommand detrend_process_imfile.pl --det_id $DET_ID --det_type $DET_TYPE --exp_tag $EXP_TAG --class $CLASS --class_id $CLASS_ID --input_uri $URI --camera $CAMERA
     113  end
     114
     115  # success
     116  task.exit 0
     117    book setword DetrendProcessImfiles $options:0 state DONE
     118  end
     119
     120  # default exit status
     121  task.exit    default
     122    showcommand failure
     123    book setword DetrendProcessImfiles $options:0 state FAIL
     124  end
     125
     126  # operation times out?
     127  task.exit    timeout
     128    showcommand timeout
     129    book setword DetrendProcessImfiles $options:0 state TIMEOUT
     130 end
     131end
     132
     133# select images ready for copy
     134# new entries are added to queue DetrendProcessExposures
     135# compare the new list with the ones already selected
     136task           dettool.processexp.load
     137  host         local
     138
     139  periods      -poll $loadpoll
     140  periods      -exec $loadexec
     141  periods      -timeout 30
     142
     143  stdout $LOGSUBDIR/detproc.exp.log
     144  stderr $LOGSUBDIR/detproc.exp.log
     145
     146  task.exec
     147    command dettool -toprocessedexp -limit 20
     148  end
     149
     150  # success
     151  task.exit    0
     152    # convert 'stdout' to book format
     153    ipptool2book stdout DetrendProcessExposures -key det_id:iter:exp_tag -uniq
     154    if ($VERBOSE > 2)
     155      book listbook DetrendProcessExposures
     156    end
     157
     158    # delete existing entries which are DONE
     159    book delpage DetrendProcessExposures -key state DONE
     160  end
     161
     162  # error
     163  task.exit    default
     164    showcommand failure
     165  end
     166
     167  # operation times out?
     168  task.exit    timeout
     169    showcommand timeout
     170  end
     171end
     172
     173# copy new images, sending job to desired host
     174task           dettool.processexp.run
     175  periods      -poll $runpoll
     176  periods      -exec $runexec
     177  periods      -timeout 30
     178
     179  task.exec
     180    book npages DetrendProcessExposures -var N
     181    if ($N == 0) break
     182    if ($network == 0) break
     183   
     184    # look for new exposures in DetrendProcessExposures
     185    book getpage DetrendProcessExposures 0 -var pageName -key state NULL
     186    if ($pageName == NULL) break
     187
     188    book setword DetrendProcessExposures $pageName state RUN
     189    book getword DetrendProcessExposures $pageName det_id   -var DET_ID
     190    book getword DetrendProcessExposures $pageName iter     -var ITER
     191    book getword DetrendProcessExposures $pageName det_type -var DET_TYPE
     192    book getword DetrendProcessExposures $pageName exp_tag  -var EXP_TAG
     193    book getword DetrendProcessExposures $pageName camera   -var CAMERA 
     194
    141195    # specify choice of remote host:
    142196    if ($parallel)
     
    146200    end
    147201
    148     # create example job options as a demonstration
    149     options "$line"
    150     if ($VERBOSE > 1)
    151       echo command detrend_process_imfile.pl --det_id $DET_ID --exp_tag $EXP_TAG --class_id $CLASS_ID --det_type $DET_TYPE --input_uri $URI --camera $CAMERA
    152     end
    153     command detrend_process_imfile.pl --det_id $DET_ID --exp_tag $EXP_TAG --class $CLASS --class_id $CLASS_ID --det_type $DET_TYPE --input_uri $URI --camera $CAMERA
    154   end
    155 
    156   # success
    157   task.exit 0
    158     queuepush DetrendProcessImfiles -replace -key 1:3:5 "DONE $options:0"
    159     # detrend_process_imfile.pl --force_exist --det_id $DET_ID --exp_tag $EXP_TAG --class $CLASS --class_id $CLASS_ID --det_type $DET_TYPE --input_uri $URI --camera $CAMERA
    160   end
    161 
    162   # default exit status
    163   task.exit    default
    164     showcommand failure
    165     queuepush DetrendProcessImfiles -replace -key 1:3:5 "FAIL $options:0"
    166     $DetrendProcessImfileFail ++
    167   end
    168 
    169   # operation times out?
    170   task.exit    timeout
    171     showcommand timeout
    172     queuepush DetrendProcessImfiles -replace -key 1:3:5 "TIMEOUT $options:0"
    173     $DetrendProcessImfileFail ++
    174  end
    175 end
    176 
    177 # select images ready for copy
    178 # new entries are added to queue DetrendProcessExposures
    179 # compare the new list with the ones already selected
    180 task           dettool.processexp.load
    181   host         local
    182 
    183   periods      -poll $loadpoll
    184   periods      -exec $loadexec
    185   periods      -timeout 30
    186 
    187   stdout $LOGSUBDIR/detproc.exp.log
    188   stderr $LOGSUBDIR/detproc.exp.log
    189 
    190   task.exec
    191     command dettool -toprocessedexp -simple -limit {$DetrendProcessExpFail + 20}
    192   end
    193 
    194   # success
    195   task.exit    0
    196     # XXX is it necessary for these to be local?
    197     # drop after this task macro is done?
    198     local i Nqueue
    199 
    200     # compare output with newImage queue
    201     # only add entries which don't exist in queue
    202     queuesize stdout -var Nqueue
    203     for i 0 $Nqueue
    204       queuepop stdout -var line
    205       if ($VERBOSE > 2)
    206         echo $line
    207       end
    208       list word -split $line
    209       $DET_ID   = $word:0
    210       $ITER     = $word:1
    211       $DET_TYPE = $word:2
    212       $EXP_TAG  = $word:3
    213       $CAMERA   = $word:4
    214       queuepush DetrendProcessExposures -uniq -key 1:2:4 "NEW $DET_ID $ITER $DET_TYPE $EXP_TAG $CAMERA"
    215     end
    216 
    217     # delete existing entries which are DONE
    218     queuedrop DetrendProcessExposures -key 0 DONE
    219   end
    220 
    221   # error
    222   task.exit    default
    223     showcommand failure
    224   end
    225 
    226   # operation times out?
    227   task.exit    timeout
    228     showcommand timeout
    229   end
    230 end
    231 
    232 # copy new images, sending job to desired host
    233 task           dettool.processexp.run
    234   periods      -poll $runpoll
    235   periods      -exec $runexec
    236   periods      -timeout 30
    237 
    238   task.exec
    239     queuesize DetrendProcessExposures -var N
    240     if ($N == 0) break
    241     if ($network == 0) break
    242    
    243     # look for new images on the internal DetrendProcessExposures queue
    244     # caution with these 'if' statements: syntax errors
    245     # will make the task fail without given a good status
    246     queuepop DetrendProcessExposures -var line -key 0 NEW
    247     if ("$line" == "NULL") break
    248 
    249     strpop line state
    250     queuepush DetrendProcessExposures -replace -key 1:2:4 "RUN $line"
    251 
    252     list word -split $line
    253     $DET_ID   = $word:0
    254     $ITER     = $word:1
    255     $DET_TYPE = $word:2
    256     $EXP_TAG  = $word:3
    257     $CAMERA   = $word:4
    258 
    259202    # XXX this is still a lame rule
    260203    $word = `basename $EXP_TAG | tr '.' ' '`
    261204    list word -split $word
    262205    $base = $word:0
    263 
    264206    stdout $LOGSUBDIR/$base/$EXP_TAG.detproc.$DET_ID.log
    265207    stderr $LOGSUBDIR/$base/$EXP_TAG.detproc.$DET_ID.log
    266208    exec mkdir -p $LOGSUBDIR/$base
    267209
    268     # specify choice of remote host:
    269     if ($parallel)
    270       host anyhost
    271     else
    272       host local
    273     end
     210    # save the pageName for future reference below
     211    options $pageName
    274212
    275213    # create example job options as a demonstration
    276     options "$line"
    277214    if ($VERBOSE > 1)
    278215      echo command detrend_process_exp.pl --det_id $DET_ID --exp_tag $EXP_TAG --camera $CAMERA
     
    283220  # success
    284221  task.exit 0
    285     queuepush DetrendProcessExposures -replace -key 1:2:4 "DONE $options:0"
     222    book setword DetrendProcessExposures $options:0 state DONE
    286223  end
    287224
     
    289226  task.exit    default
    290227    showcommand failure
    291     queuepush DetrendProcessExposures -replace -key 1:2:4 "FAIL $options:0"
    292     $DetrendProcessExpFail ++
     228    book setword DetrendProcessExposures $options:0 state FAIL
    293229  end
    294230
     
    296232  task.exit    timeout
    297233    showcommand timeout
    298     queuepush DetrendProcessExposures -replace -key 1:2:4 "TIMEOUT $options:0"
    299     $DetrendProcessExpFail ++
    300   end
    301 end
     234    book setword DetrendProcessExposures $options:0 state TIMEOUT
     235  end
     236end
  • branches/eam_branch_00/ippTasks/detrend.reject.pro

    r10745 r11011  
    1 
    21## this file contains the tasks for running the detrend processing stage
    32
    4 # dettool -residdetrun -simple
    5 # 1      0    bias
    6 # DET_ID ITER TYPE
    7 
    8 # detrend_reject_exp.pl 1      0    bias
    9 # detrend_reject_exp.pl DET_ID ITER TYPE
    10 
    11 ## these tasks use the queue DetrendResidExp
    12 ## the DetrendRejectExp queue contains:
    13 ## STATE DET_ID ITER TYPE
    14 
    15 queueinit DetrendRejectExp
    163if ($?network == 0)
    174  $network = 1
     
    207  $parallel = 0
    218end
    22 
    23 $DetrendRejectExpFail = 0
    24 
    259if ($?VERBOSE == 0)
    2610  echo "VERBOSE not defined: load pantasks.pro first"
     
    3115  break
    3216end
     17
    3318$LOGSUBDIR = $LOGDIR/detrend
    3419exec mkdir -p $LOGSUBDIR
    3520
     21book init DetrendRejectExp
     22
    3623macro detreject.status
    37   queueprint DetrendRejectExp
    38   echo "DetrendRejectExpFail: $DetrendRejectExpFail"
     24  book listbook DetrendRejectExp
    3925end
    4026
     
    5339
    5440  task.exec
    55     command dettool -residdetrun -simple -limit {$DetrendRejectExpFail + 20}
     41    command dettool -residdetrun -limit 20
    5642  end
    5743
    5844  # success
    5945  task.exit    0
    60     local i Nqueue
    61 
    62     # compare output with newImage queue
    63     # only add entries which don't exist in queue
    64     queuesize stdout -var Nqueue
    65     for i 0 $Nqueue
    66       queuepop stdout -var line
    67       if ($VERBOSE > 2)
    68         echo $line
    69       end
    70       list word -split $line
    71       $DET_ID   = $word:0
    72       $ITER     = $word:1
    73       $DET_TYPE = $word:2
    74       $MODE     = $word:3
    75       $CAMERA   = $word:4
    76       queuepush DetrendRejectExp -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $MODE $CAMERA"
     46    # convert 'stdout' to book format
     47    ipptool2book stdout DetrendRejectExp -key det_id:iter -uniq
     48    if ($VERBOSE > 2)
     49      book listbook DetrendRejectExp
    7750    end
    7851
    7952    # delete existing entries which are DONE
    80     queuedrop DetrendRejectExp -key 0 DONE
     53    book delpage DetrendRejectExp -key state DONE
    8154  end
    8255
     
    9972
    10073  task.exec
    101     queuesize DetrendRejectExp -var N
     74    book npages DetrendRejectExp -var N
    10275    if ($N == 0) break
    10376    if ($network == 0) break
    10477   
    105     # look for new images on the internal DetrendRejectExp queue
    106     # caution with these 'if' statements: syntax errors
    107     # will make the task fail without given a good status
    108     queuepop DetrendRejectExp -var line -key 0 NEW
    109     if ("$line" == "NULL") break
     78    # look for new images in DetrendRejectExp
     79    book getpage DetrendRejectExp 0 -var pageName -key state NULL
     80    if ($pageName == NULL) break
    11081
    111     strpop line state
    112     queuepush DetrendRejectExp -replace -key 1:2 "RUN $line"
    113 
    114     ## the DetrendRejectExp queue contains:
    115     ## STATE DET_ID ITER TYPE
    116     ## NOTE: the queue has the STATE prepended
    117     list word -split $line
    118     $DET_ID   = $word:0
    119     $ITER     = $word:1
    120     $DET_TYPE = $word:2
    121     $MODE     = $word:3
    122     $CAMERA   = $word:4
    123 
    124     # I'd like to add CAMERA to the log file...
    125     stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
    126     stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     82    book setword DetrendRejectExp $pageName state RUN
     83    book getword DetrendRejectExp $pageName DET_ID   -var DET_ID   
     84    book getword DetrendRejectExp $pageName ITER     -var ITER     
     85    book getword DetrendRejectExp $pageName DET_TYPE -var DET_TYPE
     86    book getword DetrendRejectExp $pageName MODE     -var MODE     
     87    book getword DetrendRejectExp $pageName CAMERA   -var CAMERA   
    12788
    12889    # specify choice of remote host:
     
    13394    end
    13495
     96    # I'd like to add CAMERA to the log file...
     97    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     98    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
     99
     100    # save the pageName for future reference below
     101    options $pageName
     102
    135103    # create example job options as a demonstration
    136     options "$line"
    137104    if ($VERBOSE > 1)
    138105      echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
     
    143110  # success
    144111  task.exit 0
    145     queuepush DetrendRejectExp -replace -key 1:2 "DONE $options:0"
     112    book setword DetrendRejectExp $options:0 state DONE
    146113  end
    147114
     
    149116  task.exit    default
    150117    showcommand failure
    151     queuepush DetrendRejectExp -replace -key 1:2 "FAIL $options:0"
    152     $DetrendRejectExpFail ++
     118    book setword DetrendRejectExp $options:0 state FAIL
    153119  end
    154120
     
    156122  task.exit    timeout
    157123    showcommand failure
    158     queuepush DetrendRejectExp -replace -key 1:2 "TIMEOUT $options:0"
    159    $DetrendRejectExpFail ++
     124    book setword DetrendRejectExp $options:0 state TIMEOUT
    160125  end
    161126end
  • branches/eam_branch_00/ippTasks/detrend.resid.pro

    r10745 r11011  
    1 
    21## this file contains the tasks for running the detrend processing stage
    32
    4 # dettool -toresidimfile -simple
    5 # 0    bias 1      850131b mc       o_850131b.mc.fit PPIMAGE_O 1.492870 2.848350 292.565582
    6 # ITER TYPE DET_ID EXP_TAG CLASS_ID URI-IN           
    7 
    8 # detrend_create_resid.pl 1      0    850131b mc       bias bias_mc_1_0.fit o_850131b.mc.fit 850131b
    9 # detrend_create_resid.pl DET_ID ITER EXP_TAG CLASS_ID TYPE (URI-DET)       (URL-IN)         (EXP_TAG)
    10 # URL-DET: $TYPE\_$CLASS_ID\_$DET_ID\_$ITER.fit
    11 
    12 ## these tasks use the queue DetrendResidImfiles
    13 ## the DetrendResidImfiles queue contains:
    14 ## STATE ITER TYPE DET_ID EXP_TAG CLASS_ID URI_IN
    15 
    16 queueinit DetrendResidImfiles
    17 queueinit DetrendResidExposures
    183if ($?network == 0)
    194  $network = 1
     
    227  $parallel = 0
    238end
    24 
    25 $DetrendResidImfileFail = 0
    26 $DetrendResidExpFail = 0
    27 
    289if ($?VERBOSE == 0)
    2910  echo "VERBOSE not defined: load pantasks.pro first"
     
    3415  break
    3516end
     17
    3618$LOGSUBDIR = $LOGDIR/detrend
    3719exec mkdir -p $LOGSUBDIR
    3820
     21book init DetrendResidImfiles
     22book init DetrendResidExposures
     23
    3924macro detresid.status
    40   queueprint DetrendResidImfiles
    41   queueprint DetrendResidExposures
    42   echo "DetrendResidImfileFail: $DetrendResidImfileFail"
    43   echo "DetrendResidExpFail: $DetrendResidExpFail"
     25  book listbook DetrendResidImfiles
     26  book listbook DetrendResidExposures
    4427end
    4528
     
    5841
    5942  task.exec
    60     command dettool -toresidimfile -simple -limit {$DetrendResidImfileFail + 20}
     43    command dettool -toresidimfile -limit 20
    6144  end
    6245
    6346  # success
    6447  task.exit    0
    65     # XXX is it necessary for these to be local?
    66     # drop after this task macro is done?
    67     local i Nqueue
    68 
    69     # compare output with newImage queue
    70     # only add entries which don't exist in queue
    71     queuesize stdout -var Nqueue
    72     for i 0 $Nqueue
    73       queuepop stdout -var line
    74       if ($VERBOSE > 2)
    75         echo $line
    76       end
    77       list word -split $line
    78       $DET_ID   = $word:0
    79       $ITER     = $word:1
    80       $DET_TYPE = $word:2
    81       $MODE     = $word:3
    82       $EXP_TAG  = $word:4
    83       $CLASS_ID = $word:5
    84       $URI      = $word:6
    85       $DET_URI  = $word:7
    86       $CAMERA   = $word:8
    87       ## must include the detID and iter in the key (if we have two running at the same time...)
    88       ## Also needed to be in the output file (or path)
    89       queuepush DetrendResidImfiles -uniq -key 1:2:5:6 "NEW $DET_ID $ITER $DET_TYPE $MODE $EXP_TAG $CLASS_ID $URI $DET_URI $CAMERA"
     48    # convert 'stdout' to book format
     49    ipptool2book stdout DetrendResidImfiles -key det_id:iter:exp_tag:class_id -uniq
     50    if ($VERBOSE > 2)
     51      book listbook DetrendResidImfiles
    9052    end
    9153
    9254    # delete existing entries which are DONE
    93     queuedrop DetrendResidImfiles -key 0 DONE
    94   end
    95 
    96   # locked list
     55    book delpage DetrendResidImfiles -key state DONE
     56  end
     57
    9758  # default exit status
    9859  task.exit    default
     
    11374
    11475  task.exec
    115     queuesize DetrendResidImfiles -var N
     76    book npages DetrendResidImfiles -var N
    11677    if ($N == 0) break
    11778    if ($network == 0) break
    11879   
    119     # look for new images on the internal DetrendResidImfiles queue
    120     # caution with these 'if' statements: syntax errors
    121     # will make the task fail without given a good status
    122     queuepop DetrendResidImfiles -var line -key 0 NEW
    123     if ("$line" == "NULL") break
    124 
    125     strpop line state
    126     queuepush DetrendResidImfiles -replace -key 1:2:5:6 "RUN $line"
    127 
    128     ## the DetrendResidImfiles queue contains:
    129     ## STATE ITER TYPE DET_ID EXP_TAG CLASS_ID URI_IN
    130     ## NOTE: the queue has the STATE prepended
    131     list word -split $line
    132     $DET_ID   = $word:0
    133     $ITER     = $word:1
    134     $DET_TYPE = $word:2
    135     $MODE     = $word:3
    136     $EXP_TAG  = $word:4
    137     $CLASS_ID = $word:5
    138     $URI      = $word:6
    139     $DET_URI  = $word:7
    140     $CAMERA   = $word:8
     80    # look for new images in DetrendResidImfiles
     81    book getpage DetrendResidImfiles 0 -var pageName -key state NULL
     82    if ($pageName == NULL) break
     83
     84    book setword DetrendResidImfiles $pageName state RUN
     85    book getword DetrendResidImfiles $pageName DET_ID   -var DET_ID   
     86    book getword DetrendResidImfiles $pageName ITER     -var ITER     
     87    book getword DetrendResidImfiles $pageName DET_TYPE -var DET_TYPE
     88    book getword DetrendResidImfiles $pageName MODE     -var MODE     
     89    book getword DetrendResidImfiles $pageName EXP_TAG  -var EXP_TAG 
     90    book getword DetrendResidImfiles $pageName CLASS_ID -var CLASS_ID
     91    book getword DetrendResidImfiles $pageName URI      -var URI     
     92    book getword DetrendResidImfiles $pageName DET_URI  -var DET_URI 
     93    book getword DetrendResidImfiles $pageName CAMERA   -var CAMERA   
     94
     95    # specify choice of remote host:
     96    if ($parallel)
     97      host anyhost
     98    else
     99      host local
     100    end
    141101
    142102    $word = `basename $EXP_TAG | tr '.' ' '`
     
    147107    exec mkdir -p $LOGSUBDIR/$base
    148108
     109    # save the pageName for future reference below
     110    options $pageName
     111
     112    # create command
     113    if ($VERBOSE > 1)
     114      echo command detrend_resid.pl --det_id $DET_ID --iteration $ITER --exp_tag $EXP_TAG --class_id $CLASS_ID --det_type $DET_TYPE --detrend $DET_URI --input_uri $URI --camera $CAMERA --mode $MODE
     115    end
     116    command detrend_resid.pl --det_id $DET_ID --iteration $ITER --exp_tag $EXP_TAG --class_id $CLASS_ID --det_type $DET_TYPE --detrend $DET_URI --input_uri $URI --camera $CAMERA --mode $MODE
     117  end
     118
     119  # success
     120  task.exit 0
     121    book setword DetrendResidImfiles $options:0 state DONE
     122  end
     123
     124  # default exit status
     125  task.exit    default
     126    showcommand failure
     127    book setword DetrendResidImfiles $options:0 state FAIL
     128  end
     129
     130  # operation times out?
     131  task.exit    timeout
     132    showcommand timeout
     133    book setword DetrendResidImfiles $options:0 state TIMEOUT
     134  end
     135end
     136
     137# select images ready for copy
     138# new entries are added to DetrendResidExposures
     139# compare the new list with the ones already selected
     140task           dettool.residexp.load
     141  host         local
     142
     143  periods      -poll $loadpoll
     144  periods      -exec $loadexec
     145  periods      -timeout 30
     146
     147  stdout $LOGSUBDIR/detresid.exp.log
     148  stderr $LOGSUBDIR/detresid.exp.log
     149
     150  task.exec
     151    command dettool -toresidexp -limit 20
     152  end
     153
     154  # success
     155  task.exit    0
     156    # convert 'stdout' to book format
     157    ipptool2book stdout DetrendResidExposures -key det_id:iter:exp_tag -uniq
     158    if ($VERBOSE > 2)
     159      book listbook DetrendResidExposures
     160    end
     161
     162    # delete existing entries which are DONE
     163    book delpage DetrendResidExposures -key state DONE
     164  end
     165
     166  # default exit status
     167  task.exit    default
     168    showcommand failure
     169  end
     170
     171  # operation times out?
     172  task.exit    timeout
     173    showcommand timeout
     174  end
     175end
     176
     177# copy new images, sending job to desired host
     178task           dettool.residexp.run
     179  periods      -poll $runpoll
     180  periods      -exec $runexec
     181  periods      -timeout 30
     182
     183  task.exec
     184    book npages DetrendResidExposures -var N
     185    if ($N == 0) break
     186    if ($network == 0) break
     187   
     188    # look for new images in DetrendResidExposures
     189    book getpage DetrendResidExposures 0 -var pageName -key state NULL
     190    if ($pageName == NULL) break
     191
     192    book setword DetrendResidExposures $pageName state RUN
     193    book getword DetrendResidExposures $pageName DET_ID   -var DET_ID 
     194    book getword DetrendResidExposures $pageName ITER     -var ITER   
     195    book getword DetrendResidExposures $pageName DET_TYPE -var DET_TYPE
     196    book getword DetrendResidExposures $pageName MODE     -var MODE   
     197    book getword DetrendResidExposures $pageName EXP_TAG  -var EXP_TAG
     198    book getword DetrendResidExposures $pageName INCLUDE  -var INCLUDE
     199    book getword DetrendResidExposures $pageName CAMERA   -var CAMERA 
     200
    149201    # specify choice of remote host:
    150202    if ($parallel)
     
    154206    end
    155207
    156     # create example job options as a demonstration
    157     options "$line"
    158     # detrend_create_resid.pl DET_ID ITER EXP_TAG CLASS_ID TYPE (URI-DET) (URL-IN) (EXP_TAG ???)
    159     # need to parse the subdir path for the detrend URL
    160     # $DET_URL = $DET_DIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.fits
    161     echo command detrend_resid.pl --det_id $DET_ID --iteration $ITER --exp_tag $EXP_TAG --class_id $CLASS_ID --det_type $DET_TYPE --detrend $DET_URI --input_uri $URI --camera $CAMERA --mode $MODE
    162     command detrend_resid.pl --det_id $DET_ID --iteration $ITER --exp_tag $EXP_TAG --class_id $CLASS_ID --det_type $DET_TYPE --detrend $DET_URI --input_uri $URI --camera $CAMERA --mode $MODE
    163   end
    164 
    165   # success
    166   task.exit 0
    167     queuepush DetrendResidImfiles -replace -key 1:2:5:6 "DONE $options:0"
    168   end
    169 
    170   # default exit status
    171   task.exit    default
    172     showcommand failure
    173     queuepush DetrendResidImfiles -replace -key 1:2:5:6 "FAIL $options:0"
    174     $DetrendResidImfileFail ++
    175   end
    176 
    177   # operation times out?
    178   task.exit    timeout
    179     showcommand timeout
    180     queuepush DetrendResidImfiles -replace -key 1:2:6:6 "TIMEOUT $options:0"
    181     $DetrendResidImfileFail ++
    182   end
    183 end
    184 
    185 # select images ready for copy
    186 # new entries are added to queue DetrendResidExposures
    187 # compare the new list with the ones already selected
    188 task           dettool.residexp.load
    189   host         local
    190 
    191   periods      -poll $loadpoll
    192   periods      -exec $loadexec
    193   periods      -timeout 30
    194 
    195   stdout $LOGSUBDIR/detresid.exp.log
    196   stderr $LOGSUBDIR/detresid.exp.log
    197 
    198   task.exec
    199     command      dettool -toresidexp -simple -limit {$DetrendResidExpFail + 20}
    200   end
    201 
    202   # success
    203   task.exit    0
    204     # XXX is it necessary for these to be local?
    205     # drop after this task macro is done?
    206     local i Nqueue
    207 
    208     # compare output with newImage queue
    209     # only add entries which don't exist in queue
    210     queuesize stdout -var Nqueue
    211     for i 0 $Nqueue
    212       queuepop stdout -var line
    213       if ($VERBOSE > 2)
    214         echo $line
    215       end
    216       list word -split $line
    217       $DET_ID   = $word:0
    218       $ITER     = $word:1
    219       $DET_TYPE = $word:2
    220       $MODE     = $word:3
    221       $EXP_TAG  = $word:4
    222       $INCLUDE  = $word:5
    223       $CAMERA   = $word:6
    224       queuepush DetrendResidExposures -uniq -key 1:2:5 "NEW $DET_ID $ITER $DET_TYPE $MODE $EXP_TAG $INCLUDE $CAMERA"
    225     end
    226 
    227     # delete existing entries which are DONE
    228     queuedrop DetrendResidExposures -key 0 DONE
    229   end
    230 
    231   # locked list
    232   # default exit status
    233   task.exit    default
    234     showcommand failure
    235   end
    236 
    237   # operation times out?
    238   task.exit    timeout
    239     showcommand timeout
    240   end
    241 end
    242 
    243 # copy new images, sending job to desired host
    244 task           dettool.residexp.run
    245   periods      -poll $runpoll
    246   periods      -exec $runexec
    247   periods      -timeout 30
    248 
    249   task.exec
    250     queuesize DetrendResidExposures -var N
    251     if ($N == 0) break
    252     if ($network == 0) break
    253    
    254     # look for new images on the internal DetrendResidExposures queue
    255     # caution with these 'if' statements: syntax errors
    256     # will make the task fail without given a good status
    257     queuepop DetrendResidExposures -var line -key 0 NEW
    258     if ("$line" == "NULL") break
    259 
    260     strpop line state
    261     queuepush DetrendResidExposures -replace -key 1:2:5 "RUN $line"
    262 
    263     ## the DetrendResidExposures queue contains:
    264     ## STATE ITER TYPE DET_ID EXP_TAG CLASS_ID URI_IN
    265     ## NOTE: the queue has the STATE prepended
    266     list word -split $line
    267     $DET_ID   = $word:0
    268     $ITER     = $word:1
    269     $DET_TYPE = $word:2
    270     $MODE     = $word:3
    271     $EXP_TAG  = $word:4
    272     $INCLUDE  = $word:5
    273     $CAMERA   = $word:6
    274 
    275208    # XXX this is still a lame rule
    276209    $word = `basename $EXP_TAG | tr '.' ' '`
    277210    list word -split $word
    278211    $base = $word:0
    279 
    280212    stdout $LOGSUBDIR/$base/$EXP_TAG.detresid.$DET_ID.$ITER.log
    281213    stderr $LOGSUBDIR/$base/$EXP_TAG.detresid.$DET_ID.$ITER.log
    282214    exec mkdir -p $LOGSUBDIR/$base
    283215
    284     # specify choice of remote host:
    285     if ($parallel)
    286       host anyhost
    287     else
    288       host local
    289     end
     216    # save the pageName for future reference below
     217    options $pageName
    290218
    291219    # create example job options as a demonstration
    292     options "$line"
    293220    if ($VERBOSE > 1)
    294221      echo command detrend_reject_imfile.pl --det_id $DET_ID --iteration $ITER --exp_tag $EXP_TAG --det_type $DET_TYPE --camera $CAMERA
     
    299226  # success
    300227  task.exit 0
    301     queuepush DetrendResidExposures -replace -key 1:2:5 "DONE $options:0"
    302   end
    303 
    304   # default exit status
    305   task.exit    default
    306     showcommand failure
    307     queuepush DetrendResidExposures -replace -key 1:2:5 "FAIL $options:0"
    308     $DetrendResidExpFail ++
    309   end
    310 
    311   # operation times out?
    312   task.exit    timeout
    313     showcommand timeout
    314     queuepush DetrendResidExposures -replace -key 1:2:5 "TIMEOUT $options:0"
    315     $DetrendResidExpFail ++
    316   end
    317 end
     228    book setword DetrendResidExposures $options:0 state DONE
     229  end
     230
     231  # default exit status
     232  task.exit    default
     233    showcommand failure
     234    book setword DetrendResidExposures $options:0 state FAIL
     235  end
     236
     237  # operation times out?
     238  task.exit    timeout
     239    showcommand timeout
     240    book setword DetrendResidExposures $options:0 state TIMEOUT
     241  end
     242end
  • branches/eam_branch_00/ippTasks/detrend.stack.pro

    r10745 r11011  
    11## this file contains the tasks for running the detrend stacking stage
    22
    3 # get a list of imfiles to stack
    4 # dettool -tostack -simple
    5 # 1 0 bias mc
    6 # DET_ID ITER TYPE CLASS_ID
    7 
    8 # function to stack the imfiles:
    9 # detrend_stack.pl 1 0 mc bias
    10 
    11 ## these tasks use the queue DetrendStackClass
    12 ## the DetrendStackClass queue contains:
    13 ## STATE DET_ID ITER TYPE CLASS_ID CAMERA
    14 
    15 queueinit DetrendStackClass
    163if ($?network == 0)
    174  $network = 1
     
    207  $parallel = 0
    218end
    22 
    23 $DetrendStackClassFail = 0
    24 
    259if ($?VERBOSE == 0)
    2610  echo "VERBOSE not defined: load pantasks.pro first"
     
    3115  break
    3216end
     17
    3318$LOGSUBDIR = $LOGDIR/detrend
    3419exec mkdir -p $LOGSUBDIR
     20
     21book init DetrendStackClass
    3522
    3623macro detstack.status
     
    3926end
    4027
    41 # select images ready for copy
    42 # new entries are added to queue DetrendStackClass
     28# select images ready for detrend_stack.pl
     29# new entries are added to DetrendStackClass
    4330# compare the new list with the ones already selected
    4431task           dettool.stack.load
     
    5340
    5441  task.exec
    55     command dettool -tostacked -simple -limit {$DetrendStackClassFail + 20}
     42    command dettool -tostacked -limit 20
    5643  end
    5744
    5845  # success
    5946  task.exit    0
    60     local i Nqueue
    61 
    62     # compare output with newImage queue
    63     # only add entries which do not exist in queue
    64     queuesize stdout -var Nqueue
    65     for i 0 $Nqueue
    66       queuepop stdout -var line
    67       if ($VERBOSE > 2)
    68         echo $line
    69       end
    70       list word -split $line
    71       $DET_ID   = $word:0
    72       $ITER     = $word:1
    73       $DET_TYPE = $word:2
    74       $CLASS_ID = $word:3
    75       $CAMERA   = $word:4
    76       queuepush DetrendStackClass -uniq -key 1:2:4 "NEW $DET_ID $ITER $DET_TYPE $CLASS_ID $CAMERA"
     47    # convert 'stdout' to book format
     48    ipptool2book stdout DetrendStackClass -key det_id:iter:class_id -uniq
     49    if ($VERBOSE > 2)
     50      book listbook DetrendStackClass
    7751    end
    7852
    7953    # delete existing entries which are DONE
    80     queuedrop DetrendStackClass -key 0 DONE
     54    book delpage DetrendStackClass -key state DONE
    8155  end
    8256
     
    9973
    10074  task.exec
    101     queuesize DetrendStackClass -var N
     75    book npages DetrendStackClass -var N
    10276    if ($N == 0) break
    10377    if ($network == 0) break
    10478   
    105     # look for new images on the internal DetrendStackClass queue
    106     # caution with these 'if' statements: syntax errors
    107     # will make the task fail without given a good status
    108     queuepop DetrendStackClass -var line -key 0 NEW
    109     if ("$line" == "NULL") break
     79    # look for new images in DetrendStackClass
     80    book getpage DetrendStackClass 0 -var pageName -key state NULL
     81    if ($pageName == NULL) break
    11082
    111     strpop line state
    112     queuepush DetrendStackClass -replace -key 1:2:4 "RUN $line"
    113 
    114     # the DetrendStackClass queue contains:
    115     # STATE DET_ID ITER TYPE CLASS_ID
    116     ## NOTE: the queue has the STATE prepended
    117     # use local variables
    118     list word -split $line
    119     $DET_ID   = $word:0
    120     $ITER     = $word:1
    121     $DET_TYPE = $word:2
    122     $CLASS_ID = $word:3
    123     $CAMERA   = $word:4
    124 
    125     # XXX add $WORKDIR/$LOG_DIR
    126     stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
    127     stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
     83    book setword DetrendStackClass $pageName state RUN
     84    book getword DetrendStackClass $pageName det_id   -var DET_ID
     85    book getword DetrendStackClass $pageName iter     -var ITER
     86    book getword DetrendStackClass $pageName det_type -var DET_TYPE
     87    book getword DetrendStackClass $pageName class_id -var CLASS_ID
     88    book getword DetrendStackClass $pageName camera   -var CAMERA 
    12889
    12990    # specify choice of remote host:
     
    13495    end
    13596
    136     # create example job options as a demonstration
    137     options "$line"
     97    # XXX add $WORKDIR/$LOG_DIR
     98    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
     99    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.$CLASS_ID.log
     100
     101    # save the pageName for future reference below
     102    options $pageName
     103
     104    # create the command line
    138105    if ($VERBOSE > 1)
    139106      echo command detrend_stack.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --det_type $DET_TYPE --camera $CAMERA
     
    144111  # success
    145112  task.exit 0
    146     queuepush DetrendStackClass -replace -key 1:2:4 "DONE $options:0"
     113    book setword DetrendStackClass $options:0 state DONE
    147114  end
    148115
     
    150117  task.exit    default
    151118    showcommand failure
    152    queuepush DetrendStackClass -replace -key 1:2:4 "FAIL $options:0"
    153    $DetrendStackClassFail ++
     119    book setword DetrendStackClass $options:0 state FAIL
    154120  end
    155121
     
    157123  task.exit    timeout
    158124    showcommand timeout
    159     queuepush DetrendStackClass -replace -key 1:2:4 "TIMEOUT $options:0"
    160     $DetrendStackClassFail ++
     125    book setword DetrendStackClass $options:0 state TIMEOUT
    161126  end
    162127end
  • branches/eam_branch_00/ippTasks/pantasks.pro

    r10760 r11011  
    8080  end
    8181end
     82
     83macro setcommand
     84  local n
     85  $command = ""
     86  for n 1 $0
     87    $command = $command $$n
     88  end
     89  if ($VERBOSE > 1)
     90    echo "command $command"
     91  end
     92  command $command
     93end
  • branches/eam_branch_00/ippTasks/phase0.pro

    r10746 r11011  
    11## this file contains the tasks for running the phase 0 stage
    2 
    3 ## these tasks use the queue Phase0Imfiles
    4 ## the Phase0Imfiles queue contains:
    5 ## STATE EXP_TAG CLASS CLASS_ID URI-FITS
    6 ## queue keys are counted from 0
    7 
    8 queueinit Phase0Imfiles
    9 queueinit Phase0Exposures
     2## these tasks use the books Phase0Imfiles and Phase0Exposures
     3
    104if ($?network == 0)
    115  $network = 1
     
    148  $parallel = 0
    159end
    16 
    17 $Phase0ImfileFail = 0
    18 $Phase0ExpFail = 0
    19 
    2010if ($?VERBOSE == 0)
    2111  echo "VERBOSE not defined: load pantasks.pro first"
     
    2616  break
    2717end
     18
    2819$LOGSUBDIR = $LOGDIR/phase0
    2920exec mkdir -p $LOGSUBDIR
    3021
     22book init Phase0Imfiles
     23book init Phase0Exposures
     24
    3125macro phase0.status
    32   queueprint Phase0Imfiles
    33   queueprint Phase0Exposures
    34   echo "Phase0ImfileFail: $Phase0ImfileFail"
    35   echo "Phase0ExpFail: $Phase0ExpFail"
     26  book listbook Phase0Imfiles
     27  book listbook Phase0Exposures
    3628end
    3729
     
    5042
    5143  task.exec
    52     command p0tool -pendingimfile -simple -limit {$Phase0ImfileFail + 20}
     44    command p0tool -pendingimfile -limit 20
    5345  end
    5446
    5547  # success
    5648  task.exit    0
    57     local i Nqueue
    58 
    59     # compare output with Phase0Imfiles queue
    60     # only add entries which don't exist in queue
    61     queuesize stdout -var Nqueue
    62     for i 0 $Nqueue
    63       queuepop stdout -var line
    64       if ($VERBOSE > 2)
    65         echo $line
    66       end
    67       list word -split $line
    68       $EXP_TAG  = $word:0
    69       $CLASS    = $word:1
    70       $CLASS_ID = $word:2
    71       $URI      = $word:3
    72       queuepush Phase0Imfiles -uniq -key 1 "NEW $EXP_TAG $CLASS $CLASS_ID $URI"
     49    # convert 'stdout' to book format
     50    ipptool2book stdout Phase0Imfiles -key exp_tag -uniq
     51    if ($VERBOSE > 2)
     52      book listbook Phase0Imfiles
    7353    end
    7454
    7555    # delete existing entries which are DONE
    76     queuedrop Phase0Imfiles -key 0 DONE
     56    book delpage Phase0Imfiles -key state DONE
    7757  end
    7858
     
    8868end
    8969
    90 
    91 
    92 # run the phase0imfile script on pending images
     70# run the phase0_imfile.pl script on pending images
    9371task           phase0.imfile.run
    9472  periods      -poll $runpoll
     
    9775
    9876  task.exec
    99     queuesize Phase0Imfiles -var N
     77    book npages Phase0Imfiles -var N
    10078    if ($N == 0) break
    10179    if ($network == 0) break
    10280   
    103     # look for new images on the internal DetrendImfilesToProcess queue
    104     # caution with these 'if' statements: syntax errors
    105     # will make the task fail without given a good status
    106     queuepop Phase0Imfiles -var line -key 0 NEW
    107     if ("$line" == "NULL") break
    108 
    109     strpop line state
    110     queuepush Phase0Imfiles -replace -key 1 "RUN $line"
    111 
    112     ## the Phase0Imfiles queue contains (line has popped STATE)
    113     ## STATE EXP_TAG CLASS CLASS_ID URI-FITS
    114     list word -split $line
    115     $EXP_TAG  = $word:0
    116     $CLASS    = $word:1
    117     $CLASS_ID = $word:2
    118     $URI      = $word:3
    119 
    120     # specify choice of remote host:(need to choose based on chips)
     81    # look for new images in Phase0Imfiles
     82    book getpage Phase0Imfiles 0 -var pageName -key state NULL
     83    if ($pageName == NULL) break
     84
     85    book setword Phase0Imfiles $pageName state RUN
     86    book getword Phase0Imfiles $pageName exp_tag -var EXP_TAG
     87    book getword Phase0Imfiles $pageName class -var CLASS
     88    book getword Phase0Imfiles $pageName class_id -var CLASS_ID
     89    book getword Phase0Imfiles $pageName uri -var URI
     90
     91    # specify choice of remote host
    12192    if ($parallel)
    12293      host anyhost
     
    133104    exec mkdir -p $LOGSUBDIR/$base
    134105
     106    # save the pageName for future reference below
     107    options $pageName
     108
    135109    # create the command line
    136     options "$line"
    137110    if ($VERBOSE > 1)
    138111      echo command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
     
    143116  # success
    144117  task.exit 0
    145     # phase0imfile.pl updates DB tables, here we just update the queue
    146     queuepush Phase0Imfiles -replace -key 1 "DONE $options:0"
     118    # phase0_imfile.pl updates DB tables, here we just update the queue
     119    book setword Phase0Imfiles $options:0 state DONE
    147120  end
    148121
     
    150123  task.exit    default
    151124    showcommand failure
    152     queuepush Phase0Imfiles -replace -key 1 "FAIL $options:0"
    153     $Phase0ImfileFail ++
     125    book setword Phase0Imfiles $options:0 state FAIL
    154126  end
    155127
     
    157129  task.exit    timeout
    158130    showcommand timeout
    159     queuepush Phase0Imfiles -replace -key 1 "TIMEOUT $options:0"
    160     $Phase0ImfileFail ++
    161   end
    162 end
    163 
    164 
    165 
    166 ## these tasks use the queue Phase0Exposures
    167 ## the Phase0Exposures queue contains:
    168 ## STATE EXP_TAG CAMERA TELESCOPE TYPE NCLASS
    169 
    170 # select images ready for phase0 analysis
    171 # new entries are added to queue Phase0Exposures
    172 # compare the new list with the ones already selected
     131    book setword Phase0Imfiles $options:0 state TIMEOUT
     132  end
     133end
     134
     135# select exposures ready for phase0_exp.pl
    173136task           phase0.exp.load
    174137  host         local
     
    182145
    183146  task.exec
    184     command p0tool -pendingexp -simple -limit {$Phase0ExpFail + 20}
     147    command p0tool -pendingexp -limit 20
    185148  end
    186149
    187150  # success
    188151  task.exit    0
    189     local i Nqueue
    190 
    191     # compare output with Phase0Exposures queue
    192     # only add entries which don't exist in queue
    193     queuesize stdout -var Nqueue
    194     for i 0 $Nqueue
    195       queuepop stdout -var line
    196       if ($VERBOSE > 2)
    197         echo $line
    198       end
    199       list word -split $line
    200       $EXP_TAG   = $word:0
    201       # $EXP_ID    = $word:1
    202       # $CAMERA    = $word:2
    203       # $TELESCOPE = $word:3
    204       # $DATEOBS   = $word:4
    205       # $TYPE      = $word:5
    206       # $IMFILES   = $word:6
    207       queuepush Phase0Exposures -uniq -key 1 "NEW $EXP_TAG"
     152    # convert 'stdout' to book format
     153    ipptool2book stdout Phase0Exposures -key exp_tag -uniq
     154    if ($VERBOSE > 2)
     155      book listbook Phase0Exposures
    208156    end
    209157
    210158    # delete existing entries which are DONE
    211     queuedrop Phase0Exposures -key 0 DONE
     159    book delpage Phase0Exposures -key state DONE
    212160  end
    213161
    214162  # default exit status
    215163  task.exit    default
    216     showcommand
    217   end
    218 
    219   # operation times out?
    220   task.exit    timeout
    221     showcommand
    222   end
    223 end
    224 
    225 
    226 
    227 # run the phase0imfile script on pending images
     164    showcommand failure
     165  end
     166
     167  # operation times out?
     168  task.exit    timeout
     169    showcommand timeout
     170  end
     171end
     172
     173# run the phase0_exp.pl script on pending exposures
    228174task           phase0.exp.run
    229175  periods      -poll $runpoll
     
    232178
    233179  task.exec
    234     queuesize Phase0Exposures -var N
     180    book npages Phase0Exposures -var N
    235181    if ($N == 0) break
    236182    if ($network == 0) break
    237183   
    238     # look for new images on the internal DetrendImfilesToProcess queue
    239     # caution with these 'if' statements: syntax errors
    240     # will make the task fail without given a good status
    241     queuepop Phase0Exposures -var line -key 0 NEW
    242     if ("$line" == "NULL") break
    243 
    244     strpop line state
    245     queuepush Phase0Exposures -replace -key 1 "RUN $line"
    246 
    247     ## the Phase0Exposures queue contains:
    248     ## STATE EXP_TAG CAMERA TELESCOPE TYPE NCLASS
    249     list word -split $line
    250     $EXP_TAG   = $word:0
     184    # look for new images in Phase0Exposures (state == NULL)
     185    book getpage Phase0Exposures 0 -var pageName -key state NULL
     186    if ($pageName == NULL) break
     187
     188    book setword Phase0Exposures $pageName state RUN
     189    book getword Phase0Exposures $pageName exp_tag -var EXP_TAG
     190
     191    # specify choice of remote host:(need to choose based on chips)
     192    if ($parallel)
     193      host anyhost
     194    else
     195      host local
     196    end
    251197
    252198    # XXX this is still a lame rule
     
    258204    exec mkdir -p $LOGSUBDIR/$base
    259205
    260     # specify choice of remote host:(need to choose based on chips)
    261     if ($parallel)
    262       host anyhost
    263     else
    264       host local
    265     end
     206    # save the pageName for future reference below
     207    options $pageName
    266208
    267209    # create the command line
    268     options "$line"
    269210    if ($VERBOSE > 1)
    270211      echo command phase0_exp.pl --exp_tag $EXP_TAG
     
    276217  task.exit 0
    277218    # phase0exp.pl updates DB tables, here we just update the queue
    278     queuepush Phase0Exposures -replace -key 1 "DONE $options:0"
     219    book setword Phase0Exposures $options:0 state DONE
    279220  end
    280221
     
    282223  task.exit    default
    283224    showcommand
    284     queuepush Phase0Exposures -replace -key 1 "FAIL $options:0"
    285     $Phase0ExpFail
     225    book setword Phase0Exposures $options:0 state FAIL
    286226  end
    287227
     
    289229  task.exit    timeout
    290230    showcommand
    291     queuepush Phase0Exposures -replace -key 1 "TIMEOUT $options:0"
    292     $Phase0ExpFail
     231    book setword Phase0Exposures $options:0 state TIMEOUT
    293232  end
    294233end
  • branches/eam_branch_00/ippTasks/phase2.pro

    r11008 r11011  
    11## this file contains the tasks for running the phase 0 stage
     2## these tasks use the book p2PendingImfile
    23
    3 ## these tasks use the queue Phase2Imfiles
    4 ## the Phase2Imfiles queue contains:
    5 ## STATE EXP_TAG CLASS CLASS_ID URI-FITS
    6 ## queue keys are counted from 0
    7 
    8 # XXX change book names to match ippTool values?
    9 # XXX replace with book init p2pending
    10 queueinit Phase2Imfiles
    114if ($?network == 0)
    125  $network = 1
     
    158  $parallel = 0
    169end
    17 
    18 $Phase2ImfileFail = 0
    19 
    2010if ($?VERBOSE == 0)
    2111  echo "VERBOSE not defined: load pantasks.pro first"
     
    2616  break
    2717end
     18
    2819$LOGSUBDIR = $LOGDIR/phase2
    2920exec mkdir -p $LOGSUBDIR
    3021
     22book init p2PendingImfile
     23
    3124macro phase2.status
    32   book listbook p2pending
    33   echo "Phase2ImfileFail: $Phase2ImfileFail"
     25  book listbook p2PendingImfile
    3426end
    3527
    3628# select images ready for phase2 analysis
    37 # new entries are added to queue Phase2Imfiles
    38 # compare the new list with the ones already selected
     29# new entries are added to p2PendingImfile
     30# skip already-present entries
    3931task           phase2.imfile.load
    4032  host         local
     
    4840
    4941  task.exec
    50     # command p2tool -pendingimfile -simple -limit {$Phase2ImfileFail + 20}
    51     # XXX make sure we remove FAIL and TIMEOUT entries
    5242    command p2tool -pendingimfile -limit 20
    5343  end
     
    5545  # success
    5646  task.exit    0
    57     # stdout from the task is stored on queue 'stdout'
    5847    # convert 'stdout' to book format
    59     # only add entries which don't exist in the book
    60     # 'state' has value of NULL
    61     ipptool2book stdout p2pending -key exp_tag:class_id -uniq
     48    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq
    6249    if ($VERBOSE > 2)
    63       book listbook p2pending
     50      book listbook p2PendingImfile
    6451    end
    6552
    6653    # delete existing entries which are DONE
    67     book delpage p2pending -key state DONE
     54    book delpage p2PendingImfile -key state DONE
    6855  end
    6956
     
    7966end
    8067
    81 # run the phase2imfile script on pending images
     68# run the phase2.pl script on pending images
    8269task           phase2.imfile.run
    8370  periods      -poll $runpoll
     
    8673
    8774  task.exec
    88     book npages p2pending -var N
     75    book npages p2PendingImfile -var N
    8976    if ($N == 0) break
    9077    if ($network == 0) break
    9178   
    92     # look for new images on the internal p2pending book
    93     # caution with these 'if' statements: syntax errors
    94     # will make the task fail without given a good status
    95     book getpage p2pending 0 -var pageName -key state NULL
    96     book setword p2pending $pageName state RUN
     79    # look for new images in p2PendingImfile (state == NULL)
     80    book getpage p2PendingImfile 0 -var pageName -key state NULL
     81    if ($pageName == NULL) break
    9782
    98     book getword p2pending $pageName camera -var CAMERA
    99     book getword p2pending $pageName exp_tag -var EXP_TAG
    100     book getword p2pending $pageName class_id -var CLASS_ID
    101     book getword p2pending $pageName uri -var URI
     83    book setword p2PendingImfile $pageName state RUN
     84    book getword p2PendingImfile $pageName camera -var CAMERA
     85    book getword p2PendingImfile $pageName exp_tag -var EXP_TAG
     86    book getword p2PendingImfile $pageName class_id -var CLASS_ID
     87    book getword p2PendingImfile $pageName uri -var URI
    10288
    103     # specify choice of remote host:(need to choose based on chips)
     89    # specify choice of remote host
     90    # XXX need to choose based on chips
    10491    if ($parallel)
    10592      host anyhost
     
    118105    exec mkdir -p $LOGSUBDIR/$base
    119106
    120     # save the p2pending book pageName for future reference below
     107    # save the pageName for future reference below
    121108    options $pageName
    122109
     
    130117  # success
    131118  task.exit 0
    132     # phase2imfile.pl updates DB tables, here we just update the queue
    133     book setword p2pending $options:0 state DONE
    134     # queuepush Phase2Imfiles -replace -key 1:2 "DONE $options:0"
     119    # phase2.pl updates DB tables, here we just update the queue
     120    book setword p2PendingImfile $options:0 state DONE
    135121  end
    136122
     
    138124  task.exit    default
    139125    showcommand failure
    140     book setword p2pending $options:0 state FAIL
    141     # queuepush Phase2Imfiles -replace -key 1:2 "FAIL $options:0"
    142     # drop failed entries from the book lists?
    143     $Phase2ImfileFail ++
     126    book setword p2PendingImfile $options:0 state FAIL
    144127  end
    145128
    146   # operation times out?
     129  # operation timed out?
    147130  task.exit    timeout
    148131    showcommand timeout
    149     book setword p2pending $options:0 state TIMEOUT
    150     # queuepush Phase2Imfiles -replace -key 1:2 "TIMEOUT $options:0"
    151     $Phase2ImfileFail ++
     132    book setword p2PendingImfile $options:0 state TIMEOUT
    152133  end
    153134end
  • branches/eam_branch_00/ippTasks/phase3.pro

    r10758 r11011  
    1 ## this file contains the tasks for running the phase 0 stage
     1## this file contains the tasks for running the phase 3 stage
     2## these tasks use the book Phase3Exposures
    23
    3 ## these tasks use the queue Phase3Exposures
    4 ## the Phase3Exposures queue contains:
    5 ## STATE EXP_TAG CLASS CLASS_ID URI-FITS
    6 ## queue keys are counted from 0
    7 
    8 queueinit Phase3Exposures
    94if ($?network == 0)
    105  $network = 1
     
    138  $parallel = 0
    149end
    15 
    16 $Phase3ExposureFail = 0
    17 
    1810if ($?VERBOSE == 0)
    1911  echo "VERBOSE not defined: load pantasks.pro first"
     
    2416  break
    2517end
     18
    2619$LOGSUBDIR = $LOGDIR/phase3
    2720exec mkdir -p $LOGSUBDIR
    2821
     22book init Phase3Exposures
     23
    2924macro phase3.status
    30   queueprint Phase3Exposures
    31   echo "Phase3ExposureFail: $Phase3ExposureFail"
     25  book listbook Phase3Exposures
    3226end
    3327
    3428# select images ready for phase3 analysis
    35 # new entries are added to queue Phase3Exposures
    36 # compare the new list with the ones already selected
     29# new entries are added to Phase3Exposures
     30# skip already-present entries
    3731task           phase3.exp.load
    3832  host         local
     
    4640
    4741  task.exec
    48     command      p3tool -pendingexp -simple
     42    command p3tool -pendingexp -limit 20
    4943  end
    5044
    5145  # success
    5246  task.exit    0
    53     local i Nqueue
    54 
    55     # compare output with Phase3Exposures queue
    56     # only add entries which don't exist in queue
    57     queuesize stdout -var Nqueue
    58     for i 0 $Nqueue
    59       queuepop stdout -var line
    60       if ($VERBOSE > 2)
    61         echo $line
    62       end
    63       list word -split $line
    64       $EXP_TAG   = $word:0
    65       queuepush Phase3Exposures -uniq -key 1 "NEW $EXP_TAG"
     47    # convert 'stdout' to book format
     48    ipptool2book stdout Phase3Exposures -key exp_tag -uniq
     49    if ($VERBOSE > 2)
     50      book listbook Phase3Exposures
    6651    end
    6752
    6853    # delete existing entries which are DONE
    69     queuedrop Phase3Exposures -key 0 DONE
     54    book delpage Phase3Exposures -key state DONE
    7055  end
    7156
     
    8873
    8974  task.exec
    90     queuesize Phase3Exposures -var N
     75    book npages Phase3Exposures -var N
    9176    if ($N == 0) break
    9277    if ($network == 0) break
    9378   
    94     # look for new images on the internal DetrendExposuresToProcess queue
    95     # caution with these 'if' statements: syntax errors
    96     # will make the task fail without given a good status
    97     queuepop Phase3Exposures -var line -key 0 NEW
    98     if ("$line" == "NULL") break
     79    # look for new images in Phase3Exposures (state == NULL)
     80    book getpage Phase3Exposures 0 -var pageName -key state NULL
     81    if ($pageName == NULL) break
    9982
    100     strpop line state
    101     queuepush Phase3Exposures -replace -key 1 "RUN $line"
     83    book setword Phase3Exposures $pageName state RUN
     84    book getword Phase3Exposures $pageName camera -var CAMERA
     85    book getword Phase3Exposures $pageName exp_tag -var EXP_TAG
    10286
    103     ## the Phase3Exposures queue contains:
    104     ## STATE EXP_TAG CAMERA TELESCOPE TYPE NCLASS
    105     list word -split $line
    106     $EXP_TAG   = $word:0
     87    # specify choice of remote host:(need to choose based on chips)
     88    if ($parallel)
     89      host anyhost
     90    else
     91      host local
     92    end
    10793
    10894    # XXX this is still a lame rule
     
    114100    exec mkdir -p $LOGSUBDIR/$base
    115101
    116     # specify choice of remote host:(need to choose based on chips)
    117     if ($parallel)
    118       host anyhost
    119     else
    120       host local
    121     end
     102    # save the pageName for future reference below
     103    options $pageName
    122104
    123105    # create the command line
    124     options "$line"
    125106    if ($VERBOSE > 1)
    126107      echo command phase3.pl --exp_tag $EXP_TAG
    127108    end
    128     command phase3.pl --exp_tag $EXP_TAG --camera CTIO_MOSAIC2
     109    command phase3.pl --exp_tag $EXP_TAG --camera $CAMERA
    129110  end
    130111
     
    132113  task.exit 0
    133114    # phase3exp.pl updates DB tables, here we just update the queue
    134     queuepush Phase3Exposures -replace -key 1 "DONE $options:0"
     115    book setword Phase3Exposures $options:0 state DONE
    135116  end
    136117
     
    138119  task.exit    default
    139120    showcommand failure
    140     queuepush Phase3Exposures -replace -key 1 "FAIL $options:0"
    141     $Phase3ExposureFail ++
     121    book setword Phase3Exposures $options:0 state FAIL
    142122  end
    143123
     
    145125  task.exit    timeout
    146126    showcommand timeout
    147     queuepush Phase3Exposures -replace -key 1 "TIMEOUT $options:0"
    148     $Phase3ExposureFail ++
     127    book setword Phase3Exposures $options:0 state TIMEOUT
    149128  end
    150129end
Note: See TracChangeset for help on using the changeset viewer.