IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 17, 2023, 4:41:34 PM (3 years ago)
Author:
eugene
Message:

merging from trunk

Location:
branches/eam_branches/ipp-20230313/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20230313/tools

  • branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt

    r42406 r42531  
    99if (not($?RAWFIX_FIXCHIP_INIT))
    1010  book init fixchip.book
     11  book init fixhost.book
    1112  $RAWFIX_FIXCHIP_INIT = 1
    1213end
     14
     15$MAX_FIXHOST = 2
    1316
    1417# select nights in state fixchip.new
     
    2730
    2831  task.exec
    29     # command check.rawfix.sh state ckchip.done
    3032    command check.rawfix.sh state fixchip.new
    3133  end
     
    3537    # fields in the table will become words in the page
    3638    queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout fixchip.book
    37   end
    38 
    39   # exit values other than 0:
    40   task.exit    default
    41     showcommand failure
    42   end
    43 
    44   task.exit    crash
    45     showcommand crash
    46   end
    47 
    48   # operation times out?
    49   task.exit    timeout
    50     showcommand timeout
    51   end
    52 end
    53 
    54 task nights.fixchip.run
    55 
     39    book delpage fixchip.book -key pantaskState DONE
     40  end
     41
     42  # exit values other than 0:
     43  task.exit    default
     44    showcommand failure
     45  end
     46
     47  task.exit    crash
     48    showcommand crash
     49  end
     50
     51  # operation times out?
     52  task.exit    timeout
     53    showcommand timeout
     54  end
     55end
     56
     57# output: fixhost.book
     58task nights.fixchip.loadhosts
    5659  periods      -poll $RPOLL
    5760  periods      -exec $REXEC
    5861  periods      -timeout 60
     62  host          local
    5963  npending 1
    60 
    61   stdout $LOGDIR/fixchip.run.stdout.log 
    62   stderr $LOGDIR/fixchip.run.stderr.log
     64  # note: the tasks which return their results via stdout
     65  # seem to fail if run remotely. 
     66
     67  stdout $LOGDIR/fixchip.loadhosts.stdout.log 
     68  stderr $LOGDIR/fixchip.loadhosts.stderr.log
    6369
    6470  task.exec
     
    7682    book setword fixchip.book $pageName pantaskState RUN
    7783    book getword fixchip.book $pageName dateobs -var DATEOBS
     84    book getword fixchip.book $pageName iter    -var ITER
    7885    option $pageName
     86    # save the page so we can use it below
     87
     88    substr $DATEOBS 0 4 YEAR
     89
     90    # write an entry point in the log for this night
     91    sprintf tmpline "%s/%s/%s/log.fixchip.runhosts.v%d" $mypath $YEAR $DATEOBS $ITER
     92    date -var mydate
     93    exec echo "# start runhosts $mydate" >> $tmpline
     94
     95    # the command returns these fields: dateobs stage fixhost chipID
     96    # NOTE: stage == ITER
     97    command get_hosts_fixchip.sh $mypath $DATEOBS $ITER
     98  end
     99
     100  task.exit 0
     101    # convert the stdout 'queue' to entries in a book
     102    # fields in the table will become words in the page
     103    # queueprint stdout
     104    queuesize stdout -var Nhosts
     105    queue2book -raw-columns -key dateobs:chipID -uniq -setword pantaskState INIT stdout fixhost.book
     106    book setword fixchip.book $options:0 NHOST {$Nhosts - 1}
     107    book setword fixchip.book $options:0 NDONE 0
     108    # book list
     109    # book listbook fixchip.book
     110    # use the queuesize (Nhosts) to track how many jobs are done / to be done
     111  end
     112
     113  # exit values other than 0:
     114  task.exit    default
     115    showcommand failure
     116    book setword fixchip.book $options:0 pantasksQuality FAIL
     117  end
     118
     119  task.exit    crash
     120    showcommand crash
     121    book setword fixchip.book $options:0 pantasksQuality CRASH
     122  end
     123
     124  # operation times out?
     125  task.exit    timeout
     126    showcommand timeout
     127    book setword fixchip.book $options:0 pantasksQuality TIMEOUT
     128  end
     129end
     130
     131task nights.fixchip.run
     132  periods      -poll $RPOLL
     133  periods      -exec $REXEC
     134  periods      -timeout 1800
     135
     136  task.exec
     137    # if we are unable to run the 'exec', use a long retry time
     138    periods -exec $REXEC
     139
     140    book npages fixhost.book -var N
     141    if ($N == 0) break
     142    if ($NETWORK == 0) break
     143   
     144    # look for new nights in fixhost.book (pantaskState == INIT)
     145    book getpage fixhost.book 0 -var pageName -key pantaskState INIT
     146    if ("$pageName" == "NULL") break
     147
     148    book setword fixhost.book $pageName pantaskState RUN
     149    book getword fixhost.book $pageName dateobs -var DATEOBS
     150    book getword fixhost.book $pageName iter    -var ITER
     151    book getword fixhost.book $pageName fixhost -var FIXHOST
     152    book getword fixhost.book $pageName chipID  -var CHIP_ID
    79153
    80154    substr $DATEOBS 0 4 YEAR
     
    83157    sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY
    84158
    85     command fix_chip_locations.pl --dateobs $FULLDATE --chiplist gpc1.chips.txt
    86   end
    87 
    88   ## XX delete the page from the book if done?
    89   task.exit 0
    90     # convert the stdout 'queue' to entries in a book
    91     # fields in the table will become words in the page
    92     # use the queuesize (Nhosts) to track how many jobs are done / to be done
    93     exec update.rawfix.sh $options:0 fixchip.done
    94     book delpage fixchip.book $options:0
     159    option $pageName $DATEOBS $YEAR
     160    # save DATEOBS so we can find the md5sum.book entry
     161    # also save YEAR for output log
     162
     163    stdout $mypath/$YEAR/$DATEOBS/log.fixchip.run.$CHIP_ID.v$ITER
     164    stderr $mypath/$YEAR/$DATEOBS/log.fixchip.run.$CHIP_ID.v$ITER
     165
     166    host -required $FIXHOST
     167    ## check if this host needs to be launched
     168    if (not($?host:$FIXHOST))
     169      echo "host not defined, creating : $FIXHOST"
     170      $host:$FIXHOST = 0
     171    end
     172    if ($host:$FIXHOST < $MAX_FIXHOST)
     173      control host add $FIXHOST
     174      $host:$FIXHOST ++
     175    end
     176
     177    # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs
     178    periods -exec 0.05
     179    command fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --chipID $CHIP_ID --stage $ITER
     180  end
     181
     182  task.exit 0
     183    nights.fixchip.exit OK
     184  end
     185
     186  # exit values other than 0:
     187  task.exit    default
     188    nights.fixchip.exit FAIL
     189    showcommand failure
     190  end
     191
     192  task.exit    crash
     193    nights.fixchip.exit CRASH
     194    showcommand crash
     195  end
     196
     197  # operation times out?
     198  task.exit    timeout
     199    nights.fixchip.exit TIMEOUT
     200    showcommand timeout
     201  end
     202end
     203
     204# output: fixhost.book
     205task nights.fixchip.clean
     206
     207  periods      -poll $RPOLL
     208  periods      -exec $REXEC
     209  periods      -timeout 60
     210  npending 1
     211
     212  stdout $LOGDIR/fixchip.clean.stdout.log 
     213  stderr $LOGDIR/fixchip.clean.stderr.log
     214
     215  task.exec
     216    # if we are unable to run the 'exec', use a long retry time
     217    periods -exec $REXEC
     218
     219    book npages fixchip.book -var N
     220    if ($N == 0) break
     221    if ($NETWORK == 0) break
     222   
     223    # look for completed nights in fixchip.book (pantaskState == STOP)
     224    book getpage fixchip.book 0 -var pageName -key pantaskState STOP
     225    if ("$pageName" == "NULL") break
     226
     227    # book listpage fixchip.book $pageName
     228
     229    # book setword fixchip.book $pageName pantaskState RUN
     230    book getword fixchip.book $pageName dateobs -var DATEOBS
     231    book getword fixchip.book $pageName pantasksQuality -var QUALITY
     232
     233    option $pageName
     234    # save the page so we can use it below
     235
     236    if ("$QUALITY" == "OK")
     237      command update.rawfix.sh $DATEOBS fixchip.done
     238    else
     239      command update.rawfix.sh $DATEOBS fixchip.fail
     240    end
     241  end
     242
     243  task.exit 0
     244    # now that the entry is set to done in the db, remove the pantasks book entry
     245    echo "cleaning this page: $options:0"
     246    book setword fixchip.book $options:0 pantaskState DONE
    95247  end
    96248
     
    99251    showcommand failure
    100252    book setword fixchip.book $options:0 pantasksQuality FAIL
    101     exec update.rawfix.sh $options:0 fixchip.fail
    102253  end
    103254
     
    105256    showcommand crash
    106257    book setword fixchip.book $options:0 pantasksQuality CRASH
    107     exec update.rawfix.sh $options:0 fixchip.fail
    108258  end
    109259
     
    112262    showcommand timeout
    113263    book setword fixchip.book $options:0 pantasksQuality TIMEOUT
    114     exec update.rawfix.sh $options:0 fixchip.fail
    115   end
    116 end
    117 
     264  end
     265end
     266
     267######################### UTILITIES #################################
     268
     269macro nights.fixchip.exit
     270  if ($0 != 2)
     271    echo "USAGE: nights.fixchip.exit (quality)"
     272    break
     273  end
     274
     275  # options are : pagename DATEOBS YEAR
     276
     277  book setword fixhost.book $options:0 pantaskState DONE
     278  book getword fixchip.book $options:1 NHOST -var Nhosts
     279  book getword fixchip.book $options:1 NDONE -var Ndone
     280  book getword fixchip.book $options:1 stage -var ITER
     281  $Ndone ++
     282  book setword fixchip.book $options:1 NDONE $Ndone
     283
     284  sprintf tmpline "%s/%s/%s/log.fixchip.runhosts.v%d" $mypath $options:2 $options:1 $ITER
     285  if ("$1" != "OK")
     286    book setword fixchip.book $options:1 pantasksQuality $1
     287    exec echo "failure $1 $options:0" >> $tmpline
     288  else
     289    exec echo "success $1 $options:0" >> $tmpline
     290  end
     291  if ($Ndone == $Nhosts)
     292    book setword fixchip.book $options:1 pantaskState STOP
     293  end
     294  book delpage fixhost.book $options:0
     295end
     296
Note: See TracChangeset for help on using the changeset viewer.