IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2023, 4:50:38 PM (3 years ago)
Author:
eugene
Message:

rework to use a stage/iteration tracked by the rawfix database

File:
1 edited

Legend:

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

    r42444 r42445  
    1717
    1818my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
    19 my ($neb_dbh, $gpc_dbh) = &parse_db_config ("$topdir/nebulous.config");
     19my ($neb_dbh, $gpc_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config");
    2020
    2121# read the list of chip_ids:
     
    3232# instance lists by host: YYYYMMDD/HOSTNAME.inst.STAGE.txt
    3333# chip states by chip: YYYYMMDD/CHIPNAME.uris.STAGE.txt
     34
     35my $Nchip = 0;
     36
     37my $Ngood = 0;
     38my $Ndead = 0;
     39my $Ngone = 0;
     40my $Nsing = 0;
     41my $Ndups = 0;
     42my $Nsbck = 0;
     43my $Nxbck = 0;
     44
     45my $Ncul1 = 0;
     46my $Ncul2 = 0;
     47my $Ncul3 = 0;
    3448
    3549foreach my $chip_id (@chip_ids) {
     
    90104}
    91105
    92 # run neb-replicate for SING entries?
    93 # run neb-replicate for SBCK entries?  (does this put a second copy at ATRC or ITC?)
    94 # save the list of instances on each host
    95 ## run md5sum on the instances for each host
    96 ## only note inconsistent md5sums?  (need to save the gpc1 md5sum values)
    97 # rerun to generate a list of the host with max instances per chip?
    98 
    99 ### when to cull entries?
    100 ## neb-replicate puts the new entry at ATRC by default
    101 ## neb-replicate --volume VOL puts the new entry at the specified location
    102 ### in order to use this, I need to choose the target volume
     106print "Nchip: $Nchip\n";
     107print "Ngood: $Ngood\n";
     108print "Ngone: $Ngone\n";
     109print "Ndead: $Ndead\n";
     110print "Nsing: $Nsing\n";
     111print "Ndups: $Ndups\n";
     112print "Nsbck: $Nsbck\n";
     113print "Nxbck: $Nxbck\n";
     114print "Ncul1: $Ncul1\n";
     115print "Ncul2: $Ncul2\n";
     116print "Ncul3: $Ncul3\n";
     117
     118my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3;
     119if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; }
     120
     121# update the stats in the database
     122my $sql_update_stats = "UPDATE nights set";
     123$sql_update_stats .= "  Nchip = $Nchip";
     124$sql_update_stats .= ", Ngood = $Ngood";
     125$sql_update_stats .= ", Ndead = $Ndead";
     126$sql_update_stats .= ", Ngone = $Ngone";
     127$sql_update_stats .= ", Nsing = $Nsing";
     128$sql_update_stats .= ", Ndups = $Ndups";
     129$sql_update_stats .= ", Nsbck = $Nsbck";
     130$sql_update_stats .= ", Nxbck = $Nxbck";
     131$sql_update_stats .= ", Ncul1 = $Ncul1";
     132$sql_update_stats .= ", Ncul2 = $Ncul2";
     133$sql_update_stats .= ", Ncul3 = $Ncul3";
     134$sql_update_stats .= " WHERE dateobs = $dateword";
     135
     136my $query = $raw_dbh->prepare($sql_update_stats);
     137$query->execute () or die "invalid response from RAW database\n";
    103138
    104139exit 0;
     
    256291
    257292    my $outinfo = "$extID $data_st $md5_sum";
     293    $Nchip ++;
    258294
    259295    # GOOD : already fixed
    260296    if (($Nmain == 1) && ($Nback == 1)) {
    261297        print $outfh "GOOD: $outinfo\n";
     298        $Ngood ++;
    262299        return;
    263300    }
     
    267304    if (($Nmain == 1) && ($Nback == 0)) {
    268305        print $outfh "SING: $outinfo\n";
     306        $Nsing ++;
    269307        return;
    270308    }
     
    274312    if (($Nmain == 0) && ($Nback == 1)) {
    275313        print $outfh "SBCK: $outinfo\n";
     314        $Nsbck ++;
    276315        return;
    277316    }
     
    281320    if (($Nmain > 1) && ($Nback == 0)) {
    282321        print $outfh "DUPS: $outinfo\n";
     322        $Ndups ++;
    283323        return;
    284324    }
     
    288328    if (($Nmain == 0) &&  ($Nback > 1)) {
    289329        print $outfh "XBCK: $outinfo\n";
     330        $Nxbck ++;
    290331        return;
    291332    }
     
    294335    if (($Nmain == 0) && ($Nback == 0) && $Ndead) {
    295336        print $outfh "DEAD: $outinfo\n";
     337        $Ndead ++;
    296338        return;
    297339    }
     
    299341    if (($Nmain == 0) && ($Nback == 0) && ($Ndead == 0)) {
    300342        print $outfh "GONE: $outinfo\n";
     343        $Ngone ++;
    301344        return;
    302345    }
     
    306349    if (($Nmain > 1) && ($Nback == 1)) {
    307350        print $outfh "CUL1: $outinfo\n";
     351        $Ncul1 ++;
    308352        return;
    309353    }
     
    313357    if (($Nback > 1) && ($Nmain == 1)) {
    314358        print $outfh "CUL2: $outinfo\n";
     359        $Ncul2 ++;
    315360        return;
    316361    }
     
    320365    if (($Nback > 1) && ($Nmain > 1)) {
    321366        print $outfh "CUL3: $outinfo\n";
     367        $Ncul3 ++;
    322368        return;
    323369    }
     
    335381    pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs;
    336382    pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;
    337     pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;
     383    pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage;
    338384    pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
    339385   
     
    363409    my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user );
    364410    my ( $gpcdb_name, $gpcdb_host, $gpcdb_port, $gpcdb_pass, $gpcdb_user );
     411    my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user );
    365412
    366413    if (-e $conffile) {
     
    380427            if ($_ =~ /GPC1_PASS /) { $gpcdb_pass = (split /\s+/,$_)[2]; }
    381428            if ($_ =~ /GPC1_PORT /) { $gpcdb_port = (split /\s+/,$_)[2]; }
     429
     430            if ($_ =~ /RAW_NAME /)  { $rawdb_name = (split /\s+/,$_)[2]; }
     431            if ($_ =~ /RAW_HOST /)  { $rawdb_host = (split /\s+/,$_)[2]; }
     432            if ($_ =~ /RAW_USER /)  { $rawdb_user = (split /\s+/,$_)[2]; }
     433            if ($_ =~ /RAW_PASS /)  { $rawdb_pass = (split /\s+/,$_)[2]; }
     434            if ($_ =~ /RAW_PORT /)  { $rawdb_port = (split /\s+/,$_)[2]; }
    382435        }
    383436        close(IN);
    384437        print STDERR  "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n";
    385438        print STDERR  "gpc1 dbh config: $gpcdb_name $gpcdb_host $gpcdb_port $gpcdb_user $gpcdb_pass\n";
     439        print STDERR  "raw  dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n";
    386440    }
    387441
     
    398452    pod2usage( -msg => "Cannot configure gpc1 database (dbpass)", -exitval => 2) unless defined $gpcdb_pass;
    399453
     454    pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name;
     455    pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host;
     456    pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user;
     457    pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port;
     458    pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass;
     459
    400460    my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host";
    401461    if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; }
     
    406466    my $gpc_dbh = DBI->connect($gpcdb_dsn, $gpcdb_user, $gpcdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
    407467
    408     return ($neb_dbh, $gpc_dbh);
     468    my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host";
     469    if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; }
     470    my $raw_dbh = DBI->connect($rawdb_dsn, $rawdb_user, $rawdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
     471
     472    return ($neb_dbh, $gpc_dbh, $raw_dbh);
    409473}
    410474
Note: See TracChangeset for help on using the changeset viewer.