IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

first pass on convering queues to books

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.