IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.