IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30579


Ignore:
Timestamp:
Feb 11, 2011, 2:49:34 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20101205
Files:
1 deleted
55 edited
49 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/ippMonitor/Makefile.in

    r30446 r30579  
    4343$(DESTWWW)/ipp.stack.dat \
    4444$(DESTWWW)/ipp.stack.php \
     45$(DESTWWW)/ipp.dvodb.dat \
     46$(DESTWWW)/ipp.dvodb.php \
    4547$(DESTWWW)/phptest.php \
    4648$(DESTWWW)/site.php \
     
    5961$(DESTWWW)/show_and_delete_image.php \
    6062$(DESTWWW)/scatterPlot.php \
     63$(DESTWWW)/rawBurntoolState.php \
    6164$(DESTWWW)/plotHistogram.php \
    6265$(DESTWWW)/columns_in_db.php \
     
    6568$(DESTWWW)/warpProcessedExp.php \
    6669$(DESTWWW)/diskUsage.php \
    67 $(DESTWWW)/version.php
     70$(DESTWWW)/version.php
     71
     72
     73
    6874
    6975DEFSRC = \
     
    211217$(DESTWWW)/exposureStatus.php \
    212218$(DESTWWW)/mopsStatus.php \
    213 $(DESTWWW)/gpc1MysqlProcessList.php
     219$(DESTWWW)/gpc1MysqlProcessList.php \
     220$(DESTWWW)/minidvodbRun.php \
     221$(DESTWWW)/minidvodbCopy.php \
     222$(DESTWWW)/minidvodbProcessed.php \
     223$(DESTWWW)/addRunRun.php \
     224$(DESTWWW)/addRunProcessed.php
     225
     226
    214227
    215228PICTURES = \
  • branches/eam_branches/ipp-20101205/ippMonitor/def/diffProcessedSkyfile_Images.d

    r27892 r30579  
    1111# IMAGE VAR basename filerule camera class_id
    1212IMAGE JPEG2 $diffSkyfile.path_base PPSUB.OUTPUT.JPEG2 GPC1 NONE
     13
     14# if no query restrictions are supplied, we want to limit the query or it is extremely long running:
     15UNRESTRICTED AND diffRun.diff_id = 0
    1316
    1417# XXX need to get camera from lookup
  • branches/eam_branches/ipp-20101205/ippMonitor/def/magicProcessedMasks_Images.d

    r27892 r30579  
    1111ARGS  ARG7 magicRun.magic_id=$magicRun.magic_id
    1212ARGS  ARG7 camera=GPC1
    13 ARGS  ARG7 basename=$magicRun.workdir/$magicRun.exp_id/$magicRun.exp_id.mgc.$magicRun.magic_id.verify/$magicRun.exp_id
     13#ARGS  ARG7 basename=$magicRun.workdir/$magicRun.exp_id/$magicRun.exp_id.mgc.$magicRun.magic_id.verify/$magicRun.exp_id
     14ARGS  ARG7 basename=$magicMask.path_base
    1415
    1516#        field                   size  format  name           show     link to         extras
     
    2526FIELD    magicMask.fault,        5,   %d,     Fault
    2627FIELD    magicRun.workdir,       5,   %s,     Label, none
     28FIELD    magicMask.path_base,    5,   %s,     Label, none
    2729
    2830TAIL PHP insert_image ('MAGIC.ORIGINAL.PNG', 'width=49%');
  • branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_exposures.php

    r30446 r30579  
    1717else {$myMenu = "ipp.imfiles.dat";}
    1818
    19 menu($myMenu, 'Czartool on '.$lastUpdateTime, 'ipp.css', $ID['link'], $ID['proj']);
    20 
    2119$pass = $ID['pass'];
    2220$proj = $ID['proj'];
    2321$menu = $ID['menu'];
    2422
    25 $today = date("Y-m-d");
    26 
     23$date = $_POST['date'];
     24$survey = $_POST['survey'];
     25
     26// if no date chosen, use today
     27if ($date == "") $date = date("Y-m-d");
     28if ($survey == "") $survey = "";
     29
     30menu($myMenu, 'Exposure summary for '.$date , 'ipp.css', $ID['link'], $ID['proj']);
     31
     32// set up the form
     33echo "<form action=\"czartool_exposures.php\" method=\"POST\">\n";
     34
     35echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
     36echo "<input type=\"hidden\" name=\"proj\" value=\"$proj\">\n";
     37echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
     38
     39
     40echo "<form method=post action=czartool_exposures.php?pass=$pass&proj=$proj&date=$date&survey=$survey>";
     41echo "<p  align=\"center\"> Current status of all exposures taken on (UTC) <input type=text name=date value='$date'>";
     42echo " for survey <input type=text name=survey value='$survey'> (leave blank for all surveys)";
     43echo "<input type=submit value=Submit>";
    2744echo "</p>";
    28 echo "<p  align=\"center\"> Current status of all exposures taken $today UTC </p>";
    29 
    30 createTableForThisSurvey($gpc1db, $today, "");
     45
     46echo "</form>\n";
     47
     48createTableForThisSurvey($gpc1db, $date, $survey);
    3149
    3250menu_end();
     
    5876    $qry->fetchInto($count);
    5977
    60     if ($surveyStr == "") $surveyText = "all surveys"; 
     78    if ($surveyStr == "") $surveyText = "all surveys";
    6179    else $surveyText = "$surveyStr survey";
    6280
     
    83101    $ssDiffProduced = array(); getSSDiffProduced($db, $date, $surveyStr, &$ssDiffProduced);
    84102
    85     $class = "list";
    86     echo "<table class=$class >\n";
     103    // create table
     104    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
     105
     106    // table headers
    87107    echo "<tr><td></td>\n";
    88     write_header_cell($class, "");
    89     write_header_cell($class, "");
    90     write_header_cell($class, "");
    91     write_header_cell($class, "");
    92     write_header_cell($class, "Raw");
    93     write_header_cell($class, "Chip");
    94     write_header_cell($class, "Camera");
    95     write_header_cell($class, "Warp");
    96     write_header_cell($class, "Stack");
    97     write_header_cell($class, "Warp-Stack Diff");
    98     write_header_cell($class, "Warp-Warp1 Diff");
    99     write_header_cell($class, "Warp-Warp2 Diff");
    100     write_header_cell($class, "Stack-Stack Diff");
     108    echo "<th></th>";
     109    echo "<th></th>";
     110    echo "<th></th>";
     111    echo "<th></th>";
     112    echo "<th>Raw</th>";
     113    echo "<th>Chip</th>";
     114    echo "<th>Camera</th>";
     115    echo "<th>Warp</th>";
     116    echo "<th>Stack</th>";
     117    echo "<th>Warp-Stack Diff</th>";
     118    echo "<th>Warp-Warp1 Diff</th>";
     119    echo "<th>Warp-Warp2 Diff</th>";
     120    echo "<th>Stack-Stack Diff</th>";
    101121    echo "<tr><td></td>\n";
    102     write_header_cell($class, "Exp ID");
    103     write_header_cell($class, "Exp Name");
    104     write_header_cell($class, "Filter");
    105     write_header_cell($class, "Comment");
    106     write_header_cell($class, "state");
    107     write_header_cell($class, "state/dist?");
    108     write_header_cell($class, "state/dist?");
    109     write_header_cell($class, "state/dist?");
    110     write_header_cell($class, "total/dist");
    111     write_header_cell($class, "total/dist");
    112     write_header_cell($class, "total/dist");
    113     write_header_cell($class, "total/dist");
    114     write_header_cell($class, "total/dist");
     122    echo "<th>Exp ID</th>";
     123    echo "<th>Exp Name</th>";
     124    echo "<th>Filter</th>";
     125    echo "<th>Comment</th>";
     126    echo "<th>state</th>";
     127    echo "<th>state/dist?</th>";
     128    echo "<th>state/dist?</th>";
     129    echo "<th>state/dist?</th>";
     130    echo "<th>total/dist</th>";
     131    echo "<th>total/dist</th>";
     132    echo "<th>total/dist</th>";
     133    echo "<th>total/dist</th>";
     134    echo "<th>total/dist</th>";
    115135
    116136    $sql =
     
    147167        echo "<tr><td></td>\n";
    148168
     169        echo "<TD>$exp_id</td>";
     170        echo "<TD>$exp_name</td>";
     171        echo "<TD>$filter</td>";
     172        echo "<TD>$comment</td>";
     173        echo "<TD>$rawExp</td>";
     174
    149175        // chip
    150176        if (!$chipDist[$exp_id]) $chipDistStr = "N";
    151177        else $chipDistStr = $chipDist[$exp_id];
     178        echo "<TD>$chipState/$chipDistStr</td>";
    152179
    153180        // cam
    154181        if (!$camDist[$exp_id]) $camDistStr = "N";
    155182        else $camDistStr = $camDist[$exp_id];
     183        echo "<TD>$camState/$camDistStr</td>";
    156184
    157185        // warp
    158186        if (!$warpDist[$exp_id]) $warpDistStr = "N";
    159187        else $warpDistStr = $warpDist[$exp_id];
     188        echo "<TD>$warpState/$warpDistStr</td>";
    160189
    161190        // stack
    162         if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "";
     191        if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "&nbsp;";
    163192        else $stackDistStr = $stack_hash[$exp_id] . "/" . $stackDist[$exp_id];
     193        $color = getColour($stack_hash[$exp_id], $stackDist[$exp_id]);
     194        echo "<TD bgcolor=\"$color\" >$stackDistStr</td>";
    164195
    165196        // WS diff
    166         if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "";
     197        if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "&nbsp;";
    167198        else $wsDistStr = $wsDiffProduced[$exp_id] . "/" . $wsDiffDist[$exp_id];
     199        $color = getColour($wsDiffProduced[$exp_id], $wsDiffDist[$exp_id]);
     200        echo "<TD bgcolor=\"$color\" >$wsDistStr</td>";
    168201
    169202        // WW1 diff
    170         if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "";
     203        if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "&nbsp;";
    171204        else $ww1DistStr = $ww1DiffProduced[$exp_id] . "/" . $ww1DiffDist[$exp_id];
     205        $color = getColour($ww1DiffProduced[$exp_id], $ww1DiffDist[$exp_id]);
     206        echo "<TD bgcolor=\"$color\" >$ww1DistStr</td>";
    172207
    173208        // WW2 dist
    174         if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "";
     209        if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "&nbsp;";
    175210        else $ww2DistStr =  $ww2DiffProduced[$exp_id] . "/" . $ww2DiffDist[$exp_id];
     211        $color = getColour($ww2DiffProduced[$exp_id], $ww2DiffDist[$exp_id]);
     212        echo "<TD bgcolor=\"$color\" >$ww2DistStr</td>";
    176213
    177214        // SS dist
    178         if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "";
     215        if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "&nbsp;";
    179216        else $ssDistStr = $ssDiffProduced[$exp_id] . "/" . $ssDiffDist[$exp_id];
    180 
    181         write_table_cell($class, '%s', "", $exp_id);
    182         write_table_cell($class, '%s', "", $exp_name);
    183         write_table_cell($class, '%s', "", $filter);
    184         write_table_cell($class, '%s', "", $comment);
    185         write_table_cell($class, '%s', "", $rawExp);
    186         write_table_cell($class, '%s', "", "$chipState/$chipDistStr");
    187         write_table_cell($class, '%s', "", "$camState/$camDistStr");
    188         write_table_cell($class, '%s', "", "$warpState/$warpDistStr");
    189         write_table_cell($class, '%s', "", $stackDistStr);
    190         write_table_cell($class, '%s', "", $wsDistStr);
    191         write_table_cell($class, '%s', "", $ww1DistStr);
    192         write_table_cell($class, '%s', "", $ww2DistStr);
    193         write_table_cell($class, '%s', "", $ssDistStr);
     217        $color = getColour($ssDiffProduced[$exp_id], $ssDiffDist[$exp_id]);
     218        echo "<TD bgcolor=\"$color\" >$ssDistStr</td>";
    194219
    195220        echo "</tr>\n";
     
    199224}
    200225
     226###########################################################################
     227#
     228# Gets the right cell colour provided number created and distributed
     229#
     230###########################################################################
     231function getColour($created, $distributed) {
     232
     233    if ($distributed > 0 && $created > 0 && $distributed % $created != 0) return "red";
     234    return "";
     235}
    201236
    202237###########################################################################
  • branches/eam_branches/ipp-20101205/ippMonitor/raw/ipp.load.dat

    r28451 r30579  
    2323menulink  | menuselect   | link    | New Imfile                   | newImfile.php                   
    2424menulink  | menuselect   | link    | Raw Imfile                   | rawImfile.php                   
     25menutop   | menutop      | plain   | &nbsp;                       |
     26menulink  | menuselect   | link    | Burntool State               | rawBurntoolState.php                         
  • branches/eam_branches/ipp-20101205/ippMonitor/raw/ipp.menu.dat

    r28601 r30579  
    2323menutop   | menutop      | link    | Stack Steps                  | ipp.stack.php
    2424menutop   | menutop      | link    | Distribution                 | ipp.dist.php
     25menutop   | menutop      | link    | dvoDB                        | ipp.dvodb.php
    2526menutop   | menutop      | link    | Calibration                  | ipp.cal.php
    2627menutop   | menutop      | link    | Plots                        | ipp.plots.php
  • branches/eam_branches/ipp-20101205/ippMonitor/raw/ipp.php

    r28688 r30579  
    390390  if ($sortKey == "") {
    391391    if ($_SERVER[REQUEST_METHOD] == 'GET') {
    392       $sortKey = $_GET['rsort'];
     392      $sortVal = $_GET['rsort'];
    393393    } else {
    394       $sortKey = $_POST['rsort'];
     394      $sortVal = $_POST['rsort'];
    395395    }
    396396    if ($sortVal != "") {
     
    529529    $value = $_POST[$htmlkey];
    530530  }
     531  # a search restriction may include an SQL wild-card.  we have to mangle these so that the http
     532  # does not get converted to a special character
     533  $value = preg_replace ('|%|', '%25', $value);
    531534  if ($value != "") {
    532535    if ($line) {
  • branches/eam_branches/ipp-20101205/ippMonitor/scripts/generate

    r29485 r30579  
    5858        if ($key eq "FIELD") {
    5959            ($field, $width, $format, $name, $show, $link, $extras) = split (/,\s+/, $value, 7);
    60             if (! $name) { die "table $ARGV[0] missing required elements\n"; }
     60            if (! $name) { die "table $ARGV[0] missing required elements: $value\n"; }
    6161            if ($field =~ m|\S+\s+as\s+\S+|) {
    6262                ($fieldreal) = $field =~ m|\S+\s+as\s+(\S+)|;
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/chip_imfile.pl

    r30102 r30579  
    325325        # get the UNIX version of the (possible) neb: or path: filename
    326326        my $uriReal = $ipprc->file_resolve( $uri );
     327        &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
    327328
    328329        # funpack into the temp file.
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_advancerun.pl

    r28963 r30579  
    2323use PS::IPP::Config 1.01 qw( :standard );
    2424
    25 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2625
    2726use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    2928
    3029# Parse the command-line arguments
    31 my ($dist_id, $stage, $stage_id, $outdir, $clean);
     30my ($dist_id, $stage, $stage_id, $outdir, $clean, $camera);
    3231my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    3332
    3433GetOptions(
    35            'dist_id=s'  => \$dist_id,# Magic destreak run identifier
     34           'dist_id=s'      => \$dist_id,# Magic destreak run identifier
     35           'camera=s'       => \$camera,
    3636           'stage=s'        => \$stage,      # raw, chip, warp, or diff
    3737           'stage_id=s'     => \$stage_id,   # exp_id, chip_id, warp_id, or diff_id
     
    5353    defined $stage_id and
    5454    defined $outdir;
     55
     56my $ipprc = PS::IPP::Config->new($camera); # IPP configuration
    5557
    5658$ipprc->redirect_output($logfile) if $logfile;
     
    134136}
    135137
    136 # XXX should we create a file rule for this?
    137 my $dbinfo_file = "$outdir/dbinfo.$stage.$stage_id.mdc";
    138 
    139 {
    140     my $command = "$tool_cmd $exportarg -outfile $dbinfo_file";
     138
     139# work around the fact that $ipprc->file_create does not actually create a file on disk
     140# unless the scheme is nebulous
     141sub create_file {
     142    my $rule = shift;
     143    my $path_base = shift;
     144    my $ref = shift;
     145
     146    my $file;
     147
     148    my $error;
     149    $file = $ipprc->prepare_output($rule, $path_base, undef, 1, \$error)
     150        or &my_die("Unable to prepare outut for $rule", $dist_id, $PS_EXIT_SYS_ERROR);
     151
     152    my $scheme = file_scheme($file);
     153    $scheme = "" if !$scheme;
     154
     155    my $resolved;
     156    if ($scheme) {
     157        $ipprc->file_create($file)
     158            or &my_die("Unable to create $file", $dist_id, $PS_EXIT_SYS_ERROR);
     159
     160        $resolved = $ipprc->file_resolve($file)
     161            or &my_die("Unable to resolve $file", $dist_id, $PS_EXIT_SYS_ERROR);
     162
     163        if ($scheme eq 'neb') {
     164            &my_die("$resolved not found", $dist_id, $PS_EXIT_SYS_ERROR) unless ($resolved and -e $resolved);
     165    }
     166    } else {
     167        $resolved = $file;
     168    }
     169    $$ref = $resolved;
     170
     171    return $file
     172}
     173
     174my $dbinfo_root = "$outdir/dbinfo.$stage.$stage_id";
     175my $resolved;
     176my $dbinfo_file = create_file("DIST.OUTPUT.DBINFO", $dbinfo_root, \$resolved);
     177
     178{
     179    my $command = "$tool_cmd $exportarg -outfile $resolved";
    141180    $command .= " -clean" if ((defined $clean) and ($stage ne "raw"));
    142181    $command .= " -dbname $dbname" if defined $dbname;
     
    149188    }
    150189}
    151 my $dirinfo = "$outdir/dirinfo.$stage.$stage_id.mdc";
     190
     191my $dirinfo_root = "$outdir/dirinfo.$stage.$stage_id";
     192my $dirinfo = create_file("DIST.OUTPUT.DIRINFO", $dirinfo_root, \$resolved);
     193
    152194{
    153195    my $command = "$tool_cmd $list_mode";
     
    168210        &my_die("Unable to parse metadata list", $dist_id, $PS_EXIT_UNKNOWN_ERROR);
    169211
    170     open MANIFEST, ">$dirinfo" or
    171         &my_die("Unable to open dirinfo file $dirinfo",  $dist_id, $PS_EXIT_UNKNOWN_ERROR);
     212    open MANIFEST, ">$resolved" or
     213        &my_die("Unable to open dirinfo file $resolved",  $dist_id, $PS_EXIT_UNKNOWN_ERROR);
    172214
    173215    my $destdir;
     
    197239        &my_die("unable to find path",  $dist_id, $PS_EXIT_UNKNOWN_ERROR) if !$path;
    198240        my $component_dir = find_componentdir($destdir, $path);
    199 #        print MANIFEST "$component METADATA\n";
    200241        print MANIFEST "\t" , "$component", "\tSTR\t", $component_dir, "\n";
    201242    }
     
    217258    }
    218259}
    219 
    220260
    221261exit 0;
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_bundle.pl

    r30102 r30579  
    1616
    1717use IPC::Cmd 0.36 qw( can_run run );
    18 use File::Temp qw( tempfile );
     18use File::Temp qw( tempfile tempdir );
    1919use File::Basename qw( basename );
    2020use Digest::MD5::File qw( file_md5_hex );
     
    7171# Parse the command-line arguments
    7272my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean);
    73 my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
     73my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
    7474my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    7575
     
    8888           'magicked'       => \$magicked,   # magicked state for this component
    8989           'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
    90            'outdir=s'       => \$outdir,     # "directory" for outputs
     90           'outroot=s'      => \$outroot,    # outroot
    9191           'prefix=s'       => \$prefix,     # "prefix" to apply to filenames
    9292           'clean'          => \$clean,      # create clean distribution
     
    9999
    100100pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outdir",
     101pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot",
    102102           -exitval => 3) unless
    103103    defined $camera and
     
    106106    defined $component and
    107107    defined $path_base and
    108     defined $outdir;
     108    defined $outroot;
    109109
    110110$ipprc->redirect_output($logfile) if $logfile;
     
    116116$ipprc->define_camera($camera);
    117117
    118 # create the output directories if it is not a nebulous path and it doesn't exist
    119 if (index($outdir, "neb://") != 0) {
    120     if (! -e $outdir ) {
    121         my $code = system "mkdir -p $outdir";
    122         &my_die("cannot create output directory $outdir", $component,
    123                 $code >> 8) if $code;
    124     }
    125 }
     118$ipprc->outroot_prepare($outroot);
    126119
    127120# Get the list of data products for this component
     
    138131# set up directory for temporary files
    139132
    140 my $tmpdir  = "$outdir/tmpdir.$component.$$";
    141 if (-e $tmpdir) {
    142     if (-d $tmpdir) {
    143         my $rc = system "rm -r $tmpdir";
    144         &my_die("cannot rm $tmpdir return code: $rc", $component, $PS_EXIT_UNKNOWN_ERROR) if $rc;
    145     } else {
    146         unlink $tmpdir or &my_die("cannot delete $tmpdir", $component, $PS_EXIT_UNKNOWN_ERROR);
    147     }
    148 }
    149 mkdir $tmpdir or &my_die("cannot create temporary directory $tmpdir", $component,
    150                        $PS_EXIT_UNKNOWN_ERROR);
     133my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR");
     134$temproot = "/tmp" if !defined $temproot;
     135&my_die("directory for TEMP.DIR $temproot does not exist", $component, $PS_EXIT_CONFIG_ERROR) if ! -e $temproot;
     136
     137my $tmpdir  = tempdir("$temproot/dist.XXXX", CLEANUP => !$save_temps);
    151138
    152139#
     
    349336if ($num_files) {
    350337    # create the tarfile
    351     # XXX TODO: create a file rule for the tar file name
    352     my $tbase = basename($path_base);
    353     $tbase .= ".$component" if $component;
    354     $file_name = ($prefix ? $prefix : "") . "$tbase.tgz";
    355     my $tarfile = "$outdir/$file_name";
     338#    my $tbase = basename($path_base);
     339#    $tbase .= ".$component" if $component;
     340#    $file_name = ($prefix ? $prefix : "") . "$tbase.tgz";
     341    my $error;
     342    my $output_tarfile;
     343    my $rule;
     344    if ($stage eq 'chip' or $stage eq 'chip_bg' or $stage eq 'raw') {
     345        $rule = "DIST.OUTPUT.CHIP.BUNDLE";
     346    } else {
     347        $rule = "DIST.OUTPUT.BUNDLE";
     348    }
     349    $output_tarfile = $ipprc->prepare_output($rule, $outroot, $component, 1, \$error)
     350            or &my_die("Failed to prepare output tarfile: $error", $component, $error);
     351    $file_name = basename($output_tarfile);
     352
     353
     354    my $scheme = file_scheme($output_tarfile);
     355
     356    my $tarfile;
     357    if ($scheme) {
     358        $ipprc->file_create($output_tarfile)
     359            or &my_die("Failed to create $output_tarfile: $error", $component, $error);
     360        $tarfile = $ipprc->file_resolve($output_tarfile);
     361
     362        if ($scheme eq 'neb') {
     363            &my_die("output file $output_tarfile not found", $component, $PS_EXIT_SYS_ERROR)
     364                unless ($tarfile and -e $tarfile);
     365        }
     366    } else {
     367        # no scheme the filename and the resolved filename are the same
     368        $tarfile = $output_tarfile;
     369    }
    356370
    357371    my $command = "tar -C $tmpdir --owner=ipp --group=users -czhf $tarfile .";
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_component.pl

    r27718 r30579  
    2121use PS::IPP::Metadata::Config;
    2222use PS::IPP::Metadata::List qw( parse_md_list );
    23 
    2423use PS::IPP::Config 1.01 qw( :standard );
    25 
    26 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2724
    2825use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7774    defined $outdir;
    7875
     76my $ipprc = PS::IPP::Config->new($camera); # IPP configuration
    7977$ipprc->redirect_output($logfile) if $logfile;
     78
     79my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR");
     80
     81$temproot = "/tmp" if !defined $temproot;
    8082
    8183if (($stage eq 'raw') and !$clean and !defined $chip_path_base) {
     
    8587my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    8688
    87 my ($rf, $rf_name) = tempfile("/tmp/bundleresults.$dist_id.$component.XXXX", UNLINK => !$save_temps);
     89my ($rf, $rf_name) = tempfile("$temproot/bundleresults.$dist_id.$component.XXXX", UNLINK => !$save_temps);
    8890close $rf;
     91
     92my $basename = basename($path_base);
     93my $outroot = "$outdir/$basename";
    8994
    9095my ($file_name, $bytes, $md5sum);
     
    9297    my $command = "$dist_make_bundle --camera $camera --stage $stage --stage_id $stage_id";
    9398    $command .= " --results_file $rf_name";
    94     $command .= " --component $component --path_base $path_base --outdir $outdir";
     99    $command .= " --component $component --path_base $path_base --outroot $outroot";
    95100    $command .= " --chip_path_base $chip_path_base" if $chip_path_base;
    96101    $command .= " --state $run_state" if defined $run_state;
     
    136141    &my_die("undefined file md5sum from dist_bundle.pl", $dist_id, $component, $outdir, $PS_EXIT_PROG_ERROR) unless defined $md5sum;
    137142}
     143
    138144
    139145{
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_defineruns.pl

    r29068 r30579  
    4242
    4343# Parse the command-line arguments
    44 my ($stage, $stage_limit, $dist_root, $no_magic);
     44my ($stage, $stage_limit, $dist_root, $workdir, $no_magic);
    4545my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    4646my @labels;
     
    4949           'stage=s'        => \$stage,      # stage to queue
    5050           'label=s'        => \@labels,     # labels
     51           'workdir=s'      => \$workdir,     # workdir
    5152           'stage_limit=s'  => \$stage_limit,# maximum number of runs queued for each stage
    52            'dist_root=s'    => \$dist_root,  # root of distribution work area
     53#           'dist_root=s'    => \$dist_root,  # root of distribution work area
    5354           'no_magic'       => \$no_magic,   # queue runs without requiring magic (for testing only)
    5455           'dbname=s'       => \$dbname,     # Database name
     
    6667$ipprc->redirect_output($logfile) if $logfile;
    6768
    68 if (!$dist_root) {
    69     $dist_root = metadataLookupStr($ipprc->{_siteConfig}, "DISTRIBUTION_ROOT");
    70     &my_die("failed to find DISTRIBUTION_ROOT in site configuration", $PS_EXIT_CONFIG_ERROR) if !$dist_root;
     69if (!$workdir) {
     70    print "workdir not supplied will use DISTRIBUTION_ROOT\n";
     71    # old method where we set workdir based on a config file
     72    if (!$dist_root) {
     73        $dist_root = metadataLookupStr($ipprc->{_siteConfig}, "DISTRIBUTION_ROOT");
     74        &my_die("failed to find DISTRIBUTION_ROOT in site configuration", $PS_EXIT_CONFIG_ERROR) if !$dist_root;
     75    }
     76
     77    my ($day, $month, $year) = (gmtime)[3,4,5];
     78    my $datestr = sprintf "%04d%02d%02d", $year+1900, $month + 1, $day;
     79
     80    $workdir = $dist_root . "/$datestr";
     81
     82    print "workdir is $workdir\n";
    7183}
    72 
    73 my ($day, $month, $year) = (gmtime)[3,4,5];
    74 my $datestr = sprintf "%04d%02d%02d", $year+1900, $month + 1, $day;
    75 
    76 my $workdir = "$dist_root/$datestr";
    77 
    78 print "workdir is $workdir\n";
    7984
    8085# if stage is not supplied as an argument, loop over all stages
     
    9095        my $command = "$disttool -definebyquery -stage $stage -workdir $workdir -label $label";
    9196        $command .= " -no_magic" if $no_magic;
    92         $command .= " -dry_run" if $no_update;
     97        $command .= " -pretend" if $no_update;
    9398        $command .= " -limit $stage_limit" if $stage_limit;
    9499        $command .= " -set_label $label";
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/dist_make_fileset.pl

    r28963 r30579  
    9696# make sure that the database info file for this run exists
    9797my $dbinfo_file = "$dist_dir/dbinfo.$stage.$stage_id.mdc";
    98 if (! -e "$dbinfo_file" ) {
     98if (! $ipprc->file_exists($dbinfo_file) ) {
    9999    &my_die("dbinfo file for dist run $dbinfo_file not found", $dist_id, $dest_id, $PS_EXIT_UNKNOWN_ERROR);
    100100}
     
    103103# make sure that the dirinfo file for this run exists
    104104my $dirinfo_file = "$dist_dir/dirinfo.$stage.$stage_id.mdc";
    105 if (! -e "$dirinfo_file" ) {
     105if (!$ipprc->file_exists($dirinfo_file)) {
    106106    &my_die("dirinfo file for dist run $dirinfo_file not found", $dist_id, $dest_id, $PS_EXIT_UNKNOWN_ERROR);
    107107}
     
    277277    $command .= " -dbname $dbname" if $dbname;
    278278
    279     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    280         run(command => $command, verbose => $verbose);
    281     unless ($success) {
    282         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    283         print STDERR "Unable to perform $command error_code: $error_code\n";
     279    if (!$no_update) {
     280        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     281            run(command => $command, verbose => $verbose);
     282        unless ($success) {
     283            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     284            print STDERR "Unable to perform $command error_code: $error_code\n";
     285        }
     286    } else {
     287        print STDERR "skipping $command\n";
    284288    }
    285289    exit $fault;
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/ipp_cleanup.pl

    r30446 r30579  
    207207            }
    208208
    209             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    210             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    211             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    212             $command .= " -dbname $dbname" if defined $dbname;
    213             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    214                 run(command => $command, verbose => $verbose);
    215             unless ($success) {
    216                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    217                 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
    218             }
     209            set_destreak_goto_cleaned();
    219210
    220211        } else {
     
    324315        }
    325316
    326         # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    327         my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    328         $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    329         $command .= " -dbname $dbname" if defined $dbname;
    330         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    331             run(command => $command, verbose => $verbose);
    332         unless ($success) {
    333             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    334             &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
    335         }
     317        set_destreak_goto_cleaned();
    336318
    337319    } else {
     
    469451            }
    470452
    471             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    472             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    473             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    474             $command .= " -dbname $dbname" if defined $dbname;
    475             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    476                 run(command => $command, verbose => $verbose);
    477             unless ($success) {
    478                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    479                 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
    480             }
     453            set_destreak_goto_cleaned();
    481454
    482455         } else {
     
    603576            }
    604577
    605             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    606             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    607             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    608             $command .= " -dbname $dbname" if defined $dbname;
    609             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    610                 run(command => $command, verbose => $verbose);
    611             unless ($success) {
    612                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    613                 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
    614             }
     578            set_destreak_goto_cleaned();
    615579
    616580        } else {
     
    759723            }
    760724
    761             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    762             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    763             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    764             $command .= " -dbname $dbname" if defined $dbname;
    765             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    766                 run(command => $command, verbose => $verbose);
    767             unless ($success) {
    768                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    769                 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
    770             }
     725            set_destreak_goto_cleaned();
    771726
    772727        } else {
     
    20622017}
    20632018
     2019# this gets set to 1 the first time we set the corresponding destreak run to be cleaned
     2020my $ds_done = 0;
     2021sub set_destreak_goto_cleaned {
     2022
     2023    return if $ds_done;
     2024
     2025    # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     2026    my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     2027    my $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
     2028    $command .= " -dbname $dbname" if defined $dbname;
     2029    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2030        run(command => $command, verbose => $verbose);
     2031    unless ($success) {
     2032        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2033            &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     2034    }
     2035    $ds_done = 1;
     2036}
     2037
    20642038# XXX we currently do not set the error state in the db on my_die
    20652039sub my_die
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/magic_destreak_cleanup.pl

    r30446 r30579  
    159159        my $component = $comp->{component};
    160160        my $backup_path_base = $comp->{backup_path_base};
    161         my $recovery_path_base = $comp->{recovery_path_base};
    162161        my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom);
    163162        my ($rimage, $rmask, $rch_mask, $rweight, $rsources, $rastrom);
     
    197196                $bsources = $ipprc->filename("PSPHOT.OUTPUT", $backup_path_base, $component);
    198197            }
    199             if ($recovery_path_base) {
    200                 $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component);
    201 
    202                 if ($dynamicMasks) {
    203                     my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
    204                     # This is kludgey but correct
    205                     $rmask = dirname($recovery_path_base) . "/" . basename($mask);
    206                     $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
    207                 } else {
    208                     $rmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
    209                 }
    210                 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component);
    211             }
    212198        } elsif ($stage eq "camera") {
    213199            if ($backup_path_base) {
     
    221207                $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base);
    222208            }
    223             if ($recovery_path_base) {
    224                 $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
    225                 $rmask   = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base);
    226                 $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
    227                 $rsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $recovery_path_base);
    228             }
    229209        } elsif ($stage eq "diff") {
    230210            my $name = "PPSUB.OUTPUT";
     211            if ($backup_path_base) {
     212                $bimage  = $ipprc->filename($name, $backup_path_base);
     213                $bmask   = $ipprc->filename("$name.MASK", $backup_path_base);
     214                $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base);
     215                # bills 2011-01-24
     216                # don't clean up the uncensored Diff sources file
     217                # $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
     218            }
     219        }
     220
     221        delete_files($bimage, $bmask, $bweight, $bsources, $bastrom, $bch_mask, $rch_mask);
     222
     223        if ($stage eq "diff" and $warp_warp) {
     224            my $name = "PPSUB.INVERSE";
    231225            if ($backup_path_base) {
    232226                $bimage  = $ipprc->filename($name, $backup_path_base);
     
    237231                # $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
    238232            }
    239             if ($recovery_path_base) {
    240                 $rimage  = $ipprc->filename($name, $recovery_path_base);
    241                 $rmask   = $ipprc->filename("$name.MASK", $recovery_path_base);
    242                 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base);
    243                 $rsources = $ipprc->filename("$name.SOURCES", $recovery_path_base);
    244             }
    245         }
    246 
    247         delete_files($rimage, $rmask, $rweight, $rsources, $rastrom, $bimage, $bmask, $bweight, $bsources, $bastrom, $bch_mask, $rch_mask);
    248 
    249         if ($stage eq "diff" and $warp_warp) {
    250             my $name = "PPSUB.INVERSE";
    251             if ($backup_path_base) {
    252                 $bimage  = $ipprc->filename($name, $backup_path_base);
    253                 $bmask   = $ipprc->filename("$name.MASK", $backup_path_base);
    254                 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base);
    255                 # bills 2011-01-24
    256                 # don't clean up the uncensored sources file
    257                 # $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
    258             }
    259             if ($recovery_path_base) {
    260                 $rimage  = $ipprc->filename($name, $recovery_path_base);
    261                 $rmask   = $ipprc->filename("$name.MASK", $recovery_path_base);
    262                 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base);
    263                 $rsources = $ipprc->filename("$name.SOURCES", $recovery_path_base);
    264             }
    265             # undef is not necessary, it's just to keep the lists in the same order.
    266             delete_files($rimage, $rmask, $rweight, $rsources, undef, $bimage, $bmask, $bweight, $bsources);
     233            delete_files($bimage, $bmask, $bweight, $bsources);
    267234        }
    268235        my $command = "$magicdstool -tocleanedfile -magic_ds_id $magic_ds_id -component $component";
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/nightly_science.pl

    r30446 r30579  
    12661266}
    12671267
     1268sub multi_date_verify_uniqueness_diff {
     1269    my $warp_id_1 = shift;
     1270    my $warp_id_2 = shift;
     1271    my $date = shift;
     1272    my $target = shift;
     1273
     1274    my $db = init_gpc_db();
     1275    $date =~ s/-//g;
     1276    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
     1277
     1278    my $count = 0;
     1279   
     1280    my $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where (label = '$label' OR label = 'goto_cleaned') AND warp1 = $warp_id_1 AND warp2 = $warp_id_2";
     1281    my $data_ref = $db->selectall_arrayref( $sth );
     1282    $count += $#{ $data_ref } + 1;
     1283
     1284    $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where (label = '$label' OR label = 'goto_cleaned') AND warp1 = $warp_id_2 AND warp2 = $warp_id_1";
     1285    $data_ref = $db->selectall_arrayref( $sth );
     1286    $count += $#{ $data_ref } + 1;
     1287
     1288    return($count);
     1289}
     1290
    12681291sub pre_diff_queue {
    12691292    my $date = shift;
     
    13751398        $metadata_out{nsDiffState} = 'DIFFING';
    13761399    }
    1377 
     1400    if ($metadata_out{nsDiffState} eq 'FINISHED_DIFFS') {
     1401        foreach my $target (sort (keys %science_config)) {
     1402            if ($science_config{$target}{DIFFABLE} == 1) {
     1403                foreach my $filter (@filter_list) {
     1404                    multi_date_diff_queue($date,$target,$filter,$pretend);
     1405                }
     1406            }
     1407        }
     1408    }
    13781409#     if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) {
    13791410#       $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     
    15111542
    15121543}
     1544
     1545sub multi_date_diff_queue {
     1546    my $date = shift;
     1547    my $target = shift;
     1548    my $filter = shift;
     1549    my $pretend = shift;
     1550    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
     1551
     1552    my $db = init_gpc_db();
     1553
     1554    my $obj_sth = "select DISTINCT rawExp.object from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";
     1555    $obj_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND rawExp.filter = '$filter' ORDER BY rawExp.object";
     1556
     1557    my $object_ref = $db->selectall_arrayref( $obj_sth );
     1558
     1559    my $Npotential = 0;
     1560    my $Nqueued = 0;
     1561   
     1562    foreach my $object_row (@{ $object_ref }) {
     1563        my $this_object = shift @{ $object_row };
     1564#       my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";
     1565#       $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
     1566#       $input_sth .= " ORDER BY dateobs ";
     1567       
     1568        my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM ";
     1569        $input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
     1570        $input_sth .=   " WHERE warpRun.label = '$label' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
     1571        $input_sth .=   " ORDER BY dateobs ";
     1572
     1573        my $warps = $db->selectall_arrayref( $input_sth );
     1574
     1575        # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra.
     1576        my %comment_hash = ();
     1577        foreach my $this_warp (@{ $warps }) {
     1578            my $this_comment = ${ $this_warp }[3];
     1579            my $this_exp_id  = ${ $this_warp }[0];
     1580            $comment_hash{$this_comment} = $this_exp_id;
     1581        }
     1582       
     1583        if (($#{ $warps } + 1) % 2 != 0) {
     1584            print STDERR "md_diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } ";
     1585            if ($#{ $warps} + 1 == 1) {
     1586                print STDERR ": I can do no diffs with only one exposure.\n";
     1587                next;
     1588            }
     1589            else {
     1590                print STDERR ": I should declare an exposure to be faulty.\n";
     1591                my @keep_warps = ();
     1592#               print "@{ $warps }\n";
     1593                foreach my $this_warp (@{ $warps }) {
     1594                    my $this_comment = ${ $this_warp }[3];
     1595                    my $this_exp_id  = ${ $this_warp }[0];
     1596                    if ($comment_hash{$this_comment} == $this_exp_id) {
     1597                        push @keep_warps, $this_warp;
     1598                    }
     1599                    else {
     1600                        print STDERR "md_diff_queue: excluding $this_exp_id for $this_object\n";
     1601                    }
     1602                }
     1603                @{ $warps } = @keep_warps;
     1604#               print "@{ $warps }\n";
     1605            }
     1606        }
     1607       
     1608        while ($#{ $warps } > -1) {
     1609            my $input_warp = shift @{ $warps };
     1610            my $input_exp_id = ${ $input_warp }[0];
     1611            my $input_comment = ${ $input_warp }[3];
     1612
     1613           
     1614            my $template_warp = shift @{ $warps };
     1615
     1616            my $template_exp_id = ${ $template_warp }[0];
     1617           
     1618            my $input_warp_id = ${ $input_warp }[1];
     1619            my $template_warp_id = ${ $template_warp }[1];
     1620
     1621            my $input_warp_state = ${ $input_warp }[4];
     1622            my $template_warp_state = ${ $template_warp }[4];
     1623           
     1624            unless(defined($template_warp)&& defined($template_exp_id)) {
     1625                print STDERR "md_diff received an undef! $input_exp_id $input_comment $this_object T: $template_warp V: @$template_warp\n";
     1626                next;
     1627            }
     1628            $Npotential++;
     1629           
     1630            unless (defined($input_warp_id) && defined($template_warp_id) &&
     1631                    ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) {
     1632                print STDERR "md_Diff for this $date $target $input_exp_id ($input_warp_id $input_warp_state) $template_exp_id ($template_warp_id $template_warp_state) not fully processed\n";
     1633                next;
     1634            }
     1635
     1636            if (multi_date_verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) {
     1637                $Nqueued++;
     1638                print STDERR "md_Diffs already queued for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n";
     1639                next;
     1640            }
     1641
     1642            my $new_data_group = "${data_group}.multi";
     1643            my $cmd = "$difftool -dbname $dbname  -definewarpwarp ";
     1644            $cmd .= "-input_label $label  -template_label $label ";
     1645            $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting.
     1646            $cmd .= "-set_workdir $workdir  -set_dist_group $dist_group  -set_data_group $new_data_group ";
     1647            $cmd .= " -simple  -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id ";
     1648#               $cmd .= " -pretend ";
     1649            if (defined($pretend)) {
     1650                $cmd .= ' -pretend ';
     1651            }
     1652            if ($debug == 1) {
     1653                $cmd .= ' -pretend ';
     1654                print STDERR "md_Diffs would like to queue for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n";
     1655                print STDERR "md_diff_queue: $cmd\n";
     1656                print STDERR " $input_warp_id $template_warp_id\n";
     1657            }
     1658           
     1659            if (($debug == 0)&&(!defined($pretend))) {
     1660                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1661                    run ( command => $cmd, verbose => $verbose );
     1662                unless ($success) {
     1663                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1664                    &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     1665                }
     1666                $Nqueued++;
     1667            }
     1668        }
     1669    }
     1670    $metadata_out{nsDiffPotential} += $Npotential;
     1671    $metadata_out{nsDiffQueued}    += $Nqueued;
     1672#      if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) {
     1673#       $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     1674#      }       
     1675
     1676}
    15131677           
    15141678
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/register_exp.pl

    r30446 r30579  
    255255        if (exists($nightlyscience_config{$target}{OBSMODE})) {
    256256            $possible++;
    257             if ($obsmode =~ /$nightlyscience_config{$target}{OBSMODE}/) {
     257            if ($obsmode =~ /^$nightlyscience_config{$target}{OBSMODE}$/) {
    258258                $match++;
    259259            }
     
    261261        if (exists($nightlyscience_config{$target}{OBJECT})) {
    262262            $possible++;
    263             if ($object =~ /$nightlyscience_config{$target}{OBJECT}/) {
     263            if ($object =~ /^$nightlyscience_config{$target}{OBJECT}$/) {
    264264                $match++;
    265265            }
     
    267267        if (exists($nightlyscience_config{$target}{COMMENT})) {
    268268            $possible++;
    269             if ($comment =~ /$nightlyscience_config{$target}{COMMENT}/) {
     269            if ($comment =~ /^$nightlyscience_config{$target}{COMMENT}$/) {
    270270                $match++;
    271271            }
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/warp_skycell.pl

    r27754 r30579  
    7171my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7272
    73 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR );
    74 $logDest .= ".update" if ($run_state eq 'update');
     73my ($logDest, $traceDest);
     74if ($run_state eq 'new') {
     75    $logDest = prepare_output("LOG.EXP", $outroot, $skycell_id, 0);
     76    $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
     77} elsif ($run_state eq 'update')  {
     78    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 0);
     79    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, $skycell_id, 1);
     80} else {
     81    &my_die( "invalid run_state: $run_state", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR );
     82}
     83
     84my $neb;
     85my $scheme = file_scheme($outroot);
     86if ($scheme and $scheme eq 'neb') {
     87    $neb = $ipprc->nebulous();
     88}
    7589
    7690$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ) if $redirect;
     
    117131    unless ($success) {
    118132        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    119         &my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $error_code);
     133        &my_die("Unable to perform ppConfigDump: $error_code", $warp_id, $skycell_id, $tess_dir, $error_code);
    120134    }
    121135    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    122         &my_die("Unable to parse metadata config doc", $warp_id, $PS_EXIT_PROG_ERROR);
     136        &my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR);
    123137    $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE');
    124138}
     
    141155
    142156
    143 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outroot, $skycell_id );
    144 my $outputMask = $ipprc->filename("PSWARP.OUTPUT.MASK", $outroot, $skycell_id);
    145 my $outputWeight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $outroot, $skycell_id);
    146 my $outputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $outroot, $skycell_id);
    147 my $outputPSF = $ipprc->filename("PSPHOT.PSF.SKY.SAVE", $outroot);
    148 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outroot, $skycell_id );
    149 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outroot, $skycell_id );
    150 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot, $skycell_id );
    151 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot, $skycell_id);
    152 my $configuration =  $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id);
    153 
    154 if ($run_state eq 'update') {
    155     $traceDest .= ".update";
    156     $outputStats .= ".update";
    157 }
    158 
    159 my $skyFile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
     157my $outputImage = prepare_output ("PSWARP.OUTPUT", $outroot, $skycell_id, 1);
     158my $outputMask = prepare_output ("PSWARP.OUTPUT.MASK", $outroot, $skycell_id, 1);
     159my $outputWeight = prepare_output ("PSWARP.OUTPUT.VARIANCE", $outroot, $skycell_id, 1);
     160my $outputSources = prepare_output ("PSWARP.OUTPUT.SOURCES", $outroot, $skycell_id, 1);
     161my $outputPSF = prepare_output ("PSPHOT.PSF.SKY.SAVE", $outroot, 1);
     162my $outputBin1 = prepare_output ("PSWARP.BIN1", $outroot, $skycell_id, 1);
     163my $outputBin2 = prepare_output ("PSWARP.BIN2", $outroot, $skycell_id, 1);
     164my $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1);
     165my $configuration;
     166
     167my $dump_config = 1;
     168if ($run_state eq 'new') {
     169    $configuration =  prepare_output ("PSWARP.CONFIG", $outroot, $skycell_id, 1);
     170} else {
     171    $configuration =  $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id) or
     172        &my_die("Missing entry from camera config PSWARP.CONFIG", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR);
     173    if ($ipprc->file_exists($configuration)) {
     174        $dump_config = 0;
     175    } else {
     176        print STDERR "WARNING: Config dump file $configuration is missing. Using current recipes and file rules.\n";
     177
     178        # XXX: should we create a new config dump file?
     179        # I vote yes but only if we can distingusing between temporarily unavailable and GONE.
     180        my $gone = 0;
     181        if (storage_object_exists($configuration, \$gone)) {
     182            if ($gone) {
     183                $configuration = prepare_output('PSWARP.CONFIG', $outroot, $skycell_id, 1);
     184                # if we dump the config we need to insure that the config dump represents
     185                # the full processing
     186            } else {
     187                # file is temporarily not available. Don't dump config.
     188                $dump_config = 0;
     189            }
     190        }
     191    }
     192}
     193
     194
     195my $skyFile = prepare_output ("SKYCELL.TEMPLATE", $outroot, $skycell_id, 1);
    160196$ipprc->skycell_file( $tess_dir, $skycell_id, $skyFile, $verbose ) or &my_die("Unable to generate template skycell", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR);
    161197## XXX this seems to have insufficient error checking: dvoImageExtract can fail to write and still return a valid exit status
     
    171207foreach my $imfile (@$imfiles) {
    172208    my $image = $imfile->{uri}; # Image name
    173     my $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name
     209    my $weight = $ipprc->filename ("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id}); # Mask name
    174210
    175211    my $mask;                   # Mask name
    176212    if ($dynamicMasks) {
    177         $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
     213        $mask = $ipprc->filename ("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
    178214    } else {
    179         $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $imfile->{chip_path_base}, $imfile->{class_id});
     215        $mask = $ipprc->filename ("PPIMAGE.CHIP.MASK", $imfile->{chip_path_base}, $imfile->{class_id});
    180216    }
    181217
     
    186222    # Astrometry file: astrometry is done at the camera stage, and always results in a MEF file
    187223    # XXX allow an option to use the image header astrometry?
    188     my $astrom = $ipprc->filename($astromSource, $imfile->{cam_path_base});
     224    my $astrom = $ipprc->filename ($astromSource, $imfile->{cam_path_base});
    189225
    190226    &my_die("Couldn't find input file: $astrom", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless defined $astrom and $ipprc->file_exists($astrom);
     
    245281        $do_stats = 1;
    246282    } else {
    247         #$command .= " -ipprc $configuration";
    248         my $resolved = $ipprc->file_resolve($configuration);
    249         $command .= " -ipprc $resolved";
     283        $command .= " -ipprc $configuration";
    250284    }
    251285    if ($do_stats) {
     
    263297    if ($do_stats) {
    264298        # Check first for the stats file
     299        check_output($outputStats, 0);
    265300        my $outputStatsReal = $ipprc->file_resolve($outputStats);
    266         &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
     301#        &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
    267302        &my_die("Stats file has zero size: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless -s $outputStatsReal;
    268303
    269         # measure chip stats
     304        # measure skycell stats
    270305        $command = "$ppStatsFromMetadata $outputStatsReal - WARP_SKYCELL";
    271306        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    283318
    284319        if (!$quality) {
    285             &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
    286             &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    287             &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
    288             &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    289             &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) if metadataLookupBool($recipe, 'PSF') and not $ipprc->file_exists($outputPSF);
    290             if ($run_state eq 'new') {
    291                 &my_die("Couldn't find expected output file: $configuration", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
     320        #    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
     321        #    &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
     322        #    &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
     323        #    &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
     324        #    &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) if metadataLookupBool($recipe, 'PSF') and not $ipprc->file_exists($outputPSF);
     325
     326            check_output($outputImage, 0);
     327            check_output($outputMask, 0);
     328            check_output($outputWeight, 0);
     329            check_output($outputSources, 1);
     330            check_output($outputPSF, 1) if metadataLookupBool($recipe, 'PSF')  ;
     331            if ($dump_config)  {
     332                check_output($configuration, 1);
     333#                &my_die("Couldn't find expected output file: $configuration", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
    292334            }
    293335        }
     
    335377    }
    336378}
     379
     380exit 0;
     381
     382# Prepare to write to an output file
     383#   Lookup the filename in the rules.
     384#   Make sure that if file exists and is a nebulous file that there is only one instance
     385#   Deal with files that have been lost.
     386sub prepare_output
     387{
     388    my $filerule = shift;
     389    my $outroot  = shift;
     390    my $skycell_id = shift;
     391    my $delete = shift;
     392    $delete = 0 if !defined $delete;
     393
     394    my $error;
     395    my $output = $ipprc->prepare_output($filerule, $outroot, $skycell_id, $delete, \$error)
     396                    or &my_die("failed to prepare output file for: $filerule", $warp_id, $skycell_id, $tess_dir, $error);
     397    return $output;
     398}
     399
     400sub check_output
     401{
     402    my $file = shift;
     403    my $replicate = shift;
     404
     405    if (!defined $file) {
     406        return;
     407    }
     408
     409    &my_die("Couldn't find expected output file: $file",  $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     410
     411    if ($replicate and $neb) {
     412        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR);
     413    }
     414}
     415
     416# subroutine to check the status of a nebulous file. Used to distinguish between a storage object that
     417# does not exist and one that all of the instances have been lost.
     418# XXXX This should be implemented properly in Nebulous
     419# For now uses Bill's script 'whichnode' which queries the nebulous database directly
     420
     421my $whichnode;
     422sub storage_object_exists
     423{
     424    return 0 if !$neb;
     425
     426    my $file = shift;
     427    my $ref_all_gone = shift;
     428
     429    my $exists = $neb->storage_object_exists($file);
     430    if (!$exists) {
     431        return 0;
     432    }
     433
     434    if (!$whichnode) {
     435        $whichnode = can_run('whichnode') or
     436            &my_die("Can't find whichnode",  $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR);
     437    }
     438
     439    my $command = "$whichnode $file";
     440
     441    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     442        run(command => $command, verbose => $verbose);
     443    unless ($success) {
     444        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     445        &my_die("Unable to perform whichnode: $error_code", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR);
     446    }
     447
     448    my @lines = split "\n", (join "", @$stdout_buf);
     449
     450    if (scalar @lines == 0) {
     451        # no output the file is really and truely gone
     452        # XXX: this is now caught above
     453        print STDERR "storage object for $file does not exist\n";
     454        return 0;
     455    }
     456
     457    my $numGone = 0;
     458    my $numNotGone = 0;
     459    foreach my $line (@lines) {
     460        chomp $line;
     461
     462        # output lines are either
     463        #   "volume available"
     464        # or
     465        #   "volume not available"
     466
     467        my ($volume, $answer, undef) = split " ", $line;
     468        # our hack is if the volume has an X in the name it's gone
     469        if ($volume =~ /X/) {
     470            print STDERR "$file is on $volume which is gone\n";
     471            $numGone++;
     472        } elsif ($answer eq 'available') {
     473            $numNotGone++;
     474        } elsif ($answer eq 'not') {
     475            print STDERR "$file is on $volume which is not available\n";
     476            $numNotGone++;
     477        } else {
     478            print STDERR "unexpected output from whichnode: $line\n";
     479        }
     480    }
     481    # if there are any instances that are not on a gone volume set all_gone to 0
     482    if ($numNotGone == 0 and $numGone > 0) {
     483        $$ref_all_gone = 1;
     484    } else {
     485        $$ref_all_gone = 0;
     486    }
     487
     488    # storage object exists so return true
     489    return 1;
     490}
     491
    337492
    338493sub my_die
  • branches/eam_branches/ipp-20101205/ippTasks/diskbalance.pro

    r29631 r30579  
    194194    book getword balancePending $pageName source_name      -var SOURCE
    195195    book getword balancePending $pageName destination_name -var DESTINATION
    196    
     196    book getword balancePending $pageName destination_host -var DEST_HOST
    197197    # Fix this with multihost restriction when possible.
    198     set.host.for.balance $DESTINATION
     198    set.host.for.balance $DEST_HOST
    199199
    200200    stdout NULL
  • branches/eam_branches/ipp-20101205/ippTasks/dist.pro

    r30446 r30579  
    9595end
    9696
     97# This is now only used if we are not using a nebulous outroot
    9798macro get.host.for.component
    9899    if ($0 != 3)
     
    122123end
    123124
     125# This is now only used if we are not using a nebulous outroot
    124126macro set.dist.workdir.by.component
    125127    if ($0 != 5)
     
    139141    book getword ipphosts distribution count -var count
    140142    if ("$count" == "NULL")
    141         echo "ERROR: distributin hosts list is empty"
     143        echo "ERROR: distribution hosts list is empty"
    142144        break
    143145    end
     
    289291    end
    290292
    291 
    292     set.dist.workdir.by.component $DIST_STAGE_ID $COMPONENT $OUTDIR_TEMPLATE OUTDIR
    293     if ("$OUTDIR" == "NULL")
    294         echo ERROR failed to set workdir for $COMPONENT
    295         break
    296     end
    297 
    298293    substr $COMPONENT 0 3 COMP_HEAD
    299294    if ("$COMP_HEAD" == "sky")
    300295        set.host.for.skycell $COMPONENT
     296        set.workdir.by.skycell $COMPONENT $OUTDIR_TEMPLATE $default_host OUTDIR
    301297    else
    302         # assume component is a class_id, if not we will default to anyhost
     298        # assume component is a class_id, if  it is not we will default to
     299        # host "anyhost"
     300        # and volume "any"
    303301        set.host.for.camera $CAMERA $COMPONENT
     302        set.workdir.by.camera $CAMERA $COMPONENT $OUTDIR_TEMPLATE $default_host OUTDIR
     303    end
     304
     305    if ("$OUTDIR" == "NULL")
     306        echo ERROR failed to set workdir for $COMPONENT
     307        break
    304308    end
    305309
    306310    sprintf logfile "%s/dist.%s.%s.log" $OUTDIR $DIST_ID $COMPONENT
    307 #    stdout $logfile
    308 #    stderr $logfile
    309311
    310312    $run = dist_component.pl --dist_id $DIST_ID --camera $CAMERA --stage $DIST_STAGE --stage_id $DIST_STAGE_ID --component $COMPONENT --path_base $PATH_BASE --chip_path_base $CHIP_PATH_BASE --state $STATE --data_state $DATA_STATE $EXTRA_ARGS --outdir $OUTDIR --logfile $logfile
     
    401403    book getpage distToAdvance 0 -var pageName -key pantaskState INIT
    402404    if ("$pageName" == "NULL") break
     405
     406    # XXX the sql for disttool -toadvance does not include the camera:
     407    # hack around this for now
     408    $CAMERA = GPC1
    403409
    404410    book setword distToAdvance $pageName pantaskState RUN
     
    414420    end
    415421
    416     host anyhost
    417 
    418     # using $DIST_ID as the "component" works fine here since we only look
    419     # at the last two digits. But make sure that there 2 digits
    420     $fake_component = $STAGE_ID + 10
    421     set.dist.workdir.by.component $fake_component "exposure" $OUTDIR_TEMPLATE OUTDIR
     422    substr $OUTDIR_TEMPLATE 0 3 SCHEME
     423    if ("$SCHEME" == "neb")
     424        # XXX This does not work if workdir is not in nebulous
     425        # and $default_host == "any" because /data/any does not exist
     426        # use "dummy" as component. Result will be 'any'
     427        # set.workdir.by.camera $CAMERA dummy $OUTDIR_TEMPLATE $default_host OUTDIR
     428        set.workdir.by.camera GPC1 dummy $OUTDIR_TEMPLATE $default_host OUTDIR
     429    else
     430        # using $DIST_ID as the "component" works fine here since we only look
     431        # at the last two digits. But make sure that there 2 digits
     432        $fake_component = $STAGE_ID + 10
     433        set.dist.workdir.by.component $fake_component "exposure" $OUTDIR_TEMPLATE OUTDIR
     434    end
     435 
    422436    if ("$OUTDIR" == "NULL")
    423437        echo ERROR failed to set workdir for $DIST_ID
    424438        break
    425439    end
     440    host anyhost
    426441
    427442    sprintf logfile "%s/dist.advance.%s.log" $OUTDIR $DIST_ID
    428 #    stdout $logfile
    429 #    stderr $logfile
    430 
    431     $run = dist_advancerun.pl --dist_id $DIST_ID --stage $STAGE --stage_id $STAGE_ID --outdir $OUTDIR $EXTRA_ARGS --logfile $logfile
     443
     444    $run = dist_advancerun.pl --dist_id $DIST_ID --stage $STAGE --stage_id $STAGE_ID --camera $CAMERA --outdir $OUTDIR $EXTRA_ARGS --logfile $logfile
    432445    add_standard_args run
    433446
  • branches/eam_branches/ipp-20101205/ippTasks/pstamp.pro

    r30446 r30579  
    1818$pstampStopFaulted_DB = 0
    1919
     20# give up on dependents with fault_count >= $PSTAMP_MAX_FAULT_COUNT
     21$PSTAMP_MAX_FAULT_COUNT = 5
     22macro set.max.fault.count
     23    $PSTAMP_MAX_FAULT_COUNT = $1
     24end
     25macro get.max.fault.count
     26    echo maximum fault count: $PSTAMP_MAX_FAULT_COUNT
     27end
     28$POLL_DEP = 500
     29
     30macro set.dependent.poll
     31    $POLL_DEP = $1
     32end
     33macro get.dependent.poll
     34    echo dependent poll limit: $POLL_DEP
     35end
     36
    2037# set PS_DBSERVER if postage stamp database host is not the same as the value for DBSERVER in site.config
    2138# warning: no quotes around the two words. That causes the variable to get passed to pstamptool as one word
     
    137154    end
    138155end
     156
    139157macro pstamp.find.on
    140158    task pstamp.request.find
     
    143161end
    144162macro pstamp.find.off
    145     task pstamp.request.find.load
    146         active false
     163    task pstamp.request.find
     164        active false
     165    end
     166end
     167
     168macro pstamp.dependent.on
     169    task pstamp.dependent.load
     170        active true
     171    end
     172    task pstamp.dependent.run
     173        active true
     174    end
     175end
     176macro pstamp.dependent.off
     177    task pstamp.dependent.load
     178        active false
     179    end
     180    task pstamp.dependent.run
     181        active false
     182    end
     183end
     184
     185
     186macro pstamp.status.on
     187    task pstamp.save.status
     188        active true
     189    end
     190end
     191macro pstamp.status.off
     192    task pstamp.save.status
     193        active false
     194    end
     195end
     196
     197macro pstamp.status.set.exec
     198    task pstamp.save.status
     199        periods -exec $1
    147200    end
    148201end
     
    509562            echo pstamp.job.run task.exit $JOB_ID status: $JOB_STATUS
    510563        end
    511         showcommand failure
     564#        showcommand failure
    512565        process_exit pstampJob $options:0 $JOB_STATUS
    513566    end
     
    593646        add_poll_args run
    594647        add_poll_labels run
    595         command $run
     648        command $run -limit $POLL_DEP
    596649    end
    597650
     
    648701        book getword pstampDependent $pageName outdir     -var OUTDIR
    649702        book getword pstampDependent $pageName need_magic -var NEED_MAGIC
     703        book getword pstampDependent $pageName fault_count -var FAULT_COUNT
    650704        book getword pstampDependent $pageName dbname     -var DBNAME
    651705
     
    666720        stderr $MYLOGFILE
    667721
    668         $run = pstamp_checkdependent.pl --dep_id $DEP_ID --stage_id $STAGE_ID --stage $STAGE --component $COMPONENT --imagedb $IMAGEDB --rlabel $RLABEL $NEED_MAGIC
     722        $run = pstamp_checkdependent.pl --dep_id $DEP_ID --stage_id $STAGE_ID --stage $STAGE --component $COMPONENT --imagedb $IMAGEDB --rlabel $RLABEL $NEED_MAGIC --fault_count $FAULT_COUNT --max_fault_count $PSTAMP_MAX_FAULT_COUNT
    669723
    670724        add_standard_args run
     
    689743            echo pstamp.job.run task.exit $DEP_ID status: $JOB_STATUS
    690744        end
    691         showcommand failure
     745#        showcommand failure
    692746        process_exit pstampDependent $options:0 $JOB_STATUS
    693747    end
     
    905959    end
    906960end
     961
     962task pstamp.save.status
     963    host        local
     964
     965    periods     -poll $LOADPOLL
     966    periods     -exec 90
     967    periods     -timeout 20
     968    npending    1
     969
     970    task.exec
     971        stdout NULL
     972        stderr $LOGSUBDIR/pstamp.save.status.log
     973
     974        $run = pstamp_save_server_status.pl --update-link
     975        command $run
     976    end
     977
     978    task.exit $EXIT_SUCCESS
     979        # echo nothing to do
     980    end
     981
     982    task.exit   default
     983        showcommand failure
     984    end
     985
     986    task.exit   crash
     987        showcommand crash
     988    end
     989
     990    task.exit   timeout
     991        showcommand timeout
     992    end
     993end
  • branches/eam_branches/ipp-20101205/ippTasks/rcserver.pro

    r28792 r30579  
    4040    active false
    4141  end
    42   task rcserver.revert
    43     active false
    44   end
    4542end
    4643
     
    4845  task rcserver.revert
    4946    active true
     47  end
     48end
     49
     50macro rcserver.revert.off
     51  task rcserver.revert
     52    active false
    5053  end
    5154end
     
    136139
    137140    sprintf logfile "%s/makefs.%s.%s.log" $DIST_DIR $DIST_ID $DEST_ID
    138     stdout $logfile
    139     stderr $logfile
    140141
    141142    book setword rcPendingFS $pageName pantaskState RUN
    142143
    143     $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID --data_group $DATA_GROUP --filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME  --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR
     144    $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID --data_group $DATA_GROUP --filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME  --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR --logfile $logfile
    144145
    145146    add_standard_args run
  • branches/eam_branches/ipp-20101205/ippTasks/register.pro

    r30446 r30579  
    105105
    106106macro register.add.date
    107   if ($0 != 2)
    108     echo "USAGE: register.add.date (YYYY-MM-DD)"
     107  if ($0 != 4)
     108    echo "USAGE: register.add.date (YYYY-MM-DD) (DBNAME) (VALID_BURNTOOL)"
    109109    break
    110110  end
     
    112112   book newpage regDates $1
    113113   book setword regDates $1 nsState NEW
    114    book setword regDates $1 dbname $DB:0
    115 end
    116 
    117 
    118 $valid_burntool_value = 14
     114   book setword regDates $1 dbname $2
     115   book setword regDates $1 valid_burntool $3
     116end
     117
     118
     119# $valid_burntool_value = 14
    119120$sunrise = 17:30:00
    120121$sunset  = 03:30:00
     
    565566     if ($Npages == 0)
    566567       $today = `date -u +%Y-%m-%d`
     568       $dbname = $DB:0
     569       $valid_burntool = 14
    567570     else
    568571       book getpage regDates $reg_datePAGE -var today
     572       book getword regDates $today dbname -var dbname
     573       book getword regDates $today valid_burntool -var valid_burntool
    569574       $reg_datePAGE ++
    570575       if ($reg_datePAGE >= $Npages) set reg_datePAGE = 0
     
    577582    $dateobs_begin = $today\T$sunset
    578583    $dateobs_end   = $today\T$sunrise
    579     $run = $run -dateobs_begin $dateobs_begin -dateobs_end $dateobs_end -valid_burntool $valid_burntool_value
    580     if ($DB:n == 0)
    581       option DEFAULT
    582     else
    583       # save the DB name for the exit tasks
    584       option $DB:$regPendingBurntoolImfile_DB
    585       $run = $run -dbname $DB:$regPendingBurntoolImfile_DB
    586       $regPendingBurntoolImfile_DB ++
    587       if ($regPendingBurntoolImfile_DB >= $DB:n) set regPendingBurntoolImfile_DB = 0
    588     end
     584    $run = $run -dateobs_begin $dateobs_begin -dateobs_end $dateobs_end -valid_burntool $valid_burntool
     585    $run = $run -dbname $dbname
     586    option $dbname
     587#     if ($DB:n == 0)
     588#       option DEFAULT
     589#     else
     590#       # save the DB name for the exit tasks
     591#       option $DB:$regPendingBurntoolImfile_DB
     592#       $run = $run -dbname $DB:$regPendingBurntoolImfile_DB
     593#       if ("$dbname" != "$DB:$regPendingBurntoolImfile_DB")
     594#         break
     595#       end
     596#       $regPendingBurntoolImfile_DB ++
     597#       if ($regPendingBurntoolImfile_DB >= $DB:n) set regPendingBurntoolImfile_DB = 0
     598#     end
    589599
    590600#    echo $run
     
    697707    book setword regDates $today nsState NEW
    698708    book setword regDates $today dbname $DB:0
     709    book setword regDates $today valid_burntool 14
    699710
    700711    command true
  • branches/eam_branches/ipp-20101205/ippTasks/survey.pro

    r30446 r30579  
    287287# user functions to manipulate dist labels
    288288macro survey.add.dist
    289   if ($0 != 2)
    290     echo "USAGE: survey.add.dist (label)"
     289  if ($0 != 3)
     290    echo "USAGE: survey.add.dist (label) (workdir)"
    291291    break
    292292  end
    293293  book newpage SURVEY_DIST $1
     294  book setword SURVEY_DIST $1 WORKDIR $2
    294295  book setword SURVEY_DIST $1 STATE PENDING
    295296end
     
    896897    end
    897898
     899    book getword SURVEY_DIST $label WORKDIR -var workdir_base
     900    $year = `date +%Y`
     901    $month = `date +%m`
     902    $day = `date +%d`
     903    $workdir = $workdir_base/$label/$year/$month/$day
     904
    898905    book setword SURVEY_DIST $label STATE DONE
    899906 
    900907    # note workdir is set by the script based on site.config
    901     $run = dist_defineruns.pl --label $label
     908    $run = dist_defineruns.pl --label $label --workdir $workdir
    902909
    903910    if ($DB:n == 0)
     
    908915    end
    909916   
    910 #    echo $run
     917    if ($VERBOSE > 1 )
     918        echo $run
     919    end
    911920    command $run
    912921  end
     
    11261135    end
    11271136   
    1128     echo $run
     1137    # echo $run
    11291138
    11301139    command $run
  • branches/eam_branches/ipp-20101205/ippToPsps/perl/ippToPsps/Gpc1Db.pm

    r29234 r30579  
    3434
    3535    return 1;
     36}
     37
     38###########################################################################
     39#
     40# Returns a count of warps thyat contributed to the stack with this stack ID
     41#
     42###########################################################################
     43sub countContributingWarpsToStack {
     44        my ($self, $stackId) = @_;
     45
     46          my $query = $self->{_db}->prepare(<<SQL);
     47          SELECT COUNT(DISTINCT warp_id)
     48              FROM stackInputSkyfile
     49              WHERE stack_id = $stackId
     50SQL
     51
     52    $query->execute;
     53    return scalar $query->fetchrow_array();
    3654}
    3755
  • branches/eam_branches/ipp-20101205/ippTools/share/camtool_find_pendingimfile.sql

  • branches/eam_branches/ipp-20101205/ippTools/share/chiptool_processedimfile.sql

    r29199 r30579  
    2929    rawImfile.magicked AS raw_magicked,
    3030    rawImfile.burntool_state,
     31    IFNULL(magicDSRun.magic_ds_id, 0) AS magic_ds_id,
    3132    magicDSRun.state AS dsRun_state,
    32     IFNULL(magicDSRun.magic_ds_id, 0) AS magic_ds_id
     33    magicDSFile.data_state AS dsFile_data_state
    3334FROM chipRun
    3435JOIN chipImfile
     
    4344LEFT JOIN magicDSRun
    4445    ON stage_id = chip_id AND stage = 'chip' AND magicDSRun.re_place AND magicDSRun.state != 'drop'
     46LEFT JOIN magicDSFile ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id AND chipProcessedImfile.class_id = magicDSFile.component
  • branches/eam_branches/ipp-20101205/ippTools/share/difftool_pendingcleanupskyfile.sql

    r24186 r30579  
    99    USING(diff_id)
    1010WHERE
    11    ((diffRun.state = 'goto_cleaned'  AND diffSkyfile.data_state = 'full')
     11   ((diffRun.state = 'goto_cleaned'  AND (diffSkyfile.data_state = 'full' OR diffSkyfile.data_state = 'update'))
    1212    OR
    1313    (diffRun.state = 'goto_scrubbed' AND diffSkyfile.data_state != 'scrubbed')
  • branches/eam_branches/ipp-20101205/ippTools/share/difftool_setskyfiletoupdate.sql

    r29568 r30579  
    11UPDATE diffRun
    22    JOIN diffSkyfile USING(diff_id)
    3     LEFT JOIN magicDSRun ON (stage_id = diff_id AND stage = 'diff')
    4     LEFT JOIN magicDSFile ON (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
    5                               AND component = skycell_id)
    63SET diffRun.state = 'update',
    7     diffSkyfile.data_state = 'update'
     4    diffSkyfile.data_state = 'update',
     5    diffSkyfile.fault = 0
    86    -- set hook %s
    97WHERE diff_id = %lld
    108    AND (diffRun.state = 'cleaned' OR diffRun.state = 'update')
    11     AND (diffSkyfile.data_state = 'cleaned')
     9    AND (diffSkyfile.data_state = 'cleaned' OR diffSkyfile.data_state = 'update')
  • branches/eam_branches/ipp-20101205/ippTools/share/magicdstool_setfiletoupdate.sql

    r29561 r30579  
    77WHERE magic_ds_id = %lld
    88    AND (magicDSRun.state = 'cleaned' OR magicDSRun.state = 'update')
    9     AND (magicDSFile.data_state = 'cleaned')
     9    AND (magicDSFile.data_state = 'cleaned' OR magicDSFile.data_state ='update')
  • branches/eam_branches/ipp-20101205/ippTools/share/pxadmin_create_tables.sql

  • branches/eam_branches/ipp-20101205/ippTools/share/regtool_pendingexp.sql

    r30102 r30579  
    4848          GROUP BY newExp.exp_id
    4949          HAVING SUM(rawImfile.fault) = 0
     50          LIMIT 256
    5051         ) AS RAWEXPOSURES
    5152         USING (exp_id)
  • branches/eam_branches/ipp-20101205/ippTools/share/warptool_change_skyfile_data_state.sql

    r26567 r30579  
    11-- handle changes in warpSkyfile.data_state.
    22-- Used for the modes tofullskyfile, tocleanedskyfile and topurgedskyfile
    3 -- args are new data_state, string for magic hook, warp_id, skycell_id and current expected state for warpRun
     3-- arguments are are new data_state, string for magic hook, warp_id, skycell_id
    44UPDATE warpSkyfile
    55JOIN warpRun USING(warp_id)
  • branches/eam_branches/ipp-20101205/ippTools/share/warptool_scmap.sql

    r29349 r30579  
    1212    IFNULL(magicDSRun.magic_ds_id, 0) AS magic_ds_id,
    1313    IFNULL(magicDSRun.state, 0) AS dsRun_state,
     14    IFNULL(magicDSFile.data_state, 0) AS dsFile_data_state,
    1415    IFNULL(magicDSFile.fault, 0) as dsFile_fault
    1516FROM warpRun
  • branches/eam_branches/ipp-20101205/ippTools/share/warptool_setskyfiletoupdate.sql

    r29568 r30579  
    11UPDATE warpRun
    22    JOIN warpSkyfile USING(warp_id)
    3     LEFT JOIN magicDSRun ON (stage_id = warp_id AND stage = 'warp')
    4     LEFT JOIN magicDSFile ON (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
    5                               AND component = skycell_id)
    63SET warpRun.state = 'update',
    7     warpSkyfile.data_state = 'update'
     4    warpSkyfile.data_state = 'update',
     5    warpSkyfile.fault = 0
    86    -- set hook %s
    97WHERE warp_id = %lld
    108    AND (warpRun.state = 'cleaned' OR warpRun.state = 'update')
    11     AND (warpSkyfile.data_state = 'cleaned')
     9    AND (warpSkyfile.data_state = 'cleaned' OR warpSkyfile.data_state = 'update')
  • branches/eam_branches/ipp-20101205/ippTools/share/warptool_towarped.sql

    r29171 r30579  
    1111    exp_tag,
    1212    workdir,
     13    label,
    1314    magicked,
    1415    path_base,
     
    2324        warpRun.state,
    2425        warpRun.reduction,
     26        warpRun.label,
    2527        camRun.cam_id,
    2628        rawExp.camera,
     
    7678        warpRun.state,
    7779        warpRun.reduction,
     80        warpRun.label,
    7881        camRun.cam_id,
    7982        rawExp.camera,
  • branches/eam_branches/ipp-20101205/ippTools/src

  • branches/eam_branches/ipp-20101205/ippTools/src/chiptool.c

    r30102 r30579  
    838838    PXOPT_COPY_S16(config->args, where, "-fault", "chipProcessedImfile.fault", "==");
    839839
     840    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     841
    840842    if (!psListLength(where->list)
    841843        && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    874876    }
    875877    psFree(query);
     878
     879    if (!fault) {
     880        // If fault has not been supplied, don't revert update faults with the magic value
     881        // We don't do this for new runs because then they would never complete
     882        // quality should be used to drop bad components
     883        psStringAppend(&query_update, " AND (chipProcessedImfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
     884    }
    876885    if (!p_psDBRunQuery(config->dbh, query_update)) {
    877886        psError(PS_ERR_UNKNOWN, false, "database error");
     
    19191928    }
    19201929
     1930    // we do not update components with the magic fault value. They are non-updateable
     1931    psStringAppend(&query, " AND (chipProcessedImfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
     1932
    19211933    if (!p_psDBRunQueryF(config->dbh, query, setHook, chip_id)) {
    19221934        psError(PS_ERR_UNKNOWN, false, "database error");
  • branches/eam_branches/ipp-20101205/ippTools/src/difftool.c

    r30530 r30579  
    917917    PXOPT_COPY_S16(config->args, where, "-fault",     "fault", "==");
    918918
     919    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     920
    919921    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
    920922        psFree(where);
     
    950952        psLogMsg("difftool", PS_LOG_INFO, "Deleted %" PRIu64 " rows", psDBAffectedRows(config->dbh));
    951953
     954        if (!fault) {
     955            // If fault has not been supplied, don't revert update faults with the magic value
     956            // We don't do this for new runs because then they would never complete
     957            // quality should be used to drop bad components
     958            psStringAppend(&query_updated, " AND (diffSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
     959        }
    952960        if (!p_psDBRunQuery(config->dbh, query_updated)) {
    953961            psError(PS_ERR_UNKNOWN, false, "database error");
     
    32013209        psStringAppend(&query, " AND (diffSkyfile.skycell_id = '%s')", skycell_id);
    32023210    }
     3211    // we do not update components with the magic fault value. They are non-updateable
     3212    // (But can be recovered with "difftool -revertwarped -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
     3213    psStringAppend(&query, " AND (diffSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
    32033214
    32043215    if (!p_psDBRunQueryF(config->dbh, query, setHook, diff_id)) {
  • branches/eam_branches/ipp-20101205/ippTools/src/disttool.c

    r30446 r30579  
    11851185    PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "==");
    11861186    PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
    1187     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1187    pxAddLabelSearchArgs(config, where, "-label", "label", "==");
    11881188    PXOPT_COPY_S16(config->args, where, "-fault", "rcDSFileset.fault", "==");
    11891189
  • branches/eam_branches/ipp-20101205/ippTools/src/disttoolConfig.c

    r29067 r30579  
    197197    psMetadataAddS64(revertfilesetArgs, PS_LIST_TAIL, "-stage_id",0, "define stage_id", 0);
    198198    psMetadataAddStr(revertfilesetArgs, PS_LIST_TAIL, "-state",   0, "define state", NULL);
    199     psMetadataAddStr(revertfilesetArgs, PS_LIST_TAIL, "-label",   0, "define label", NULL);
     199    psMetadataAddStr(revertfilesetArgs, PS_LIST_TAIL, "-label",   PS_META_DUPLICATE_OK, "define label", NULL);
    200200    psMetadataAddS16(revertfilesetArgs, PS_LIST_TAIL, "-fault",   0, "define fault code", 0);
    201201    psMetadataAddBool(revertfilesetArgs, PS_LIST_TAIL, "-all",    0, "revert all faulted runs", NULL);
  • branches/eam_branches/ipp-20101205/ippTools/src/dqstatstool.c

    r28427 r30579  
    9292  }
    9393  else {
    94     psStringAppend(&query, " AND (invalid IS NULL OR invalid = 1) ");
     94    psStringAppend(&query, " AND (warp_id IS NOT NULL AND invalid IS NULL) ");
    9595  }
    9696
     
    402402
    403403    if (psMetadataLookupStr(&status,enginedef,"COLNAME")&&
    404         isfinite(psMetadataLookupF32(&status,enginedef,"MINIMUM"))&&
    405         isfinite(psMetadataLookupF32(&status,enginedef,"MAXIMUM"))) {
     404        (strcmp(psMetadataLookupStr(&status,enginedef,"RULETYPE"),"STRICT") == 0)&&
     405        (isfinite(psMetadataLookupF32(&status,enginedef,"MINIMUM"))&&
     406         isfinite(psMetadataLookupF32(&status,enginedef,"MAXIMUM")))) {
    406407      psArrayAdd(decisionRules,decisionRules->n,enginedef);
     408    }
     409    else if (psMetadataLookupStr(&status,enginedef,"COLNAME")&&
     410             (strcmp(psMetadataLookupStr(&status,enginedef,"RULETYPE"),"CDF") == 0)&&
     411             (isfinite(psMetadataLookupF32(&status,enginedef,"CDF00"))&&
     412              isfinite(psMetadataLookupF32(&status,enginedef,"CDF50"))&&
     413              isfinite(psMetadataLookupF32(&status,enginedef,"CDF100")))) {
     414      psArrayAdd(decisionRules,decisionRules->n, enginedef);
     415    }
     416    else if (strcmp(psMetadataLookupStr(&status,enginedef,"RULETYPE"),"UNUSED") == 0) {
    407417    }
    408418    else {
     
    637647    // Calculate if this exposure was "good" or not.
    638648    bool accept = true;
     649    psF32 quality = 1.0;
    639650    for (long j = 0; j < decisionRules->n; j++) {
    640651      psMetadata *rule = decisionRules->data[j];
     
    644655        psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find column name");
    645656        return(false);
    646       }     
    647       psF32 min_value  = psMetadataLookupF32(&status,rule,"MINIMUM");
    648       if (!status) {
    649         psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find min value for %s",colname);
    650         return(false);
    651       }     
    652       psF32 max_value  = psMetadataLookupF32(&status,rule,"MAXIMUM");
    653       if (!status) {
    654         psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find max value for %s",colname);
    655         return(false);
    656       }
    657       psString filter = psMetadataLookupStr(&status,rule,"FILTER");
    658       if (!status) {
    659         status = true;
    660       }
    661       if (filter) {
    662         psString imfilter = psMetadataLookupStr(&status,tableRow,"FILTER");
    663         if (strcmp(filter,imfilter) != 0) {
    664           continue;
    665         }
    666657      }
    667658      // Not happy with this being set to a F32. Can this ever be something else?
    668659      psF32 value      = psMetadataLookupF32(&status,tableRow,colname);
    669660      if (!status) {
    670         psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find column %s (%f %f %f) in compare with rule.",colname,min_value,max_value,value);
     661        psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find column %s (%f) in compare with rule.",
     662                colname,value);
    671663        psFree(colNames);
    672664        psFree(colTypes);
     
    677669        return(false);
    678670      }
    679       if ((value > max_value)||(value < min_value)) {
    680         accept = false;
    681       }     
     671      psString filter = psMetadataLookupStr(&status,rule,"FILTER");
     672      if (!status) {
     673        status = true;
     674      }
     675      if (filter) {
     676        psString imfilter = psMetadataLookupStr(&status,tableRow,"FILTER");
     677        if (strcmp(filter,imfilter) != 0) {
     678          continue;
     679        }
     680      }
     681     
     682      if (strcmp(psMetadataLookupStr(&status,rule,"RULETYPE"),"STRICT") == 0) {
     683        psF32 min_value  = psMetadataLookupF32(&status,rule,"MINIMUM");
     684        if (!status) {
     685          psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find min value for %s",colname);
     686          return(false);
     687        }     
     688        psF32 max_value  = psMetadataLookupF32(&status,rule,"MAXIMUM");
     689        if (!status) {
     690          psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find max value for %s",colname);
     691          return(false);
     692        }
     693
     694        if ((value > max_value)||(value < min_value)) {
     695          accept = false;
     696        }
     697      } // End STRICT min/max rule parsing
     698      else if (strcmp(psMetadataLookupStr(&status,rule,"RULETYPE"),"CDF") == 0) {
     699        // I'm just going to implement a quick linear interpolation over the points that exist.
     700        psF32 min_value,max_value = 99;
     701        psF32 min_cdf = 0.0,max_cdf = 1.0;
     702        psF32 cdf;
     703        psF32 try[22] = {0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,
     704                         0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,0.99,1.00};
     705        int i;
     706        int done = 0;
     707        status = true;
     708        min_value = psMetadataLookupF32(&status,rule,"CDF00");
     709        min_cdf   = 0.0;
     710        if (!isfinite(value)) {
     711          quality = 0.0;
     712          continue;
     713        }
     714        if (!status) {
     715          status = true;
     716          psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find CDF00 value for %s",colname);
     717        }
     718        if (value < min_value) {
     719          if (quality > min_cdf) {
     720            quality = 0.0;
     721            continue;
     722          }
     723        }
     724
     725        for (i = 1; i < 22; i++) {
     726          psString label = psStringCopy("");
     727          psStringAppend(&label,"CDF%02d",(int) (100 * try[i]));
     728         
     729          max_value = psMetadataLookupF32(&status,rule,label);
     730          max_cdf   = try[i];
     731          if (!status) {
     732            status = true;
     733            psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find %s value for %s",label,colname);
     734          }
     735          if ((value < max_value)&&(value > min_value)) {
     736            cdf = ((value - min_value) * max_cdf + (max_value - value) * min_cdf) / (max_value - min_value);
     737            //      fprintf(stderr,"value: %f %f %f %f %f %f %d %d %f\n",value,quality,min_cdf,min_value,max_cdf,max_value, value < max_value, value > min_value,cdf);
     738            if (quality > cdf) {
     739              quality = cdf;
     740              done = 1;
     741              i = 25;
     742            }
     743          }
     744          min_value = max_value;
     745          min_cdf = max_cdf;
     746        }
     747        if (done) {
     748          continue;
     749        }
     750        // Reached end of array without finding the value;
     751        if (value > min_value) {
     752          if (quality > min_cdf) {
     753            quality = 1.0;
     754          }
     755        }
     756
     757
     758      } // End CDF rule parsing
    682759    }
    683760    bool success;
     
    695772      return(false);
    696773    }
     774    success = psMetadataAddF32(tableRow,PS_LIST_TAIL,"QUALITY",0,"",quality);
     775    if (!success) {
     776      psError(PS_ERR_UNKNOWN,false, "Error adding exposure quality to fits table row.");
     777      psFree(colNames);
     778      psFree(colTypes);
     779      psFree(contents);
     780      psFree(query);
     781      psFree(outTable);
     782      psFree(statsoutput);
     783      psFree(statIter);
     784      psFree(tableRow);
     785      return(false);
     786    }
    697787
    698788    // Add the row to the table array.
  • branches/eam_branches/ipp-20101205/ippTools/src/magicdstool.c

    r30446 r30579  
    11121112
    11131113    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
     1114    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    11141115
    11151116    psString queryFile = NULL;
     1117    bool stateIsUpdate = false;
    11161118    if (state) {
    11171119        if (! strcmp(state, "new") || !strcmp(state, "goto_restored")) {
     
    11191121        } else if (!strcmp(state, "update")) {
    11201122            queryFile = "magicdstool_revertupdated.sql";
     1123            stateIsUpdate = true;
    11211124        } else {
    11221125            psError(PXTOOLS_ERR_SYS, true, "%s is not a valid value for state", state);
     
    11411144    }
    11421145    psFree(where);
     1146
     1147    if (stateIsUpdate && !fault) {
     1148        // If fault has not been supplied, don't revert update faults with
     1149        // the magic "do not update" value
     1150        // We don't do this for new runs because then they would never complete
     1151        // quality should be used to drop bad components
     1152        psStringAppend(&query, " AND magicDSFile.fault != %d", PXTOOL_DO_NOT_REVERT_FAULT);
     1153    }
    11431154
    11441155    if (!p_psDBRunQuery(config->dbh, query)) {
     
    17441755    }
    17451756
     1757    // we do not update components with the magic fault value. They are non-updateable
     1758    // (But can be recovered with "magicdstool -revertdestreakedfile -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
     1759    psStringAppend(&query, " AND (magicDSFile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
     1760
    17461761    if (!p_psDBRunQueryF(config->dbh, query, setHook, magic_ds_id)) {
    17471762        psError(PS_ERR_UNKNOWN, false, "database error");
  • branches/eam_branches/ipp-20101205/ippTools/src/magictool.c

    r30446 r30579  
    627627    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    628628    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
    629     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     629    pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "==");
    630630
    631631    psString query = psStringCopy("UPDATE magicRun SET fault = 0 WHERE state = 'new' AND fault != 0");
  • branches/eam_branches/ipp-20101205/ippTools/src/magictoolConfig.c

    r30446 r30579  
    114114    psMetadataAddS64(reverttreeArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magictool ID", 0);
    115115    psMetadataAddS16(reverttreeArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
    116     psMetadataAddStr(reverttreeArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL);
     116    psMetadataAddStr(reverttreeArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL);
    117117
    118118    // -inputs
  • branches/eam_branches/ipp-20101205/ippTools/src/pstamptool.c

    r30446 r30579  
    571571    PXOPT_COPY_S32(config->args, where, "-fault",      "fault", "==");
    572572    PXOPT_COPY_STR(config->args, where, "-state",      "state", "==");
     573    PXOPT_COPY_STR(config->args, where, "-reqType",     "reqType", "==");
     574    PXOPT_COPY_STR(config->args, where, "-name",     "name", "LIKE");
    573575    PXOPT_COPY_TIME(config->args, where, "-timestamp_begin", "timestamp", ">=");
    574576    PXOPT_COPY_TIME(config->args, where, "-timestamp_end", "timestamp", "<=");
     
    586588        psStringAppend(&query, ", state = '%s'", state);
    587589        if (!strcmp(state, "goto_cleaned")) {
    588             psStringAppend(&stateCheck, " AND state != 'cleaned'");
     590            psStringAppend(&stateCheck, " AND (state != 'cleaned' AND state != 'goto_cleaned')");
    589591        }
    590592    }
  • branches/eam_branches/ipp-20101205/ippTools/src/pstamptoolConfig.c

    r30446 r30579  
    104104    psMetadataAddS16(updatereqArgs, PS_LIST_TAIL, "-fault", 0,        "search by fault code", 0);
    105105    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-state", 0,        "search by state", NULL);
     106    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-reqType", 0,      "search by reqType", NULL);
     107    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-name", 0,      "search by reqType (LIKE comparsion)", NULL);
    106108    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampJob label (LIKE comparision)", NULL);
    107109    psMetadataAddTime(updatereqArgs, PS_LIST_TAIL, "-timestamp_begin", 0, "search by timestamp (>=)", NULL);
  • branches/eam_branches/ipp-20101205/ippTools/src/pxtools.h

    r28486 r30579  
    5151# define MAX_ROWS 10e9
    5252# define PXTOOL_MODE_NONE 0x0
     53// we do not revert or update components with this fault value
     54// This is the same value as PSTAMP_GONE
     55# define PXTOOL_DO_NOT_REVERT_FAULT 26
    5356
    5457bool pxIsValidState(const char *state);
  • branches/eam_branches/ipp-20101205/ippTools/src/warptool.c

    r29903 r30579  
    14851485    PXOPT_COPY_S16(config->args, where, "-fault",      "warpSkyfile.fault", "==");
    14861486
     1487    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     1488
    14871489    if (!psListLength(where->list)
    14881490        && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    15101512    }
    15111513    psFree(where);
     1514
     1515    if (!fault) {
     1516        // If fault has not been supplied, don't revert update faults with the magic value
     1517        // We don't do this for new runs because then they would never complete
     1518        // quality should be used to drop bad components
     1519        psStringAppend(&query_updated, " AND warpSkyfile.fault != %d", PXTOOL_DO_NOT_REVERT_FAULT);
     1520    }
    15121521
    15131522    if (!p_psDBRunQuery(config->dbh, query)) {
     
    20032012// shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
    20042013
    2005 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
     2014static bool change_skyfile_data_state(pxConfig *config, psString data_state)
    20062015{
    20072016    PS_ASSERT_PTR_NON_NULL(config, false);
     
    20652074static bool tocleanedskyfileMode(pxConfig *config)
    20662075{
    2067     return change_skyfile_data_state(config, "cleaned", "goto_cleaned");
     2076    return change_skyfile_data_state(config, "cleaned");
    20682077}
    20692078static bool tofullskyfileMode(pxConfig *config)
    20702079{
    2071     return change_skyfile_data_state(config, "full", "update");
     2080    return change_skyfile_data_state(config, "full");
    20722081}
    20732082static bool topurgedskyfileMode(pxConfig *config)
    20742083{
    2075     return change_skyfile_data_state(config, "purged", "goto_purged");
     2084    return change_skyfile_data_state(config, "purged");
    20762085}
    20772086static bool toscrubbedskyfileMode(pxConfig *config)
    20782087{
    2079      return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed");
     2088     return change_skyfile_data_state(config, "scrubbed");
    20802089}
    20812090
     
    21012110    else {
    21022111      if (strcmp(state,"error_cleaned") == 0) {
    2103         change_skyfile_data_state(config,"error_cleaned","goto_cleaned");
     2112        change_skyfile_data_state(config,"error_cleaned");
    21042113      }
    21052114      else if (strcmp(state, "error_scrubbed") == 0) {
    2106         change_skyfile_data_state(config,"error_scrubbed","goto_scrubbed");
     2115        change_skyfile_data_state(config,"error_scrubbed");
    21072116      }
    21082117      else if (strcmp(state, "error_purged") == 0) {
    2109         change_skyfile_data_state(config,"error_purged","goto_purged");
     2118        change_skyfile_data_state(config,"error_purged");
    21102119      }
    21112120      else {
     
    25262535        psStringAppend(&query, " AND (warpSkyfile.skycell_id = '%s')", skycell_id);
    25272536    }
     2537    // we do not update components with the magic fault value. They are non-updateable
     2538    // (But can be recovered with "warptool -revertwarped -fault 26" (PXTOOL_DO_NOT_REVERT_FAULT)
     2539    psStringAppend(&query, " AND (warpSkyfile.fault != %d)", PXTOOL_DO_NOT_REVERT_FAULT);
    25282540
    25292541    if (!p_psDBRunQueryF(config->dbh, query, setHook, warp_id)) {
  • branches/eam_branches/ipp-20101205/pstamp/scripts/Makefile.am

    r29330 r30579  
    1717        pstamp_runcommand.sh \
    1818        pstamp_server_status \
     19        pstamp_save_server_status.pl \
    1920        pstamp_webrequest.pl \
    2021        pstamp_get_image_job.pl \
    2122        psmkreq \
     23        psstatus \
    2224        pstampstopfaulted \
    2325        pstamp_checkdependent.pl \
  • branches/eam_branches/ipp-20101205/pstamp/scripts/pstamp_checkdependent.pl

    r30446 r30579  
    44#
    55# Check the status of a pending pstampDependent insuring that
    6 # the dependent processing has been queued and whether it is
    7 # finished or not
     6# the any update processing that is needed has been queued and determine check
     7# whether the processing has  finished or not
    88
    99use warnings;
     
    2727my $IPP_DIFF_MODE_STACK_STACK = 4;
    2828
    29 my ($dep_id, $stage, $stage_id, $component, $imagedb, $rlabel, $need_magic);
    30 my ($dbname, $dbserver, $verbose, $save_temps, $no_update);
     29my ($dep_id, $stage, $stage_id, $component, $imagedb, $rlabel, $need_magic, $fault_count, $max_fault_count);
     30my ($dbname, $ps_dbserver, $verbose, $save_temps, $no_update);
    3131
    3232GetOptions(
     
    3535    'stage_id=i'    =>  \$stage_id,
    3636    'component=s'   =>  \$component,
    37     'imagedb=s'     =>  \$imagedb,      # dbname for images.
     37    'imagedb=s'     =>  \$imagedb,      # dbname for images lookups.
    3838    'rlabel=s'      =>  \$rlabel,
    3939    'need_magic'    =>  \$need_magic,
     40    'fault_count=i' =>  \$fault_count,
     41    'max_fault_count=i' =>  \$max_fault_count,
    4042    'dbname=s'      =>  \$dbname,       # postage stamp server dbname
    41     'dbserver=s'    =>  \$dbserver,     # postage stamp server dbserver
     43    'dbserver=s'    =>  \$ps_dbserver,  # postage stamp server dbserver
    4244    'verbose'       =>  \$verbose,
    4345    'save-temps'    =>  \$save_temps,
     
    4850    if !(defined $dep_id and defined $stage and defined $stage_id and
    4951        defined $component and defined $imagedb);
     52
     53$max_fault_count = 5 if !$max_fault_count;
     54$fault_count = 0 if !defined $fault_count;
    5055
    5156my $missing_tools;
     
    6166}
    6267
     68my $ipprc = PS::IPP::Config->new();
     69
     70if (!$ps_dbserver) {
     71    $ps_dbserver =  metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER');
     72}
     73$pstamptool  .= " -dbname $dbname" if $dbname;
     74$pstamptool  .= " -dbserver $ps_dbserver";
     75
    6376# Append imagedb to the ippTools
     77# Note: configured DBSERVER is used for this server
    6478$chiptool    .= " -dbname $imagedb";
    6579$warptool    .= " -dbname $imagedb";
     
    6882$magicdstool .= " -dbname $imagedb";
    6983
    70 my $ipprc = PS::IPP::Config->new();
    71 
    72 if (!$dbserver) {
    73     $dbserver =  metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER');
    74 }
    75 
    7684
    7785my $tool;
    7886my $cmd;
    7987my $dsRun_state = "";
    80 my $whole_run = ($component eq 'all');
    81 
    82 # XXX: whole_run was a concept that isn't practical. Having one dependent for
    83 # a whole run makes finding errors too hard. We always have a dependent for each
    84 # component.
    85 # XXX: remove the unneeded code
    86 my_die("component = 'all' not supported", $PS_EXIT_PROG_ERROR) if $whole_run;;
    87 
    88 if ($whole_run) {
    89     if ($stage eq "chip") {
    90         $cmd = "$chiptool -listrun -chip_id $stage_id";
    91     } elsif ($stage eq "warp") {
    92         $cmd = "$warptool -listrun -warp_id $stage_id";
    93     } elsif ($stage eq "diff") {
    94         $cmd = "$difftool -listrun -diff_id $stage_id";
    95     } else {
    96         my_die("unexpected stage $stage found", $PS_EXIT_PROG_ERROR);
    97     }
     88
     89if ($stage eq "chip") {
     90    $cmd = "$chiptool -processedimfile -allfiles -chip_id $stage_id -class_id $component";
     91} elsif ($stage eq "warp") {
     92    $cmd = "$warptool -warped -warp_id $stage_id -skycell_id $component";
     93} elsif ($stage eq "diff") {
     94    $cmd = "$difftool -diffskyfile -diff_id $stage_id -skycell_id $component";
    9895} else {
    99     if ($stage eq "chip") {
    100         $cmd = "$chiptool -processedimfile -allfiles -chip_id $stage_id -class_id $component";
    101     } elsif ($stage eq "warp") {
    102         $cmd = "$warptool -warped -warp_id $stage_id -skycell_id $component";
    103     } elsif ($stage eq "diff") {
    104         $cmd = "$difftool -diffskyfile -diff_id $stage_id -skycell_id $component";
    105     } else {
    106         my_die("unexpected stage $stage found", $PS_EXIT_PROG_ERROR);
    107     }
     96    my_die("unexpected stage $stage found", $PS_EXIT_PROG_ERROR);
    10897}
    10998
     
    124113}
    125114my $status = 0;
    126 if (($it->{state} eq 'full') or ($it->{state} eq 'update') and ($whole_run or ($it->{data_state} eq 'full'))
     115if ((($it->{state} eq 'full') or ($it->{state} eq 'update')) and ($it->{data_state} eq 'full')
    127116        and (!$need_magic or $magic_ok or $it->{magicked} > 0)) {
    128117
    129     # This Dependency is satisfied. All done!
     118    # This Dependency is satisfied. All done. Release the pstampJobs
     119    #
    130120    my $command = "$pstamptool -updatedependent -set_state full -dep_id $dep_id";
    131     $command .= " -dbname $dbname" if $dbname;
    132     $command .= " -dbserver $dbserver" if $dbserver;
    133121    if (!$no_update) {
    134122        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    143131} elsif (($it->{state} eq 'cleaned') or ($it->{state} eq 'update')) {
    144132    #       For warp and diff stages we need to call the 'queue_update' subroutines even if the
    145     #       data_state is update in order to check the earlier stages in the pipeline
    146     #       For example if warpSkyfile is in update state but the chip run that it depends on hasn't
    147     #       been updated we need to go and queue it.
    148 
    149     if (($it->{state} ne 'cleaned') and $it->{fault}) {
    150         my_die("Component faulted on update dep_id: $dep_id",
    151                 $PS_EXIT_SYS_ERROR);
     133    #       data_state is update in order to check the state of inputs in earlier stages in the pipeline
     134    #       For example if warpSkyfile is in update state but the chipRun that it depends on hasn't
     135    #       been updated we need to go and queue the chips for processing.
     136
     137    my $fault = $it->{fault};
     138    if (($fault eq $PSTAMP_GONE) or (($it->{state} eq 'update') and $fault)) {
     139        $fault_count++;
     140        print "$stage $stage_id $component has fault $fault\n";
     141        if ($it->{fault} eq $PSTAMP_GONE) {
     142            faultJobs($PSTAMP_GONE);
     143            exit 0;
     144        } elsif ($fault_count >= $max_fault_count) {
     145            print "$stage $stage_id $component has faulted $fault_count times. Giving up\n";
     146
     147            faultComponent($stage, $stage_id, $component, $PSTAMP_GONE);
     148
     149            # fault the jobs
     150            faultJobs($PSTAMP_GONE);
     151            exit 0;
     152        }
     153
     154        # assume the fault is transient.
     155        my_die("Component faulted on update dep_id: $dep_id", $PS_EXIT_SYS_ERROR);
    152156    }
    153157
    154158    if ($stage eq 'chip') {
    155         # check_states_chip takes an array so that check_states_warp can pass it set of chips
     159        # check_states_chip takes an array so that check_states_warp can pass it a set of chips
    156160        my $chips = [$it];
    157         $status = check_states_chip($it->{chip_id}, $whole_run, $chips, $rlabel, $need_magic);
     161        $status = check_states_chip($it->{chip_id}, $chips, $rlabel, $need_magic);
    158162    } elsif ($stage eq 'warp') {
    159         $status = check_states_warp($it, $whole_run, $rlabel, $need_magic);
     163        $status = check_states_warp($it, $rlabel, $need_magic);
    160164    } elsif ($stage eq 'diff') {
    161         $status = check_states_diff($it, $whole_run, $rlabel, $need_magic);
     165        $status = check_states_diff($it, $rlabel, $need_magic);
    162166    } else {
    163167        my_die("Unexpected stage found $stage", $PS_EXIT_PROG_ERROR);
     168    }
     169    if ($status >= $PSTAMP_FIRST_ERROR_CODE) {
     170        faultJobs($status);
    164171    }
    165172} else {
     
    173180    my $job_fault = 0;
    174181
    175 if (0) {
    176     if ($stage eq 'chip') {
    177         # XXX: There is no need to check this anymore. All magicked chipRuns have abs(burntool_state) >= 13
    178         # If something changes that causes an error, we will figure that out from the chip failure
    179         my $burntool_state = $it->{burntool_state};
    180         # XXX: get the value of 13 from the ppImage recipe
    181         if ($burntool_state and (abs($burntool_state) < 13)) {
    182             print STDERR "chip $it->{chip_id} $it->{class_id} has burntool_state $burntool_state. Not avaiable.\n";
    183             $job_fault = $PSTAMP_NOT_AVAILABLE;
    184         }
    185     }
    186 }
    187182    if ($state eq 'error_cleaned') {
    188183        $job_fault = $PSTAMP_NOT_AVAILABLE;
    189     } elsif (($state =~ /scrub/) or ($state =~ /purge/)) {
    190         # jobs must have changed state since depenency was made
     184    } elsif (($state =~ /scrub/) or ($state =~ /purge/) or ($state eq 'drop')) {
     185        # Component state must have been changed state since dependency was inserted.
    191186        print STDERR "Dependency cannot be satisfied\n";
    192187        $job_fault = $PSTAMP_GONE;
     
    195190        my_die ("Unexpected state for ${stage}Run $stage_id $state", $PS_EXIT_PROG_ERROR);
    196191    }
     192
    197193    if (!$job_fault and ($stage eq 'chip')) {
     194        # should only get here with data_state 'full' and perhaps destreaking not done
     195        my_die ("Unexpected state for ${stage}Run $stage_id $state", $PS_EXIT_PROG_ERROR)
     196            if $it->{data_state} ne 'full';
     197
    198198        # chip processing is done, start destreaking.
    199199        my @chips;
     
    201201        $job_fault = check_states_magicDSRun($stage, $stage_id, \@chips, $rlabel, $need_magic, $it->{raw_magicked}, $it->{magic_ds_id}, $it->{dsRun_state});
    202202    }
    203     if ($job_fault) {
    204         faultJobs($state, $stage, $stage_id, $job_fault);
     203
     204    if ($job_fault >= $PSTAMP_FIRST_ERROR_CODE) {
     205        faultJobs($job_fault);
    205206    }
    206207}
     
    211212sub check_states_chip {
    212213    my $chip_id = shift;
    213     my $whole_run = shift;  # if true queue entire run for update
    214     my $metadatas = shift;  # an array of hashes, either from -processedimfile or -listrun
     214    my $metadatas = shift;  # an array of hashes, either from chiptool -processedimfile or warptool -scmap
    215215    my $rlabel = shift;     # if defined a new label for the chipRun
    216216    my $need_magic = shift;
    217 
    218217
    219218    my $dsRun_state;
     
    221220    my @chips;
    222221    my $magic_ds_id;
    223     if (!$whole_run) {
    224         foreach my $chip (@$metadatas) {
    225             $dsRun_state = $chip->{dsRun_state};
    226             $raw_all_magicked &= ($chip->{raw_magicked} > 0);
    227             $magic_ds_id = $chip->{magic_ds_id};
    228 
    229             push @chips, $chip->{class_id};
    230 
    231             my $state = $chip->{state};
    232             my $data_state = $chip->{data_state};
    233             if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or
    234                 ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/)) {
    235 
    236                 print "chipRun state is $chip->{chip_id} has state: $state data_state: $data_state cannot update\n";
    237                 faultJobs('stop', undef, undef, $PSTAMP_GONE);
    238 
    239                 return 0;
    240             } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) {
    241 
    242                 my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id -class_id $chip->{class_id}";
    243                 $command .= " -set_label $rlabel" if $rlabel;
    244 
    245                 if (!$no_update) {
    246                     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    247                                 run(command => $command, verbose => $verbose);
    248                     unless ($success) {
    249                         my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    250                     }
    251                 } else {
    252                     print "skipping $command\n";
    253                 }
    254             } elsif ($chip->{fault}) {
    255                 # fault the dependent
    256                 my_die("chip $chip->{chip_id} $chip->{class_id} faulted: $chip->{fault}", $chip->{fault});
    257             } elsif ($chip->{dsFile_fault}) {
    258                 # fault the dependent
    259                 my_die("magicDSFile $chip->{magic_ds_id} $chip->{chip_id} $chip->{class_id} faulted: $chip->{dsFile_fault}", $chip->{dsFile_fault});
    260             }
    261         }
    262     } else {
    263         my $run = $metadatas->[0];
    264         $dsRun_state = $run->{dsRun_state};
    265         $raw_all_magicked = ($run->{raw_magicked} > 0);
    266         my $state = $run->{state};
    267         if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/)) {
    268             print "chipRun state is $run->{chip_id} is in state $state cannot update\n";
    269             faultJobs('stop', undef, undef, $PSTAMP_GONE);
    270             return 0;
    271         }
    272 
    273         # providing no -class_id arguments changes all imfiles with data_state = 'cleaned' to 'update'
    274         my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id";
    275         $command .= " -set_label $rlabel" if $rlabel;
    276 
    277         if (!$no_update) {
    278             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    279                         run(command => $command, verbose => $verbose);
    280             unless ($success) {
    281                 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    282             }
    283         } else {
    284             print "skipping $command\n";
    285         }
    286     }
    287 
    288     my $status = check_states_magicDSRun('chip', $chip_id, \@chips, $rlabel, $need_magic, $raw_all_magicked, $magic_ds_id, $dsRun_state);
    289 
    290     return $status;
    291 }
    292 
    293 sub check_states_warp {
    294     # check status of input chips. If state is not updatable set error code for job
    295 
    296     # if chipProcessedImfile.state is cleaned call check_states_chip
    297 
    298     my $metadata = shift;
    299     my $whole_run = shift;  # if true queue entire run for update
    300     my $rlabel = shift;     # if defined a new label for the chipRun
    301     my $need_magic = shift;
    302 
    303     my $raw_all_magicked = 1; # this gets cleared if any of the inputs aren't destreaked
    304 
    305     my $warp_id = $metadata->{warp_id};
    306     my $skycell_id = $metadata->{skycell_id};
    307     my $state = $metadata->{state};
    308     my $data_state = $metadata->{data_state};
    309     if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or
    310          ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/)) {
    311         print STDERR "warpRun $warp_id $skycell_id has state $state $data_state faulting jobs\n";
    312         faultJobs('stop', undef, undef, $PSTAMP_GONE);
    313         exit 0;
    314     }
    315     if (($state eq 'update') and ($metadata->{fault})) {
    316         # fault dependent.
    317         my $fault = $metadata->{fault};
    318         my_die("warp $warp_id $skycell_id faulted: $fault", $fault);
    319     }
    320 
    321     if (!$whole_run) {
    322         my $skycell = $metadata;
    323         my $skycell_id = $skycell->{skycell_id};
    324 
    325         my $command = "$warptool -scmap -warp_id $warp_id -skycell_id $skycell_id";
    326         my $data = runToolAndParse($command, $verbose);
    327         if (!$data or scalar @$data == 0) {
    328             # This happens if the chipProcessedImfile disappears which happened when earlier
    329             # versions of chiptool -revertprocessedimfile didn't check the chipRun.state before
    330             # deleing the row.
    331             # Fault the jobs so that the Request can finish ...
    332             faultJobs('stop', undef, undef, $PSTAMP_GONE);
    333             # ... and fault the dependent so that we have a record of the error
    334             my_die("failed to find warpSkyCelllMap for warpRun $warp_id skycell_id $skycell_id",
    335                 $PSTAMP_GONE);
    336         }
    337 
    338 
    339         my $chips_ready = 1;
    340         my @chipsToUpdate;
    341         my $chip_id;
    342         foreach my $chip (@$data) {
    343             $chip_id = $chip->{chip_id};
    344             if (($chip->{data_state} ne 'full') or ($need_magic and ($chip->{magicked} <= 0))) {
    345                 $chips_ready = 0;
    346                 $chip->{fault} = $chip->{chip_fault};
    347                 push @chipsToUpdate, $chip;
     222
     223    my $queued_update = 0;
     224    foreach my $chip (@$metadatas) {
     225        $dsRun_state = $chip->{dsRun_state};
     226        $raw_all_magicked &= ($chip->{raw_magicked} > 0);
     227        $magic_ds_id = $chip->{magic_ds_id};
     228
     229        push @chips, $chip->{class_id};
     230
     231        my $state = $chip->{state};
     232        my $data_state = $chip->{data_state};
     233        if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or
     234            ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/) or ($data_state eq 'drop')) {
     235
     236            print "chipRun state is $chip->{chip_id} has state: $state data_state: $data_state cannot update\n";
     237            my $error_code;
     238            if (($state eq 'error_cleaned') or ($data_state ='error_cleaned')) {
     239                $error_code = $PSTAMP_NOT_AVAILABLE;
    348240            } else {
    349                 # this chip is good to go
    350             }
    351         }
    352 
    353         if ($chips_ready and $skycell->{data_state} ne 'update') {
    354             # the reason we defer setting the warp to update is so that we can handle error conditions at previous
    355             # stages more easily.
    356             my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}";
     241                $error_code = $PSTAMP_GONE;
     242            }
     243           
     244            # caller will fault the jobs
     245            return $error_code;
     246        } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) {
     247
     248            # chiptool does more state checking to insure this isn't done prematurely.
     249            my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id -class_id $chip->{class_id}";
    357250            $command .= " -set_label $rlabel" if $rlabel;
    358251
     
    366259                print "skipping $command\n";
    367260            }
    368         } elsif (scalar @chipsToUpdate > 0) {
    369             return check_states_chip($chip_id, 0, \@chipsToUpdate, $rlabel, $need_magic);
    370         }
    371     } else {
    372         my $warpRun = $metadata;
    373         my $command = "$chiptool -listrun -chip_id $warpRun->{chip_id}";
    374         my $data = runToolAndParse($command, $verbose);
    375         my_die("failed to find chipRun $warpRun->{chip_id} for warpRun $warp_id", $PS_EXIT_UNKNOWN_ERROR)
    376             if !$data or scalar @$data != 1;
    377 
    378         my $chipRun = $data->[0];
    379 
    380         my $chipRunState = $chipRun->{state};
    381         if (($chipRunState =~ /purge/) or ($chipRunState =~ /scrub/)) {
    382             print STDERR "warpRun $warp_id depends on chipRun $chipRun->{chip_id} which is in state $chipRunState\n";
    383             faultJobs('stop', 'warp', $warp_id, $PSTAMP_GONE);
    384             return 0;
    385         }
    386         my $warpRunState = $warpRun->{state};
    387         if (($chipRunState eq 'full') and (! $need_magic or ($chipRun->{magicked} > 0)) and ($warpRunState eq 'cleaned')) {
    388             # The inputs and outputs are ready. Queue the warpRun for update.
    389 
    390             # providing no -skycell_id arguments changes all skyfiles with data_state = 'cleaned' to 'update'
    391             my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id";
    392             $command .= " -set_label $rlabel" if $rlabel;
    393 
    394             if (!$no_update) {
    395                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    396                             run(command => $command, verbose => $verbose);
    397                 unless ($success) {
    398                     my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    399                 }
    400             } else {
    401                 print "skipping $command\n";
    402             }
    403         } elsif ($chipRunState eq 'cleaned' or
    404             (($chipRun->{state} eq 'full') and ($need_magic and ($chipRun->{magicked} < 0) and ($chipRun->{dsRun_state} ne 'new')))) {
    405             my $data = [$chipRun];
    406             return check_states_chip($chipRun->{chip_id}, 1, $data, $rlabel, $need_magic);
    407         }
    408     }
    409 
    410     # return value may be the return status of script so zero is good
    411     return 0;
    412 }
     261            $queued_update = 1;
     262        } elsif ($chip->{fault}) {
     263            $fault_count++;
     264            my $fault =  $chip->{fault};
     265
     266            if ($fault eq $PSTAMP_GONE) {
     267                # caller will fault jobs
     268                return $PSTAMP_GONE;
     269            } elsif ($fault_count > $max_fault_count) {
     270                print "$stage $stage_id has faulted $fault_count times. Giving up\n";
     271                $fault = $PSTAMP_GONE;
     272                faultComponent('chip', $chip->{chip_id}, $chip->{class_id}, $PSTAMP_GONE);
     273                return $PSTAMP_GONE;
     274            }
     275            # fault the dependent
     276            my_die("chip $chip->{chip_id} $chip->{class_id} faulted: $chip->{fault}", $chip->{fault});
     277        } elsif ($chip->{dsFile_fault} eq $PSTAMP_GONE) {
     278            print STDERR "magicDSFile $chip->{magic_ds_id} $chip->{chip_id} $chip->{class_id} is GONE";
     279            return $PSTAMP_GONE;
     280        } elsif ($chip->{dsFile_fault} and ($chip->{dsFile_data_state} eq 'update')) {
     281            # fault the dependent
     282            my_die("magicDSFile $chip->{magic_ds_id} $chip->{chip_id} $chip->{class_id} faulted: $chip->{dsFile_fault}", $chip->{dsFile_fault});
     283        }
     284    }
     285
     286    my $status = 0;
     287    if (!$queued_update) {
     288        $status = check_states_magicDSRun('chip', $chip_id, \@chips, $rlabel, $need_magic, $raw_all_magicked, $magic_ds_id, $dsRun_state);
     289    }
     290
     291    return $status;
     292}
     293
     294sub check_states_warp {
     295    my $metadata = shift;
     296    my $rlabel = shift;     # if defined a new label for the chipRun
     297    my $need_magic = shift;
     298   
     299    my $exit_status = 0;
     300
     301    my $raw_all_magicked = 1; # this gets cleared if any of the inputs aren't destreaked
     302
     303    my $warp_id = $metadata->{warp_id};
     304    my $skycell_id = $metadata->{skycell_id};
     305    my $state = $metadata->{state};
     306    my $data_state = $metadata->{data_state};
     307
     308    if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or
     309         ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/) or ($data_state eq 'drop')) {
     310        print STDERR "warpRun $warp_id $skycell_id has state $state $data_state faulting jobs\n";
     311        my $error_code;
     312        if (($state eq 'error_cleaned') or ($data_state eq 'error_cleaned')) {
     313            $error_code = $PSTAMP_NOT_AVAILABLE;
     314        } else {
     315            $error_code = $PSTAMP_GONE;
     316        }
     317        return $error_code
     318    }
     319    if (($state eq 'update') and ($metadata->{fault})) {
     320        # fault dependent.
     321        my $fault = $metadata->{fault};
     322        print STDERR "warp $warp_id $skycell_id faulted: $fault";
     323        return $fault;
     324    }
     325
     326    my $skycell = $metadata;
     327
     328    # get the list of input chips for this skycell
     329    my $command = "$warptool -scmap -warp_id $warp_id -skycell_id $skycell_id";
     330    my $data = runToolAndParse($command, $verbose);
     331    if (!$data or scalar @$data == 0) {
     332        # This happens if the chipProcessedImfile disappears which happened when earlier
     333        # versions of chiptool -revertprocessedimfile didn't check the chipRun.state before
     334        # deleting the row.
     335        print STDERR "failed to find warpSkyCelllMap for warpRun $warp_id skycell_id $skycell_id";
     336        return $PSTAMP_GONE;
     337    }
     338
     339    my $chips_ready = 1;
     340    my @chipsToUpdate;
     341    my $chip_id;
     342    foreach my $chip (@$data) {
     343        $chip_id = $chip->{chip_id};
     344        if (($chip->{data_state} ne 'full') or ($need_magic and ($chip->{magicked} <= 0))) {
     345            $chips_ready = 0;
     346            $chip->{fault} = $chip->{chip_fault};
     347            push @chipsToUpdate, $chip;
     348        } else {
     349            # this chip is done
     350        }
     351    }
     352
     353    if ($chips_ready and $skycell->{data_state} ne 'update') {
     354        # the reason we defer setting the warp to update is so that we can handle error conditions at previous
     355        # stages more easily.
     356        my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}";
     357        $command .= " -set_label $rlabel" if $rlabel;
     358
     359        if (!$no_update) {
     360            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     361                        run(command => $command, verbose => $verbose);
     362            unless ($success) {
     363                my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
     364            }
     365        } else {
     366            print "skipping $command\n";
     367        }
     368    } elsif (scalar @chipsToUpdate > 0) {
     369        my $fault = check_states_chip($chip_id, \@chipsToUpdate, $rlabel, $need_magic);
     370        if ($fault) {
     371            if ($fault eq $PSTAMP_GONE) {
     372                # chip or dsfile that this skycell depends on has faulted in a way that is not recoverable
     373                # fault the skycell
     374                faultComponent('warp', $warp_id, $skycell->{skycell_id}, $PSTAMP_GONE);
     375            }
     376            $exit_status = $fault;
     377        }
     378    }
     379
     380    # return value may be used as the return status of script so we use zero as success
     381    return $exit_status;
     382}
     383
    413384sub check_states_diff {
    414385    my $metadata = shift;
    415     my $whole_run = shift;  # if true queue entire run for update
    416386    my $rlabel = shift;     # if defined a new label for the chipRun
    417387    my $need_magic = shift;
     
    419389    my $diff_id   = $metadata->{diff_id};
    420390    my $diff_mode = $metadata->{diff_mode};
    421     if (!$whole_run) {
    422         my $skycell = $metadata;
    423         my $skycell_id = $skycell->{skycell_id};
    424 
    425         if ($diff_mode == $IPP_DIFF_MODE_WARP_STACK ) {
    426             # check the state of the template stack
    427             my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
    428             my $stack = runToolAndParseExpectOne($command, $verbose);
    429             my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack;
    430 
    431             if ($stack->{state} ne 'full') {
    432                 print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    433                 # this faults all jobs depending on this dep_id
    434                 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE);
    435                 return $PSTAMP_GONE;
    436             }
    437 
    438             # now check the warp
    439             $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
    440             my $warp = runToolAndParseExpectOne($command, $verbose);
    441             my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp;
    442 
    443             if ($warp->{data_state} ne 'full') {
    444                 return check_states_warp($warp, 0, $rlabel, $need_magic);
    445             }
    446             # warps are ready fall through and queue the diff update
    447         } elsif ($diff_mode eq $IPP_DIFF_MODE_WARP_WARP) {
    448             my $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
    449             my $warp1 = runToolAndParseExpectOne($command, $verbose);
    450             my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp1;
    451 
    452             my $warps_ready = 1;
    453             my $status = 0;
    454             if ($warp1->{data_state} ne 'full') {
    455                 $warps_ready = 0;
    456                 $status = check_states_warp($warp1, 0, $rlabel, $need_magic);
    457                 if ($status) {
    458                     return $status;
     391    my $skycell = $metadata;
     392    my $skycell_id = $skycell->{skycell_id};
     393
     394    if ($diff_mode == $IPP_DIFF_MODE_WARP_STACK ) {
     395        # check the state of the template stack
     396        my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
     397        my $stack = runToolAndParseExpectOne($command, $verbose);
     398        my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack;
     399
     400        if ($stack->{state} ne 'full') {
     401            print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     402            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     403            return $PSTAMP_GONE;
     404        }
     405
     406        # now check the warp
     407        $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
     408        my $warp = runToolAndParseExpectOne($command, $verbose);
     409        my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp;
     410
     411        if ($warp->{data_state} ne 'full') {
     412            my $warp_status = check_states_warp($warp, 0, $rlabel, $need_magic);
     413            if ($warp_status eq $PSTAMP_GONE) {
     414                faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     415            }
     416            return $warp_status;
     417        }
     418        # warps are ready fall through and queue the diff update
     419    } elsif ($diff_mode eq $IPP_DIFF_MODE_WARP_WARP) {
     420        my $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
     421        my $warp1 = runToolAndParseExpectOne($command, $verbose);
     422        my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp1;
     423
     424        my $warps_ready = 1;
     425        my $warp_status = 0;
     426        if ($warp1->{data_state} ne 'full') {
     427            $warps_ready = 0;
     428            $warp_status = check_states_warp($warp1, 0, $rlabel, $need_magic);
     429            if ($warp_status) {
     430                if ($warp_status eq $PSTAMP_GONE) {
     431                    faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
    459432                }
    460             }
    461             $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id";
    462             my $warp2 = runToolAndParseExpectOne($command, $verbose);
    463             my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp2;
    464 
    465             if ($warp2->{data_state} ne 'full') {
    466                 $warps_ready = 0;
    467                 $status = check_states_warp($warp2, 0, $rlabel, $need_magic);
    468             }
    469 
    470             if (!$warps_ready) {
    471                 # don't queue the diff update yet
    472                 return $status;
    473             }
    474 
    475         } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_STACK ) {
    476             # check the state of the input stack
    477             my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
    478             my $stack1 = runToolAndParseExpectOne($command, $verbose);
    479             my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1;
    480 
    481             if ($stack1->{state} ne 'full') {
    482                 print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    483                 # this faults all jobs depending on this dep_id
    484                 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE);
    485                 return $PSTAMP_GONE;
    486             }
    487             # check the state of the template stack
    488             $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
    489             my $stack2 = runToolAndParseExpectOne($command, $verbose);
    490             my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack2;
    491 
    492             if ($stack2->{state} ne 'full') {
    493                 print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    494                 # this faults all jobs depending on this dep_id
    495                 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE);
    496                 return $PSTAMP_GONE;
    497             }
    498 
    499             # inputs are ready fall through and queue the diff update
    500         } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_WARP ) {
    501             # check the state of the input stack
    502             my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}";
    503             my $stack = runToolAndParseExpectOne($command, $verbose);
    504             my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack;
    505 
    506             if ($stack->{state} ne 'full') {
    507                 print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    508                 # this faults all jobs depending on this dep_id
    509                 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE);
    510                 return $PSTAMP_GONE;
    511             }
    512 
    513             # now check the template warp
    514             $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id";
    515             my $warp = runToolAndParseExpectOne($command, $verbose);
    516             my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp;
    517 
    518             if ($warp->{data_state} ne 'full') {
    519                 return check_states_warp($warp, 0, $rlabel, $need_magic);
    520             }
    521             # warps are ready fall through and queue the diff update
     433                return $warp_status;
     434            }
     435        }
     436        $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id";
     437        my $warp2 = runToolAndParseExpectOne($command, $verbose);
     438        my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp2;
     439
     440        if ($warp2->{data_state} ne 'full') {
     441            $warps_ready = 0;
     442            $warp_status = check_states_warp($warp2, 0, $rlabel, $need_magic);
     443            if ($warp_status eq $PSTAMP_GONE) {
     444                faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     445            }
     446        }
     447
     448        if (!$warps_ready) {
     449            # don't queue the diff update yet
     450            return $warp_status;
     451        }
     452        # inputs are ready fall through and queue the diff update
     453
     454    } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_STACK ) {
     455        # check the state of the input stack
     456        my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
     457        my $stack1 = runToolAndParseExpectOne($command, $verbose);
     458        my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1;
     459
     460        if ($stack1->{state} ne 'full') {
     461            print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     462            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     463            return $PSTAMP_GONE;
     464        }
     465        # check the state of the template stack
     466        $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
     467        my $stack2 = runToolAndParseExpectOne($command, $verbose);
     468        my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack2;
     469
     470        if ($stack2->{state} ne 'full') {
     471            print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     472            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     473            return $PSTAMP_GONE;
     474        }
     475
     476        # inputs are ready fall through and queue the diff update
     477    } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_WARP ) {
     478        # check the state of the input stack
     479        my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}";
     480        my $stack = runToolAndParseExpectOne($command, $verbose);
     481        my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack;
     482
     483        if ($stack->{state} ne 'full') {
     484            print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     485            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     486            return $PSTAMP_GONE;
     487        }
     488
     489        # now check the template warp
     490        $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id";
     491        my $warp = runToolAndParseExpectOne($command, $verbose);
     492        my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp;
     493
     494        if ($warp->{data_state} ne 'full') {
     495            my $warp_status = check_states_warp($warp, 0, $rlabel, $need_magic);
     496            if ($warp_status eq $PSTAMP_GONE) {
     497                faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     498            }
     499            return $warp_status;
     500        }
     501        # warps are ready fall through and queue the diff update
     502    } else {
     503        my_die("unexpected diff_mode found: $diff_mode", $PS_EXIT_PROG_ERROR);
     504    }
     505
     506    if ($skycell->{data_state} ne 'update') {
     507        my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id";
     508        $command .= " -set_label $rlabel" if $rlabel;
     509
     510        if (!$no_update) {
     511            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     512                        run(command => $command, verbose => $verbose);
     513            unless ($success) {
     514                my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
     515            }
    522516        } else {
    523             my_die("unexpected diff_mode found: $diff_mode", $PS_EXIT_PROG_ERROR);
    524         }
    525 
    526         if ($skycell->{data_state} ne 'update') {
    527             my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id";
    528             $command .= " -set_label $rlabel" if $rlabel;
    529 
    530             if (!$no_update) {
    531                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    532                             run(command => $command, verbose => $verbose);
    533                 unless ($success) {
    534                     my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    535                 }
    536             } else {
    537                 print "skipping $command\n";
    538             }
    539         }
    540     } else {
    541         # XXX todo whole_run
    542         return $PS_EXIT_PROG_ERROR;
     517            print "skipping $command\n";
     518        }
    543519    }
    544520
     
    633609}
    634610
    635 sub faultJobs {
    636     my ($state, $stage, $stage_id, $job_fault) = @_;
    637 
    638     my $command = "$pstamptool -updatejob -set_state stop -set_fault $job_fault -dep_id $dep_id";
    639     $command .= " -dbname $dbname" if $dbname;
    640     $command .= " -dbserver $dbserver" if $dbserver;
    641     if (!$no_update) {
    642         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    643                     run(command => $command, verbose => $verbose);
    644         unless ($success) {
    645             my_die("failed to set pstampJob.fault for dep_id: $dep_id",
    646                 $PS_EXIT_UNKNOWN_ERROR);
    647         }
    648     } else {
    649         print "skipping $command\n";
    650     }
    651 }
    652 
     611# Check the data_state of the magicDSFile associated with this component (currently only chip stage is supported)
     612# Returns zero on success.
     613# returns the PSTAMP fault code to use for the jobs if an unrecoverable error is detected
     614# And faults the dependent if transient errors occur
    653615sub check_states_magicDSRun {
    654616    my $stage = shift;
     
    661623    my $dsRun_state = shift;
    662624
    663     # XXX: this code assumes that destreaking is handled at the chip stage
     625    # XXX: this code assumes that for update destreaking is only performed for chip stage
    664626    my_die ("check_states_magicDSRun only implemented for chip stage", $PS_EXIT_PROG_ERROR) if $stage ne 'chip';
    665627
     
    675637    if ($need_magic and !$input_magicked) {
    676638        if (!defined($dsRun_state) or ($dsRun_state eq 'NULL')) {
     639            # it is arguably a programming error if we get here
    677640            print "No magicDSRun for chipRun $stage_id and magic is required\n";
    678             faultJobs('stop', undef, undef, $PSTAMP_NOT_DESTREAKED);
     641            return $PSTAMP_NOT_DESTREAKED;
    679642        } elsif (($dsRun_state eq 'cleaned') or ($dsRun_state eq 'update')) {
    680643            foreach my $c (@$components) {
     
    684647                    my_die("failed to find magicDSFile for ${stage}Run $stage_id $c", $PS_EXIT_UNKNOWN_ERROR);
    685648                }
    686                 if ($dsfile->{fault} > 0) {
     649                if ($dsfile->{fault} eq $PSTAMP_GONE) {
     650                    print "magicDSFile has fault $PSTAMP_GONE\n";
     651                    return $PSTAMP_GONE;
     652                }
     653                #  destreak faults get cleared when the component is set to be updated
     654                if (($dsfile->{data_state} eq 'update') and ($dsfile->{fault} > 0)) {
     655                    $fault_count++;
     656                    if ($fault_count > $max_fault_count) {
     657                        print "Destreak file $magic_ds_id $component for $stage $stage_id has faulted $fault_count times. Giving up\n";
     658                        faultComponent('destreak', $magic_ds_id, $component, $PSTAMP_GONE);
     659                        return $PSTAMP_GONE;
     660                    }
     661                    # Assume fault is transient
    687662                    my_die("faulted magicDSFile for ${stage}Run $stage_id $c fault: $dsfile->{fault}",
    688663                        $PS_EXIT_UNKNOWN_ERROR);
     
    690665                if ($dsfile->{data_state} eq 'cleaned') {
    691666                    $command = "$magicdstool -setfiletoupdate -magic_ds_id $magic_ds_id -component $c";
    692                     # XXX: get the recoveryroot from a config file (it isn't actually used except to check whether it is in nebulous)
     667                    # XXX: get the recoveryroot from a config file
     668                    # (It isn't actually used except to check whether it is a nebulous path)
    693669                    $command .= " -set_recoveryroot neb://any/gpc1/destreak/recover";
    694670                    $command .= " -set_label $rlabel" if $rlabel;
     
    708684            }
    709685        } elsif ($dsRun_state eq 'failed_revert') {
     686            # XXX: revert failures are rarely fixed. give up but say it's just not available not GONE
    710687            print "magicDSRun.state = $dsRun_state for chipRun $stage_id is in state failed_revert cannot update\n";
    711             faultJobs('stop', undef, undef, $PSTAMP_NOT_AVAILABLE);
     688            return $PSTAMP_NOT_AVAILABLE;
    712689        } else {
    713690            print "magicDSRun.state = $dsRun_state for chipRun $stage_id";
     
    716693        }
    717694    }
     695
    718696    return 0;
     697}
     698
     699sub faultJobs {
     700    my ($job_fault) = @_;
     701
     702    my $command = "$pstamptool -updatejob -set_state stop -set_fault $job_fault -dep_id $dep_id";
     703    if (!$no_update) {
     704        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     705                    run(command => $command, verbose => $verbose);
     706        unless ($success) {
     707            my_die("failed to set pstampJob.fault for dep_id: $dep_id",
     708                $PS_EXIT_UNKNOWN_ERROR);
     709        }
     710    } else {
     711        print "skipping $command\n";
     712    }
     713}
     714
     715sub faultComponent {
     716    my ($stage, $stage_id, $component, $fault) = @_;
     717
     718    my $command;
     719    if ($stage eq 'chip') {
     720        $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $component";
     721    } elsif ($stage eq 'warp') {
     722        $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $component";
     723    } elsif ($stage eq 'diff') {
     724        $command = "$difftool -updatediffskyfile -diff_id $stage_id -skycell_id $component";
     725    } elsif ($stage eq 'destreak') {
     726        $command = "$magicdstool -updatedestreakedfile -magic_ds_id $stage_id -component $component";
     727    } else {
     728        my_die("unexpected stage $stage found", $PS_EXIT_PROG_ERROR);
     729    }
     730
     731    $command .= " -fault $fault";
     732
     733    if (!$no_update) {
     734        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     735                    run(command => $command, verbose => $verbose);
     736        unless ($success) {
     737            carp "$cmd failed";
     738        }
     739    } else {
     740        print "skipping $command\n";
     741    }
    719742}
    720743
     
    726749
    727750    my $command = "$pstamptool -updatedependent -set_fault $fault -dep_id $dep_id";
    728     $command .= " -dbname $dbname" if $dbname;
    729     $command .= " -dbserver $dbserver" if $dbserver;
    730751    if (!$no_update) {
    731752        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
  • branches/eam_branches/ipp-20101205/pstamp/scripts/pstamp_job_run.pl

    r30446 r30579  
    1414use File::Basename;
    1515use File::Copy;
    16 use File::Temp qw(tempfile);
     16use File::Temp qw(tempfile tempdir);
    1717use Digest::MD5::File qw( file_md5_hex );
    1818use PS::IPP::PStamp::RequestFile qw( :standard );
     
    144144        } elsif (($options & $PSTAMP_REQUIRE_UNCENSORED) and ($stage ne 'chip')) {
    145145            # user required uncensored but since stage isn't chip we can't rebuild them
    146             my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE);
    147         } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($stage ne 'chip')) {
     146            my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE, 'stop');
     147        } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($params->{state} eq 'update') and ($stage ne 'chip')) {
     148            # we can only restore pixels for chip stage images if the data has been updated.
     149            # XXX: this test is not quite good enough. If all components have been updated then the
     150            # state will be 'full' But this will get us going.
     151            print "Run state is update: will make stamps from destreaked $stage images.\n";
    148152            # make stamps from uncensored images
    149153            $muggle = 0;
     
    151155            # Try and replace the streaks from the recovery images
    152156
    153             @file_list = ();
    154             $tmproot = "$outdir/$job_id";
    155             mkdir $tmproot or
    156                 my_die( "failed to create temporary directory $tmproot", $job_id, $PS_EXIT_UNKNOWN_ERROR);
     157            my $temp_dir = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR") or &my_die("Unable to find temporary directory in site configuration", $job_id, $PS_EXIT_CONFIG_ERROR);
     158            $tmproot = tempdir("$temp_dir/psjob.$job_id.XXXX", CLEANUP => !$save_temps);
    157159            my $muggle_command = "$streaksreplace -stage $stage -tmproot $tmproot";
    158160            # find the "directory" of the input path_base
     
    160162            my $base = basename($image);
    161163            $tmpImage = "$tmproot/$base";
     164
     165            @file_list = ();
    162166
    163167            # XXX: We should get the recovery_path_base from the magicDSFile but that requires a bunch of file rule and
     
    180184                $base = basename($variance);
    181185                $tmpVariance = "$tmproot/$base";
    182                 $newFileArgs .= " -weight $tmpVariance";
     186                $newFileArgs .= " -variance $tmpVariance";
    183187                my $recVariance = "$inputdir/REC_$base";
    184188                $muggle_command .= " -weight $variance -recweight $recVariance";
     
    225229    }
    226230
    227     if (!$save_temps) {
    228         unlink $tmpImage if $tmpImage;
    229         unlink $tmpMask if $tmpMask;
    230         unlink $tmpVariance if $tmpVariance;
    231         rmdir $tmproot if $tmproot;
    232     }
    233 
    234231    if ($exitStatus == 0) {
    235232        my $reglist = "$outdir/reglist$job_id";
  • branches/eam_branches/ipp-20101205/pstamp/scripts/pstamp_server_status

    r30446 r30579  
    2525
    2626pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    27 #pod2usage( -msg => "Required options: --first --stage",
    28 #          -exitval => 3) unless
    29 #    defined $first and
    30 #    defined $stage;
    3127
    3228# Look for programs we need
     
    3935}
    4036
     37# XXX: Note under pantasks this will be the curent directory, so this
     38# isn't necessary if the pstamp/web stuff is configured to point at the
     39# ipp build. But currently it's running out of Bill's build
    4140my $ipphome = "/home/panstarrs/ipp";
     41my $status_cmd = "psstatus";
     42
    4243$rundir = "$ipphome/pstamp" if !$rundir;
    4344
     
    4546
    4647
     48
     49my $now = `date -u`;
     50
     51print "<b>Status updated: &nbsp;&nbsp;&nbsp;</b> $now<br /><br />\n";
     52
    4753my $down = 0;
    4854if ($down) {
    4955    print "Postage Stamp Server will be down for maintenance it will back at approximately 00:00 2010-12-11 UTC\n";
    50     exit 0;
    51 }
     56    # exit 0;
     57} else {
     58    # talk to pantasks_server and get the status
    5259
    53 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
     60    my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
    5461
    55 print $pts "status\n";
    56 print $pts "quit\n";
    57 close $pts;
     62    print $pts "status\n";
     63    print $pts "quit\n";
     64    close $pts;
    5865
    59 my $command = "$pantasks_client < $pantasks_script";
    60 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    61     run(command => $command, verbose => $verbose);
    62 unless ($success) {
    63     $error_code = (($error_code >> 8) or 1);
    64     if ($error_code == 12) {
    65         #print "Postage Stamp Server is not running\n";
    66         print "Postage Stamp Server will be down for maintenance it will back shortly.\n";
    67         exit 0;
     66
     67    my $command = "$pantasks_client < $pantasks_script";
     68    my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     69        run(command => $command, verbose => $verbose);
     70    unless ($success) {
     71        $error_code = (($error_code >> 8) or 1);
     72        if ($error_code == 12) {
     73            #print "Postage Stamp Server is not running\n";
     74            print "Postage Stamp Server will be down for maintenance it will back shortly.\n";
     75            exit 0;
     76        } else {
     77            warn("$command failed. exit status: $error_code");
     78            exit $error_code;
     79        }
    6880    }
    69     warn("$command failed. exit status: $error_code");
    70     exit $error_code;
    71 }
    7281
    73 my $output = join "", @$stdout_buf;
     82    my $output = join "", @$stdout_buf;
    7483
    75 print "$output" if $verbose;
     84    print "$output" if $verbose;
    7685
    77 my @lines = split "\n", $output;
     86    my @lines = split "\n", $output;
    7887
    79 my ($scheduler_state, $controller_state);
    80 my $got_state = 0;
    81 my %tasks;
    82 foreach my $line (@lines) {
    83     chomp $line;
    84     next if !$line;
    85     my ($first, $second, $third);
     88    my ($scheduler_state, $controller_state);
     89    my $got_state = 0;
     90    my %tasks;
     91    foreach my $line (@lines) {
     92        chomp $line;
     93        next if !$line;
     94        my ($first, $second, $third);
    8695
    87     if ($line =~ /Scheduler is/) {
    88         ($first, $second, $scheduler_state) = split " ", $line;
    89         $got_state = 1;
    90 #        print "$first $second $third $scheduler_state\n";
    91     } elsif ($line =~ /Controller is/) {
    92         ($first, $second, $controller_state) = split " ", $line;
    93 #        print "$first $second $third $controller_state\n";
    94     } elsif ($got_state == 1 and $line =~ /\+|\-/) {
    95 #        print "$line\n";
    96         my ($task_state, $task, $nrun, $njobs, $ngood, $nfail, $ntime, $cmd) = split " ", $line;
    97 #        print "$task $task_state\n";
    98         my %this_task = ( name => $task, nrun=> $nrun, njobs => $njobs, ngood => $ngood, nfail => $nfail, ntime => $ntime, cmd => $cmd );
     96        if ($line =~ /Scheduler is/) {
     97            ($first, $second, $scheduler_state) = split " ", $line;
     98            $got_state = 1;
     99    #        print "$first $second $third $scheduler_state\n";
     100        } elsif ($line =~ /Controller is/) {
     101            ($first, $second, $controller_state) = split " ", $line;
     102    #        print "$first $second $third $controller_state\n";
     103        } elsif ($got_state == 1 and $line =~ /\+|\-/) {
     104    #        print "$line\n";
     105            my ($task_state, $task, $nrun, $njobs, $ngood, $nfail, $ntime, $cmd) = split " ", $line;
     106    #        print "$task $task_state\n";
     107            my %this_task = ( name => $task, nrun=> $nrun, njobs => $njobs, ngood => $ngood, nfail => $nfail, ntime => $ntime, cmd => $cmd );
    99108
    100         # change '.' in task name to '_' so we have a valid hash key
    101         $task =~ s/\./\_/g;
    102         $tasks{$task} =  \%this_task;
     109            # change '.' in task name to '_' so we have a valid hash key
     110            $task =~ s/\./\_/g;
     111            $tasks{$task} =  \%this_task;
     112        }
     113    }
     114
     115    if ($scheduler_state) {
     116        print "Pantasks Scheduler $scheduler_state.\n";
     117        if ($controller_state) {
     118            print $br . "Pantasks Controller $controller_state.\n";
     119        } else {
     120            print STDERR "Controller state not found";
     121            exit 1;
     122        }
     123        print "$br$br\n";
     124    } else {
     125        print STDERR "Scheduler state not found";
     126        exit 1;
     127    }
     128
     129    my $request_run = $tasks{'pstamp_request_run'};
     130    my $request_fin = $tasks{'request_finish_run'};
     131    my $job_run = $tasks{'pstamp_job_run'};
     132
     133
     134    if ($request_run) {
     135        # print "<br >\n";
     136        print "<b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
     137        if ($request_fin) {
     138            print "  $request_fin->{ngood} Requests finished.";
     139        } else {
     140            print "Task request.finish.run not found.\n";
     141        }
     142        print "\n";
     143        print "\n";
     144        if ($job_run) {
     145            print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
     146            print "<br />\n";
     147        } else {
     148            print "Task pstamp.job.run not found.<br />\n";
     149        }
     150    } else {
     151        print "Task pstamp.request.run not found.\n";
    103152    }
    104153}
    105154
    106 if ($scheduler_state) {
    107     print "Pantasks Scheduler $scheduler_state.\n";
    108     if ($controller_state) {
    109         print $br . "Pantasks Controller $controller_state.\n";
    110     } else {
    111         print STDERR "Controller state not found";
    112         exit 1;
    113     }
    114     print "$br$br\n";
    115 } else {
    116     print STDERR "Scheduler state not found";
    117     exit 1;
     155# now run the script psstatus to check the status of running requests and finished requests
     156print "<br /><b>Unfinished Requests</b><br />\n";
     157print "<pre>\n";
     158system "$status_cmd --totals";
     159print "</pre>\n";
     160
     161#print "<br />\n";
     162
     163
     164# print "<br /><b>Unfinished Requests</b><br />\n";
     165print "<pre>\n";
     166system "$status_cmd --running";
     167print "</pre>\n";
     168
     169if (0) {
     170    # these are included in running requests above
     171    print "<br /><b>Requests building results fileset</b><br/>\n";
     172    print "<pre>\n";
     173    system "$status_cmd --finishing";
     174    print "</pre>\n";
    118175}
    119176
    120 my $request_run = $tasks{'pstamp_request_run'};
    121 my $request_fin = $tasks{'request_finish_run'};
    122 my $job_run = $tasks{'pstamp_job_run'};
    123 
    124 
    125 if ($request_run) {
    126     print "<br /><b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
    127     if ($request_fin) {
    128         print "  $request_fin->{ngood} Requests finished.";
    129     } else {
    130         print "Task request.finish.run not found.\n";
    131     }
    132     print "\n";
    133     print "\n";
    134     if ($job_run) {
    135         print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
    136         print "<br />\n";
    137     } else {
    138         print "Task pstamp.job.run not found.<br />\n";
    139     }
    140     print "<br /><b>Unfinished Requests</b><br />\n";
    141     print "<pre>\n";
    142     system "/home/panstarrs/bills/ipp/tools/psstatus -r ";
    143     print "</pre>\n";
    144     print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
    145     print "<pre>\n";
    146     # finished requests
    147     system "/home/panstarrs/bills/ipp/tools/psstatus -f";
    148     print "</pre>\n";
    149 } else {
    150     print "Task pstamp.request.run not found.\n";
    151 }
    152 
    153 
     177print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
     178print "<pre>\n";
     179system "$status_cmd --finished";
     180print "</pre>\n";
    154181
    155182
  • branches/eam_branches/ipp-20101205/pstamp/scripts/pstampparse.pl

    r30446 r30579  
    932932        my $data_state = $image->{data_state};
    933933        $data_state = $run_state if $stage eq 'stack';
    934         if (($run_state =~ /purged/) or ($run_state =~ /scrubbed/) or ($run_state eq 'drop')) {
     934        my $component_fault = $image->{fault};
     935        my $stage_id = $image->{stage_id};
     936        my $component = $image->{component};
     937
     938        if ($component_fault eq $PSTAMP_GONE) {
    935939            # image is gone and it's not coming back
     940            print STDERR "$stage $stage_id $component is gone\n";
     941            $$r_newState = 'stop';
     942            $$r_fault = $PSTAMP_GONE;
     943        } elsif (($run_state =~ /purged/) or ($run_state =~ /scrubbed/) or ($run_state eq 'drop')) {
     944            # image is gone and it's not coming back
     945            print STDERR "$stage $stage_id $component has state: $run_state data_state: $data_state\n";
    936946            $$r_newState = 'stop';
    937947            $$r_fault = $PSTAMP_GONE;
    938948        } elsif (($run_state eq "error_cleaned") or ($data_state eq 'error_cleaned')) {
    939949            # if cleanup had an error don't get the user's hopes up set fault to gone
     950            print STDERR "$stage $stage_id $component has state: $run_state data_state: $data_state\n";
    940951            $$r_newState = 'stop';
    941952            $$r_fault = $PSTAMP_GONE;
Note: See TracChangeset for help on using the changeset viewer.