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