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