Changeset 42449 for trunk/tools
- Timestamp:
- Apr 13, 2023, 9:30:40 AM (3 years ago)
- Location:
- trunk/tools/eam/rawfix.20230221/src
- Files:
-
- 3 added
- 5 edited
-
advance.rawfix.pl (modified) (2 diffs)
-
finish.fixchip.sh (added)
-
fix_chip_locations.pl (modified) (7 diffs)
-
get_hosts_fixchip.sh (added)
-
queue.rawfix.sh (modified) (1 diff)
-
rawfix.fixchip.pt (modified) (8 diffs)
-
rawfix.md5sum.pt (modified) (1 diff)
-
update_chip_stats.pl (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/advance.rawfix.pl
r42446 r42449 144 144 my $Nfail = $values[14]; 145 145 146 # in state of 'new', we do not care what the values of the stat fields are. 147 # they may be NULL, so do not yet try to do math on them here 148 if ($state eq "new") { &update_night_state ($dateobs, "ckchip.new", 0); return "NEW"; } 149 146 150 my $Ndone = $Ngood + $Ndead + $Ngone + $Nfail; 147 151 my $Nwait = $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3; … … 151 155 # check for completion here first (otherwise, advance fixchip.done below) 152 156 if (($state eq "fixchip.done") and ($iter > 0) and ($Nwait == 0)) { &update_night_state ($dateobs, "DONE"); return "DONE"; } 153 if ($state eq "new") { &update_night_state ($dateobs, "ckchip.new", 0); return "NEW"; }154 157 if ($state eq "ckchip.done") { &update_night_state ($dateobs, "fixchip.new"); return "NEW"; } 155 158 if ($state eq "fixchip.done") { &update_night_state ($dateobs, "md5sum.new"); return "NEW"; } -
trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
r42447 r42449 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 # USAGE: fix_chip_locations.pl --dateobs (night) -- chiplist (file) --stage (0,1,etc)14 # USAGE: fix_chip_locations.pl --dateobs (night) --stage (0,1,etc) [--chiplist (file) | --chipID (ID)] 15 15 16 16 # we need to select targets for ITC copies of files currently only at ATRC: … … 18 18 # for each chip, target a single host? 19 19 20 my ($fulldate, $dateword, $chiplist, $ stage, $topdir) = &parse_cmdopts;20 my ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir) = &parse_cmdopts; 21 21 my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 22 23 # read the list of chip_ids:24 my @chip_ids = &load_chip_list ($chiplist);25 22 26 23 # choose ITC machines on which to place backup copies: 27 24 my @vol_copy = &get_neb_volumes_copy; # array of neb hosts to copy data to at ITC 28 25 my %vol_good = &get_neb_volumes_good; # hash of valid neb hosts 29 my $volnum = 0;30 26 31 27 my $Ngood = 0; … … 41 37 my $Ncul3 = 0; 42 38 my $Nfail = 0; 39 40 my $Nchip = 0; # counts the number of instances 43 41 44 42 # load the lists of good and fail chips … … 69 67 } 70 68 71 my $Nchip = 0; 72 69 # read the list of chip_ids: 70 my @chip_ids = &load_chip_list ($chiplist); 71 72 my $volnum = 0; # select the volume to be used from the list of @vol_copy 73 74 # loop over all chip_ids so we can distribute the target volumes 73 75 foreach my $chip_id (@chip_ids) { 76 if (not defined $chipID or ($chipID eq $chip_id)) { 77 &fix_chip_locations_chipID ($chip_id, $volnum); 78 } 79 $volnum ++; 80 if ($volnum > @vol_copy) { $volnum = 0; } 81 } 82 83 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 84 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 85 86 if (not defined $chipID) { 87 # update the stats in the database 88 my $sql_update_stats = "UPDATE nights set"; 89 $sql_update_stats .= " Nchip = $Nchip"; 90 $sql_update_stats .= ", Ngood = $Ngood"; 91 $sql_update_stats .= ", Ndead = $Ndead"; 92 $sql_update_stats .= ", Ngone = $Ngone"; 93 $sql_update_stats .= ", Nsing = $Nsing"; 94 $sql_update_stats .= ", Ndups = $Ndups"; 95 $sql_update_stats .= ", Nsbck = $Nsbck"; 96 $sql_update_stats .= ", Nxbck = $Nxbck"; 97 $sql_update_stats .= ", Ncul1 = $Ncul1"; 98 $sql_update_stats .= ", Ncul2 = $Ncul2"; 99 $sql_update_stats .= ", Ncul3 = $Ncul3"; 100 $sql_update_stats .= ", Nfail = $Nfail"; 101 $sql_update_stats .= " WHERE dateobs = $dateword"; 102 103 my $query = $raw_dbh->prepare($sql_update_stats); 104 $query->execute () or die "invalid response from RAW database\n"; 105 } else { 106 107 open (OUTFILE, ">$topdir/$dateword/$chipID.stats.$stage.txt"); 108 109 print OUTFILE "Nchip: $Nchip\n"; 110 print OUTFILE "Ngood: $Ngood\n"; 111 print OUTFILE "Ngone: $Ngone\n"; 112 print OUTFILE "Ndead: $Ndead\n"; 113 print OUTFILE "Nsing: $Nsing\n"; 114 print OUTFILE "Ndups: $Ndups\n"; 115 print OUTFILE "Nsbck: $Nsbck\n"; 116 print OUTFILE "Nxbck: $Nxbck\n"; 117 print OUTFILE "Ncul1: $Ncul1\n"; 118 print OUTFILE "Ncul2: $Ncul2\n"; 119 print OUTFILE "Ncul3: $Ncul3\n"; 120 print OUTFILE "Nfail: $Nfail\n"; 121 122 close (OUTFILE); 123 } 124 125 exit 0; 126 127 sub fix_chip_locations_chipID { 128 129 my $chip_id = $_[0]; 130 my $volnum = $_[1]; 74 131 75 132 # read from chip_id file, update to next stage number … … 216 273 } 217 274 } 218 $volnum ++; 219 } 220 221 print "Nchip: $Nchip\n"; 222 print "Ngood: $Ngood\n"; 223 print "Ngone: $Ngone\n"; 224 print "Ndead: $Ndead\n"; 225 print "Nsing: $Nsing\n"; 226 print "Ndups: $Ndups\n"; 227 print "Nsbck: $Nsbck\n"; 228 print "Nxbck: $Nxbck\n"; 229 print "Ncul1: $Ncul1\n"; 230 print "Ncul2: $Ncul2\n"; 231 print "Ncul3: $Ncul3\n"; 232 print "Nfail: $Nfail\n"; 233 234 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 235 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 236 237 # update the stats in the database 238 my $sql_update_stats = "UPDATE nights set"; 239 $sql_update_stats .= " Nchip = $Nchip"; 240 $sql_update_stats .= ", Ngood = $Ngood"; 241 $sql_update_stats .= ", Ndead = $Ndead"; 242 $sql_update_stats .= ", Ngone = $Ngone"; 243 $sql_update_stats .= ", Nsing = $Nsing"; 244 $sql_update_stats .= ", Ndups = $Ndups"; 245 $sql_update_stats .= ", Nsbck = $Nsbck"; 246 $sql_update_stats .= ", Nxbck = $Nxbck"; 247 $sql_update_stats .= ", Ncul1 = $Ncul1"; 248 $sql_update_stats .= ", Ncul2 = $Ncul2"; 249 $sql_update_stats .= ", Ncul3 = $Ncul3"; 250 $sql_update_stats .= ", Nfail = $Nfail"; 251 $sql_update_stats .= " WHERE dateobs = $dateword"; 252 253 my $query = $raw_dbh->prepare($sql_update_stats); 254 $query->execute () or die "invalid response from RAW database\n"; 255 256 exit 0; 275 } 257 276 258 277 sub get_new_instance { … … 412 431 sub parse_cmdopts { 413 432 414 my ($dateobs, $chiplist, $ stage, $topdir);415 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, ' topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2);433 my ($dateobs, $chiplist, $chipID, $stage, $topdir); 434 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'chipID=s' => \$chipID, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2); 416 435 417 436 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 418 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;419 437 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 420 438 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 421 439 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 440 422 441 # check that stage is an integer 423 442 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } … … 435 454 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 436 455 437 return ($fulldate, $dateword, $chiplist, $ stage, $topdir);456 return ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir); 438 457 } 439 458 -
trunk/tools/eam/rawfix.20230221/src/queue.rawfix.sh
r42442 r42449 29 29 if ($mode == "night") then 30 30 ## XXX validate the format (YYYYMMDD)? 31 32 XXXXX:33 34 31 set mynight = $2 35 32 -
trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt
r42447 r42449 9 9 if (not($?RAWFIX_FIXCHIP_INIT)) 10 10 book init fixchip.book 11 book init fixhost.book 11 12 $RAWFIX_FIXCHIP_INIT = 1 12 13 end … … 27 28 28 29 task.exec 29 # command check.rawfix.sh state ckchip.done30 30 command check.rawfix.sh state fixchip.new 31 31 end … … 53 53 end 54 54 55 task nights.fixchip.run 55 # output: fixhost.book 56 task nights.fixchip.loadhosts 56 57 periods -poll $RPOLL 57 58 periods -exec $REXEC 58 periods -timeout 180059 host -required $HOST_FIXCHIP59 periods -timeout 60 60 host local 60 61 npending 1 62 # note: the tasks which return their results via stdout 63 # seem to fail if run remotely. 64 65 stdout $LOGDIR/fixchip.loadhosts.stdout.log 66 stderr $LOGDIR/fixchip.loadhosts.stderr.log 61 67 62 68 task.exec … … 76 82 book getword fixchip.book $pageName iter -var ITER 77 83 option $pageName 78 79 stdout $pageName/log.fixchip.v$ITER 80 stderr $pageName/log.fixchip.v$ITER 84 # save the page so we can use it below 85 86 # write an entry point in the log for this night 87 sprintf tmpline "%s/%s/log.fixchip.runhosts.v%d" $mypath $DATEOBS $ITER 88 date -var mydate 89 exec echo "# start runhosts $mydate" >> $tmpline 90 91 # the command returns these fields: dateobs stage fixhost chipID 92 # NOTE: stage == ITER 93 command $mypath/get_hosts_fixchip.sh $mypath $DATEOBS $ITER 94 end 95 96 task.exit 0 97 # convert the stdout 'queue' to entries in a book 98 # fields in the table will become words in the page 99 queueprint stdout 100 queuesize stdout -var Nhosts 101 queue2book -raw-columns -key dateobs:chipID -uniq -setword pantaskState INIT stdout fixhost.book 102 book setword fixchip.book $options:0 NHOST {$Nhosts - 1} 103 book setword fixchip.book $options:0 NDONE 0 104 book list 105 book listbook fixchip.book 106 # use the queuesize (Nhosts) to track how many jobs are done / to be done 107 end 108 109 # exit values other than 0: 110 task.exit default 111 showcommand failure 112 book setword fixchip.book $options:0 pantasksQuality FAIL 113 end 114 115 task.exit crash 116 showcommand crash 117 book setword fixchip.book $options:0 pantasksQuality CRASH 118 end 119 120 # operation times out? 121 task.exit timeout 122 showcommand timeout 123 book setword fixchip.book $options:0 pantasksQuality TIMEOUT 124 end 125 end 126 127 task nights.fixchip.run 128 periods -poll $RPOLL 129 periods -exec $REXEC 130 periods -timeout 1800 131 132 task.exec 133 # if we are unable to run the 'exec', use a long retry time 134 periods -exec $REXEC 135 136 book npages fixhost.book -var N 137 if ($N == 0) break 138 if ($NETWORK == 0) break 139 140 # look for new nights in fixhost.book (pantaskState == INIT) 141 book getpage fixhost.book 0 -var pageName -key pantaskState INIT 142 if ("$pageName" == "NULL") break 143 144 book setword fixhost.book $pageName pantaskState RUN 145 book getword fixhost.book $pageName dateobs -var DATEOBS 146 book getword fixhost.book $pageName iter -var ITER 147 book getword fixhost.book $pageName fixhost -var FIXHOST 148 book getword fixhost.book $pageName chipID -var CHIP_ID 149 option $pageName $DATEOBS 150 151 stdout $pageName/log.fixchip.run.v$ITER 152 stderr $pageName/log.fixchip.run.v$ITER 81 153 82 154 substr $DATEOBS 0 4 YEAR … … 85 157 sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY 86 158 87 command $mypath/fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage $ITER 88 end 89 90 ## XX delete the page from the book if done? 91 task.exit 0 159 host -required $FIXHOST 160 ## check if this host needs to be launched 161 if (not($?host:$FIXHOST)) 162 echo "host not defined, creating : $FIXHOST" 163 $host:$FIXHOST = 0 164 end 165 if (not($host:$FIXHOST)) 166 control host add $FIXHOST 167 $host:$FIXHOST = 1 168 end 169 170 # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs 171 periods -exec 0.05 172 command $mypath/fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --chipID $CHIP_ID --stage $ITER 173 end 174 175 task.exit 0 176 nights.fixchip.exit OK 177 end 178 179 # exit values other than 0: 180 task.exit default 181 nights.fixchip.exit FAIL 182 showcommand failure 183 end 184 185 task.exit crash 186 nights.fixchip.exit CRASH 187 showcommand crash 188 end 189 190 # operation times out? 191 task.exit timeout 192 nights.fixchip.exit TIMEOUT 193 showcommand timeout 194 end 195 end 196 197 # output: fixhost.book 198 task nights.fixchip.clean 199 200 periods -poll $RPOLL 201 periods -exec $REXEC 202 periods -timeout 60 203 npending 1 204 205 stdout $LOGDIR/fixchip.clean.stdout.log 206 stderr $LOGDIR/fixchip.clean.stderr.log 207 208 task.exec 209 # if we are unable to run the 'exec', use a long retry time 210 periods -exec $REXEC 211 212 book npages fixchip.book -var N 213 if ($N == 0) break 214 if ($NETWORK == 0) break 215 216 # look for completed nights in fixchip.book (pantaskState == STOP) 217 book getpage fixchip.book 0 -var pageName -key pantaskState STOP 218 if ("$pageName" == "NULL") break 219 220 # book listpage fixchip.book $pageName 221 222 # book setword fixchip.book $pageName pantaskState RUN 223 book getword fixchip.book $pageName dateobs -var DATEOBS 224 book getword fixchip.book $pageName pantasksQuality -var QUALITY 225 226 option $pageName 227 # save the page so we can use it below 228 229 if ("$QUALITY" == "OK") 230 command update.rawfix.sh $DATEOBS fixchip.done 231 else 232 command update.rawfix.sh $DATEOBS fixchip.fail 233 end 234 end 235 236 task.exit 0 237 # now that the entry is set to done in the db, remove the pantasks book entry 238 echo "cleaning this page: $options:0" 92 239 book setword fixchip.book $options:0 pantaskState DONE 93 exec update.rawfix.sh $options:0 fixchip.done94 240 end 95 241 … … 98 244 showcommand failure 99 245 book setword fixchip.book $options:0 pantasksQuality FAIL 100 exec update.rawfix.sh $options:0 fixchip.fail101 246 end 102 247 … … 104 249 showcommand crash 105 250 book setword fixchip.book $options:0 pantasksQuality CRASH 106 exec update.rawfix.sh $options:0 fixchip.fail107 251 end 108 252 … … 111 255 showcommand timeout 112 256 book setword fixchip.book $options:0 pantasksQuality TIMEOUT 113 exec update.rawfix.sh $options:0 fixchip.fail 114 end 115 end 116 257 end 258 end 259 260 ######################### UTILITIES ################################# 261 262 macro nights.fixchip.exit 263 if ($0 != 2) 264 echo "USAGE: nights.fixchip.exit (quality)" 265 break 266 end 267 268 book setword fixhost.book $options:0 pantaskState DONE 269 book getword fixchip.book $options:1 NHOST -var Nhosts 270 book getword fixchip.book $options:1 NDONE -var Ndone 271 book getword fixchip.book $options:1 stage -var ITER 272 $Ndone ++ 273 book setword fixchip.book $options:1 NDONE $Ndone 274 if ("$1" != "OK") 275 book setword fixchip.book $options:1 pantasksQuality $1 276 sprintf tmpline "%s/%s/log.fixchip.runhosts.v%d" $mypath $options:1 $ITER 277 exec echo "failure $1 $options:0" >> $tmpline 278 else 279 exec echo "success $1 $options:0" >> $tmpline 280 end 281 if ($Ndone == $Nhosts) 282 book setword fixchip.book $options:1 pantaskState STOP 283 end 284 book delpage fixhost.book $options:0 285 end 286 -
trunk/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt
r42445 r42449 127 127 # runs on the hosts identified by get_hosts_md5s.sh 128 128 # output: md5host.book 129 task nights.md5sum.run hosts129 task nights.md5sum.run 130 130 131 131 periods -poll $RPOLL
Note:
See TracChangeset
for help on using the changeset viewer.
