IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29736


Ignore:
Timestamp:
Nov 10, 2010, 9:56:24 AM (15 years ago)
Author:
bills
Message:

from trunk cleanup for background stages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20101029/ippTasks/science.cleanup.pro

    r29431 r29736  
    88    diff.cleanup.on
    99    stack.cleanup.on
     10    chip.bg.cleanup.on
     11    warp.bg.cleanup.on
    1012end
    1113
     
    934936
    935937
     938book init chipBGPendingCleanup
     939
     940macro chip.bg.cleanup.status
     941  book listbook chipBGPendingCleanup
     942end
     943
     944macro chip.bg.cleanup.reset
     945  book init chipBGPendingCleanup
     946end
     947
     948macro chip.bg.cleanup.on
     949  task chip.bg.cleanup.load
     950    active true
     951  end
     952  task chip.bg.cleanup.run
     953    active true
     954  end
     955end
     956
     957macro chip.bg.cleanup.off
     958  task chip.bg.cleanup.load
     959    active false
     960  end
     961  task chip.bg.cleanup.run
     962    active false
     963  end
     964end
     965
     966# this variable will cycle through the known database names
     967$chip_bg_cleanup_DB = 0
     968
     969task           chip.bg.cleanup.load
     970  host         local
     971
     972  periods      -poll $LOADPOLL
     973  periods      -exec $LOADEXEC
     974  periods      -timeout 30
     975  npending     1
     976  active       false
     977
     978  stdout NULL
     979  stderr $LOGDIR/chip.bg.cleanup.log
     980
     981  task.exec
     982    if ($LABEL:n == 0) break
     983    $run = bgtool -pendingcleanupchiprun
     984    if ($DB:n == 0)
     985      option DEFAULT
     986    else
     987      # save the DB name for the exit tasks
     988      option $DB:$chip_bg_cleanup_DB
     989      $run = $run -dbname $DB:$chip_bg_cleanup_DB
     990      $chip_bg_cleanup_DB ++
     991      if ($chip_bg_cleanup_DB >= $DB:n) set chip_bg_cleanup_DB = 0
     992    end
     993    add_poll_args run
     994    add_poll_labels run
     995    command $run
     996  end
     997
     998  # success
     999  task.exit    0
     1000    # convert 'stdout' to book format
     1001    ipptool2book stdout chipBGPendingCleanup -key chip_bg_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     1002    if ($VERBOSE > 2)
     1003      book listbook chipBGPendingCleanup
     1004    end
     1005
     1006    # delete existing entries in the appropriate pantaskStates
     1007    process_cleanup chipBGPendingCleanup
     1008  end
     1009
     1010  # locked list
     1011  task.exit    default
     1012    showcommand failure
     1013  end
     1014
     1015  task.exit    crash
     1016    showcommand crash
     1017  end
     1018
     1019  # operation times out?
     1020  task.exit    timeout
     1021    showcommand timeout
     1022  end
     1023end
     1024
     1025# run the ipp_cleanup.pl script on pending images
     1026task           chip.bg.cleanup.run
     1027  periods      -poll $RUNPOLL
     1028  periods      -exec $RUNEXEC
     1029  periods      -timeout 300
     1030  active       false
     1031
     1032  task.exec
     1033    book npages chipBGPendingCleanup -var N
     1034    if ($N == 0)
     1035        periods -exec $RUNEXEC
     1036        break
     1037    end
     1038    if ($NETWORK == 0) break
     1039   
     1040    # look for new images in chipBGPendingCleanup (pantaskState == INIT)
     1041    book getpage chipBGPendingCleanup 0 -var pageName -key pantaskState INIT
     1042    if ("$pageName" == "NULL") break
     1043
     1044    book setword chipBGPendingCleanup $pageName pantaskState RUN
     1045    book getword chipBGPendingCleanup $pageName camera -var CAMERA
     1046    book getword chipBGPendingCleanup $pageName state -var CLEANUP_MODE
     1047    book getword chipBGPendingCleanup $pageName chip_bg_id -var CHIP_BG_ID
     1048    book getword chipBGPendingCleanup $pageName workdir -var WORKDIR_TEMPLATE
     1049    book getword chipBGPendingCleanup $pageName exp_tag -var EXP_TAG
     1050    book getword chipBGPendingCleanup $pageName dbname -var DBNAME
     1051
     1052    # specify choice of local or remote host based on camera and chip (class_id)
     1053    set.host.for.camera $CAMERA FPA
     1054    set.workdir.by.camera $CAMERA FPA $WORKDIR_TEMPLATE $default_host WORKDIR
     1055    sprintf logfile "%s/%s/%s.bgc.%s.cleanup.log" $WORKDIR $EXP_TAG $EXP_TAG $CHIP_BG_ID
     1056
     1057    stdout $LOGDIR/chip.bg.cleanup.log
     1058    stderr $LOGDIR/chip.bg.cleanup.log
     1059
     1060    # XXX is everything listed here needed?
     1061    $run = ipp_cleanup.pl --stage chip_bg --stage_id $CHIP_BG_ID --camera $CAMERA --mode $CLEANUP_MODE --logfile $logfile
     1062    add_standard_args run
     1063
     1064    # save the pageName for future reference below
     1065    options $pageName
     1066
     1067    # create the command line
     1068    if ($VERBOSE > 1)
     1069      echo command $run
     1070    end
     1071    periods -exec 0.05
     1072    command $run
     1073  end
     1074
     1075  # default exit status
     1076  task.exit    default
     1077    process_exit chipBGPendingCleanup $options:0 $JOB_STATUS
     1078  end
     1079
     1080  task.exit    crash
     1081    showcommand crash
     1082    book setword chipBGPendingCleanup $options:0 pantaskState CRASH
     1083  end
     1084
     1085  # operation timed out?
     1086  task.exit    timeout
     1087    showcommand timeout
     1088    book setword chipBGPendingCleanup $options:0 pantaskState TIMEOUT
     1089  end
     1090end
     1091
     1092book init warpBGPendingCleanup
     1093
     1094macro warp.bg.cleanup.status
     1095  book listbook warpBGPendingCleanup
     1096end
     1097
     1098macro warp.bg.cleanup.reset
     1099  book init warpBGPendingCleanup
     1100end
     1101
     1102macro warp.bg.cleanup.on
     1103  task warp.bg.cleanup.load
     1104    active true
     1105  end
     1106  task warp.bg.cleanup.run
     1107    active true
     1108  end
     1109end
     1110
     1111macro warp.bg.cleanup.off
     1112  task warp.bg.cleanup.load
     1113    active false
     1114  end
     1115  task warp.bg.cleanup.run
     1116    active false
     1117  end
     1118end
     1119
     1120# this variable will cycle through the known database names
     1121$warp_bg_cleanup_DB = 0
     1122
     1123task           warp.bg.cleanup.load
     1124  host         local
     1125
     1126  periods      -poll $LOADPOLL
     1127  periods      -exec $LOADEXEC
     1128  periods      -timeout 300
     1129  npending     1
     1130  active       false
     1131
     1132  stdout NULL
     1133  stderr $LOGDIR/warp.bg.cleanup.log
     1134
     1135  task.exec
     1136    if ($LABEL:n == 0) break
     1137    $run = bgtool -pendingcleanupwarprun
     1138    if ($DB:n == 0)
     1139      option DEFAULT
     1140    else
     1141      # save the DB name for the exit tasks
     1142      option $DB:$warp_bg_cleanup_DB
     1143      $run = $run -dbname $DB:$warp_bg_cleanup_DB
     1144      $warp_bg_cleanup_DB ++
     1145      if ($warp_bg_cleanup_DB >= $DB:n) set warp_bg_cleanup_DB = 0
     1146    end
     1147    add_poll_args run
     1148    add_poll_labels run
     1149    command $run
     1150  end
     1151
     1152  # success
     1153  task.exit    0
     1154    # convert 'stdout' to book format
     1155    ipptool2book stdout warpBGPendingCleanup -key warp_bg_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     1156    if ($VERBOSE > 2)
     1157      book listbook warpBGPendingCleanup
     1158    end
     1159
     1160    # delete existing entries in the appropriate pantaskStates
     1161    process_cleanup warpBGPendingCleanup
     1162  end
     1163
     1164  # locked list
     1165  task.exit    default
     1166    showcommand failure
     1167  end
     1168
     1169  task.exit    crash
     1170    showcommand crash
     1171  end
     1172
     1173  # operation times out?
     1174  task.exit    timeout
     1175    showcommand timeout
     1176  end
     1177end
     1178
     1179# run the ipp_cleanup.pl script on pending images
     1180task           warp.bg.cleanup.run
     1181  periods      -poll $RUNPOLL
     1182  periods      -exec $RUNEXEC
     1183  periods      -timeout 300
     1184  active       false
     1185
     1186  task.exec
     1187    book npages warpBGPendingCleanup -var N
     1188    if ($N == 0)
     1189        periods -exec $RUNEXEC
     1190        break
     1191    end
     1192    if ($NETWORK == 0) break
     1193   
     1194    # look for new images in warpBGPendingCleanup (pantaskState == INIT)
     1195    book getpage warpBGPendingCleanup 0 -var pageName -key pantaskState INIT
     1196    if ("$pageName" == "NULL") break
     1197
     1198    book setword warpBGPendingCleanup $pageName pantaskState RUN
     1199    book getword warpBGPendingCleanup $pageName camera -var CAMERA
     1200    book getword warpBGPendingCleanup $pageName state -var CLEANUP_MODE
     1201    book getword warpBGPendingCleanup $pageName warp_bg_id -var WARP_BG_ID
     1202    book getword warpBGPendingCleanup $pageName workdir -var WORKDIR_TEMPLATE
     1203    book getword warpBGPendingCleanup $pageName exp_tag -var EXP_TAG
     1204    book getword warpBGPendingCleanup $pageName dbname -var DBNAME
     1205
     1206    # specify choice of local or remote host based on camera and warp
     1207    set.host.for.camera $CAMERA FPA
     1208    set.workdir.by.camera $CAMERA $WARP_BG_ID $WORKDIR_TEMPLATE $default_host WORKDIR
     1209    sprintf logfile "%s/%s/%s.bgw.%s.cleanup.log" $WORKDIR $EXP_TAG $EXP_TAG $WARP_BG_ID
     1210
     1211    stdout $LOGDIR/warp.bg.cleanup.log
     1212    stderr $LOGDIR/warp.bg.cleanup.log
     1213
     1214    # XXX is everything listed here needed?
     1215    $run = ipp_cleanup.pl --stage warp_bg --stage_id $WARP_BG_ID --camera $CAMERA --mode $CLEANUP_MODE --logfile $logfile
     1216    add_standard_args run
     1217
     1218    # save the pageName for future reference below
     1219    options $pageName
     1220
     1221    # create the command line
     1222    if ($VERBOSE > 1)
     1223      echo command $run
     1224    end
     1225    periods -exec 0.05
     1226    command $run
     1227  end
     1228
     1229  # default exit status
     1230  task.exit    default
     1231    process_exit warpBGPendingCleanup $options:0 $JOB_STATUS
     1232  end
     1233
     1234  task.exit    crash
     1235    showcommand crash
     1236    book setword warpBGPendingCleanup $options:0 pantaskState CRASH
     1237  end
     1238
     1239  # operation timed out?
     1240  task.exit    timeout
     1241    showcommand timeout
     1242    book setword warpBGPendingCleanup $options:0 pantaskState TIMEOUT
     1243  end
     1244end
Note: See TracChangeset for help on using the changeset viewer.