IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42452


Ignore:
Timestamp:
Apr 21, 2023, 10:36:27 AM (3 years ago)
Author:
eugene
Message:

some improvements (make sure to examine md5s for chip-specific inst files, randomly draw the new nights)

Location:
trunk/tools/eam/rawfix.20230221/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/eam/rawfix.20230221/src/advance.rawfix.pl

    r42449 r42452  
    7777
    7878    # select and advance nights not yet running
    79     $sql_get_run = "SELECT dateobs from nights where state = 'new'";
     79#   $sql_get_run = "SELECT dateobs from nights where state = 'new'";
     80
     81    $sql_get_run = "SELECT dateobs FROM (SELECT dateobs, rand() AS myrand FROM nights WHERE (state = 'new')) AS tmp ORDER BY myrand";
     82
    8083    $runref   = $raw_dbh->selectall_arrayref( $sql_get_run );
    8184    @runarray = @$runref;
  • trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl

    r42451 r42452  
    196196        if ($Nvalues != 3) { print "ERROR: invalid response?\n"; next; }
    197197       
     198        # data_state and possibly md5sum can be NULL, need to handle specially
     199        my $dstate = $values[1]; if (not defined $dstate) { $dstate = "NULL"; }
     200        my $md5sum = $values[2]; if (not defined $md5sum) { $md5sum = "XXXX"; }
     201       
    198202        push (@nebarray, $values[0]);
    199         push (@ds_array, $values[1]);
    200         push (@md_array, $values[2]);
    201         if ($DEBUG > 4) { print "$values[0]\n $values[1]\n $values[2]\n"; }
     203        push (@md_array, $md5sum);
     204        push (@ds_array, $dstate);
     205
     206        if ($DEBUG > 5) { print "V0: $values[0]\n"; print "V1: $values[1]\n"; print "V2: $values[2]\n"; }
     207        if ($DEBUG > 4) { print "PRINT: $values[0]\n $dstate\n $md5sum\n"; }
    202208    }
    203209
  • trunk/tools/eam/rawfix.20230221/src/check_md5s_dateobs.pl

    r42447 r42452  
    1616my ($dateword, $stage, $topdir) = &parse_cmdopts;
    1717
    18 my @instlist = glob ("$topdir/$dateword/*.inst.$stage.txt");
    19 my @md5slist = glob ("$topdir/$dateword/*.md5s.txt");
     18my $instlist_r = &load_instlist_filenames ($topdir, $dateword, $stage);
     19my $md5slist_r = &load_md5slist_filenames ($topdir, $dateword, $stage, $instlist_r);
    2020
    2121my $Nfail = 0;
     
    2323my %goodchips;
    2424
    25 foreach my $instfile (@instlist) {
    26 
    27     # find the matching md5sum file for this host
    28 
    29     my ($host) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.$stage.txt|;
    30     # print STDERR "host: $host\n";
    31 
    32     my $md5match = "NONE";
    33     foreach my $md5sfile (@md5slist) {
    34        
    35         my ($md5shost) = $md5sfile =~ m|$dateword/([0-9a-zA-Z]*).md5s.txt|;
    36         # print STDERR "md5host: $md5shost\n";
    37        
    38         if ($host ne $md5shost) { next; }
    39 
    40         $md5match = $md5sfile;
    41         last;
    42     }
    43 
    44     if ($md5match eq "NONE") {
    45         print STDOUT "missing md5sum file for $instfile\n";
    46         $Nfail ++;
    47         next;
    48     }
     25# make a list of the master instance files:
     26
     27foreach my $instfile (@$instlist_r) {
     28
     29    # print "inst: $instfile\n";
     30
     31    my $md5sfile = $md5slist_r->{$instfile};
    4932
    5033    ## read in the md5sums
    51     open (FILE, $md5match);
     34    open (FILE, $md5sfile);
    5235    my @md5data = <FILE>;
    5336    close (FILE);
    5437
    55     ## read in the list of instances
    56     open (FILE, $instfile);
    57     my @instdata = <FILE>;
    58     close (FILE);
     38    my $instdata_r = &load_instance_list ($topdir, $dateword, $stage, $instfile);
    5939
    6040    # if these do not match, complain and move on
     
    6242    # may have been culled during this process (but the MD5s stay behind)
    6343    my $N1 = @md5data;
    64     my $N2 = @instdata;
     44    my $N2 = @$instdata_r;
    6545    if ($N1 < $N2) {
    66         print STDOUT "not enough MD5s $md5match : $N1 vs $N2\n";
     46        print STDOUT "not enough MD5s $md5sfile : $N1 vs $N2\n";
    6747        $Nfail ++;
    6848        next;
     49    } else {
     50        # print STDOUT "checking MD5s $md5sfile : $N1 vs $N2\n";
    6951    }
    7052
    7153    # set up an empty hash for the instance names:
    7254    my %instfound = ();
    73     foreach my $line (@instdata) {
     55    foreach my $line (@$instdata_r) {
    7456        chomp $line;
    7557        my @words = split (/\s+/,$line);
     
    8668
    8769        # we expect lines of the form: INST STATE MDtru MDobs
    88         if (@words != 4) { die "error in MD5 list $md5match, line: $line\n"; }
     70        if (@words != 4) { die "error in MD5 list $md5sfile, line: $line\n"; }
    8971
    9072        my $inst   = $words[0];
     
    136118    print STDOUT "SUCCESS: $Nfail errors\n";
    137119    exit 0;
     120}
     121
     122# use global $topdir, $dateword, $myhost, $stage
     123sub load_instance_list {
     124    my $topdir   = $_[0];
     125    my $dateword = $_[1];
     126    my $stage    = $_[2];
     127    my $instfile = $_[3];
     128
     129    my @instdata_list;
     130
     131    # load the master list
     132    &load_instance_list_onefile ($instfile, \@instdata_list);
     133
     134    # there may be additional instances in files with names like HOSTNAME.XYnn.inst.STAGE
     135    my ($myhost) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.$stage.txt|;
     136    my @instlist = glob ("$topdir/$dateword/$myhost.XY??.inst.$stage.txt");
     137    foreach my $infile  (@instlist) {
     138        &load_instance_list_onefile ($infile, \@instdata_list);
     139    }
     140    return (\@instdata_list);
     141}
     142
     143# read the instance info
     144sub load_instance_list_onefile {
     145    my $infile = $_[0];
     146    my $instdata_list_r = $_[1]; # reference to the file data
     147
     148    open(FILE,$infile) or die "cannot open file $infile\n";
     149    my @lines = <FILE>;
     150    close (FILE);
     151
     152    foreach my $line (@lines) {
     153        chomp $line;
     154        if ($line =~ /^\s*#/) { next; } # skip lines with leading #
     155        push (@$instdata_list_r, $line);
     156    }
     157}
     158
     159# return only the master instlist filenames (ignore ones with the chipnames in the name)
     160sub load_instlist_filenames {
     161   
     162    my $topdir   = $_[0];
     163    my $dateword = $_[1];
     164    my $stage    = $_[2];
     165
     166    my @instlist_all = glob ("$topdir/$dateword/*.inst.$stage.txt");
     167
     168    my @instlist = ();
     169
     170    foreach my $instfile (@instlist_all) {
     171
     172        # skip the per-chip inst files (these should probably be merged into the master)
     173        if ($instfile =~ m|XY[0-9][0-9].inst|) { next; }
     174
     175        push (@instlist, $instfile);
     176    }
     177    return (\@instlist);
     178}
     179
     180# return a hash of the matched md5 file for each inst file
     181sub load_md5slist_filenames {
     182
     183    my $topdir     = $_[0];
     184    my $dateword   = $_[1];
     185    my $stage      = $_[2];
     186    my $instlist_r = $_[3];
     187
     188    my @md5slist = glob ("$topdir/$dateword/*.md5s.txt");
     189
     190    my %md5shash;
     191
     192    my $Nfail = 0;
     193
     194    foreach my $instfile (@$instlist_r) {
     195
     196        # find the matching md5sum file for this host
     197
     198        my ($host) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.$stage.txt|;
     199        # print STDERR "host: $host\n";
     200
     201        my $md5match = "NONE";
     202        foreach my $md5sfile (@md5slist) {
     203       
     204            my ($md5shost) = $md5sfile =~ m|$dateword/([0-9a-zA-Z]*).md5s.txt|;
     205       
     206            if ($host ne $md5shost) { next; }
     207
     208            # print STDERR "md5host: $md5shost : $md5sfile = $instfile\n";
     209
     210            $md5match = $md5sfile;
     211            last;
     212        }
     213
     214        if ($md5match eq "NONE") {
     215            print STDOUT "missing md5sum file for $instfile\n";
     216            $Nfail ++;
     217            next;
     218        }
     219        $md5shash{$instfile} = $md5match;
     220
     221        # print "match: $instfile = $md5match\n";
     222
     223    }
     224    if ($Nfail > 0) {
     225        print STDOUT "ERROR: $Nfail errors\n";
     226        exit 1;
     227    }
     228    return (\%md5shash);
    138229}
    139230
  • trunk/tools/eam/rawfix.20230221/src/get_hosts_md5s.sh

    r42445 r42452  
    2121
    2222# report both the dateobs and the hostnames
    23 ls $topdir/$dateobs/*.inst.$stage.txt | awk -v dateobs=$dateobs -v stage=$stage -F/ '(NR == 1){print "dateobs stage md5host"}{print dateobs, stage, $NF}' | sed s/.inst.$stage.txt//
     23ls $topdir/$dateobs/*.inst.$stage.txt | grep -v "XY...inst" | awk -v dateobs=$dateobs -v stage=$stage -F/ '(NR == 1){print "dateobs stage md5host"}{print dateobs, stage, $NF}' | sed s/.inst.$stage.txt//
    2424exit 0
  • trunk/tools/eam/rawfix.20230221/src/rawfix.advance.pt

    r42450 r42452  
    11
    2 $MAX_ACTIVE_NIGHTS = 5
     2$MAX_ACTIVE_NIGHTS = 10
    33
    44## regularly run the command advance.rawfits.sh
     
    88  periods -timeout 30
    99  host local
     10  active true
    1011
    1112  stdout $LOGDIR/advance.log 
     
    3940  end
    4041end
     42
     43macro nights.advance.on
     44  task nights.advance
     45    active true
     46  end
     47end
     48
     49macro nights.advance.off
     50  task nights.advance
     51    active false
     52  end
     53end
     54
     55 
  • trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt

    r42451 r42452  
    1212  $RAWFIX_FIXCHIP_INIT = 1
    1313end
     14
     15$MAX_FIXHOST = 2
    1416
    1517# select nights in state fixchip.new
     
    9799    # convert the stdout 'queue' to entries in a book
    98100    # fields in the table will become words in the page
    99     queueprint stdout
     101    # queueprint stdout
    100102    queuesize stdout -var Nhosts
    101103    queue2book -raw-columns -key dateobs:chipID -uniq -setword pantaskState INIT stdout fixhost.book
    102104    book setword fixchip.book $options:0 NHOST {$Nhosts - 1}
    103105    book setword fixchip.book $options:0 NDONE 0
    104     book list
    105     book listbook fixchip.book
     106    # book list
     107    # book listbook fixchip.book
    106108    # use the queuesize (Nhosts) to track how many jobs are done / to be done
    107109  end
     
    163165      $host:$FIXHOST = 0
    164166    end
    165     if (not($host:$FIXHOST))
     167    if ($host:$FIXHOST < $MAX_FIXHOST)
    166168      control host add $FIXHOST
    167       $host:$FIXHOST = 1
     169      $host:$FIXHOST ++
    168170    end
    169171
  • trunk/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt

    r42451 r42452  
    1212  $RAWFIX_MD5SUM_INIT = 1
    1313end
     14
     15$MAX_MD5HOST = 2
    1416
    1517# select nights which are ready for md5sum calcs
     
    9799    # convert the stdout 'queue' to entries in a book
    98100    # fields in the table will become words in the page
    99     queueprint stdout
     101    # queueprint stdout
    100102    queuesize stdout -var Nhosts
    101103    queue2book -raw-columns -key dateobs:md5host -uniq -setword pantaskState INIT stdout md5host.book
    102104    book setword md5sum.book $options:0 NHOST {$Nhosts - 1}
    103105    book setword md5sum.book $options:0 NDONE 0
    104     book list
    105     book listbook md5sum.book
     106    # book list
     107    # book listbook md5sum.book
    106108    # use the queuesize (Nhosts) to track how many jobs are done / to be done
    107109  end
     
    166168      $host:$USE_HOST = 0
    167169    end
    168     if (not($host:$USE_HOST))
     170    if ($host:$USE_HOST < $MAX_MD5HOST)
    169171      control host add $USE_HOST
    170       $host:$USE_HOST = 1
     172      $host:$USE_HOST ++
    171173    end
    172174
Note: See TracChangeset for help on using the changeset viewer.