IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17532 for trunk/ippTasks


Ignore:
Timestamp:
May 5, 2008, 2:32:06 PM (18 years ago)
Author:
eugene
Message:

adding cleanup.load and cleanup.run tasks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTasks/chip.pro

    r16531 r17532  
    1010
    1111book init chipPendingImfile
     12book init chipPendingCleanup
    1213
    1314macro chip.status
    1415  book listbook chipPendingImfile
     16  book listbook chipPendingCleanup
    1517end
    1618
    1719macro chip.reset
    1820  book init chipPendingImfile
     21  book init chipPendingCleanup
    1922end
    2023
     
    2629    active true
    2730  end
     31  task chip.cleanup.load
     32    active true
     33  end
     34  task chip.cleanup.run
     35    active true
     36  end
    2837end
    2938
     
    3342  end
    3443  task chip.imfile.run
     44    active false
     45  end
     46  task chip.cleanup.load
     47    active false
     48  end
     49  task chip.cleanup.run
    3550    active false
    3651  end
     
    169184  end
    170185end
     186
     187# this variable will cycle through the known database names
     188$chip_cleanup_DB = 0
     189
     190# select images ready for chip analysis
     191# new entries are added to chipPendingImfile
     192# skip already-present entries
     193task           chip.cleanup.load
     194  host         local
     195
     196  periods      -poll $LOADPOLL
     197  periods      -exec $LOADEXEC
     198  periods      -timeout 30
     199  npending     1
     200  active       false
     201
     202  stdout NULL
     203  stderr $LOGSUBDIR/chip.cleanup.log
     204
     205  task.exec
     206    if ($DB:n == 0)
     207      option DEFAULT
     208      command chiptool -pendingcleanup -limit 20
     209    else
     210      # save the DB name for the exit tasks
     211      option $DB:$chip_cleanup_DB
     212      command chiptool -pendingcleanup -limit 20 -dbname $DB:$chip_cleanup_DB
     213      $chip_cleanup_DB ++
     214      if ($chip_cleanup_DB >= $DB:n) set chip_cleanup_DB = 0
     215    end
     216  end
     217
     218  # success
     219  task.exit    0
     220    # convert 'stdout' to book format
     221    ipptool2book stdout chipPendingCleanup -key chip_id:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     222    if ($VERBOSE > 2)
     223      book listbook chipPendingCleanup
     224    end
     225
     226    # delete existing entries in the appropriate pantaskStates
     227    process_cleanup chipPendingCleanup
     228  end
     229
     230  # locked list
     231  task.exit    default
     232    showcommand failure
     233  end
     234
     235  # operation times out?
     236  task.exit    timeout
     237    showcommand timeout
     238  end
     239end
     240
     241# run the chip_imfile.pl script on pending images
     242task           chip.cleanup.run
     243  periods      -poll $RUNPOLL
     244  periods      -exec $RUNEXEC
     245  periods      -timeout 60
     246  active       false
     247
     248  task.exec
     249    book npages chipPendingCleanup -var N
     250    if ($N == 0) break
     251    if ($NETWORK == 0) break
     252   
     253    # look for new images in chipPendingCleanup (pantaskState == INIT)
     254    book getpage chipPendingCleanup 0 -var pageName -key pantaskState INIT
     255    if ("$pageName" == "NULL") break
     256
     257    book setword chipPendingCleanup $pageName pantaskState RUN
     258    book getword chipPendingCleanup $pageName camera -var CAMERA
     259    book getword chipPendingCleanup $pageName exp_id -var EXP_ID
     260    book getword chipPendingCleanup $pageName exp_tag -var EXP_TAG
     261    book getword chipPendingCleanup $pageName chip_id -var CHIP_ID
     262    book getword chipPendingCleanup $pageName workdir -var WORKDIR_TEMPLATE
     263    book getword chipPendingCleanup $pageName class_id -var CLASS_ID
     264    book getword chipPendingCleanup $pageName uri -var URI
     265    book getword chipPendingCleanup $pageName dbname -var DBNAME
     266    book getword chipPendingCleanup $pageName reduction -var REDUCTION
     267
     268    # specify choice of local or remote host based on camera and chip (class_id)
     269    set.host.for.camera $CAMERA $CLASS_ID
     270
     271    # raw workdir examples:
     272    # file://data/@HOST@.0/gpc1/20080130
     273    # neb:///@HOST@-vol0/gpc1/20080130 (need to supply volname?, or are we re-defining this each time?)
     274    set.workdir.by.camera $CAMERA $CLASS_ID $WORKDIR_TEMPLATE $default_host WORKDIR
     275    # out workdir examples:
     276    # file://data/ipp004.0/gpc1/20080130
     277    # neb:///ipp004-vol0/gpc1/20080130
     278
     279    ## generate outroot specific to this exposure (& chip)
     280    # XXX probably do not need to build the outroot
     281    sprintf outroot "%s/%s/%s.ch.%s" $WORKDIR $EXP_TAG $EXP_TAG $CHIP_ID
     282
     283    ## generate output log based on filerule (convert the URI to a PATH)
     284    $logfile = `ipp_filename.pl --filerule LOG.IMFILE --camera $CAMERA --class_id $CLASS_ID --basename $outroot`
     285    if ("$logfile" == "")
     286      echo "WARNING: logfile not defined in chip.pro:152"
     287      break
     288    end
     289
     290    stdout $logfile
     291    stderr $logfile
     292    dirname $logfile -var outpath
     293    mkdir $outpath
     294
     295    # XXX is everything listed here needed?
     296    $run = chip_cleanup.pl --exp_id $EXP_ID --chip_id $CHIP_ID --class_id $CLASS_ID --exp_tag $EXP_TAG --uri $URI --camera $CAMERA --outroot $outroot
     297    if ("$REDUCTION" != "NULL")
     298      $run = $run --reduction $REDUCTION
     299    end
     300    add_standard_args run
     301
     302    # save the pageName for future reference below
     303    options $pageName
     304
     305    # create the command line
     306    if ($VERBOSE > 1)
     307      echo command $run
     308    end
     309    command $run
     310  end
     311
     312  # default exit status
     313  task.exit    default
     314    process_exit chipPendingCleanup $options:0 $JOB_STATUS
     315  end
     316
     317  # operation timed out?
     318  task.exit    timeout
     319    showcommand timeout
     320    book setword chipPendingCleanup $options:0 pantaskState TIMEOUT
     321  end
     322end
Note: See TracChangeset for help on using the changeset viewer.