IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2010, 2:45:13 PM (16 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20100823/ippScripts/scripts
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/automate_stacks.pl

    r29124 r29515  
    124124    defined $check_chips or defined $check_stacks or $check_sweetspot or $check_detrends or $check_dqstats or
    125125    defined $test_mode or defined $clean_old or defined $check_mode or
    126     defined $confirm_stacks;
     126    defined $confirm_stacks or defined $burntool_stats;
    127127
    128128# Configurable parameters from our config file.
    129129my @target_list = ();
    130130my @filter_list = ();
     131my %distribution_list = ();
    131132my %tessID_list = ();
    132133my %obsmode_list = ();
     
    135136my %cleanmods_list = ();
    136137my %stackable_list = ();
     138my %extra_processing = ();
    137139my %reduction_class = ();
    138140my %macro_formats = ();
     
    206208                $this_target = ${ $tentry }{value};
    207209                push @target_list, $this_target;
     210                $distribution_list{$this_target} = $this_target;
     211            }
     212            elsif (${ $tentry }{name} eq 'DISTRIBUTION') {
     213                $distribution_list{$this_target} = ${ $tentry }{value};
    208214            }
    209215            elsif (${ $tentry }{name} eq 'TESS') {
     
    222228                $stackable_list{$this_target} = ${ $tentry }{value};
    223229            }
     230            elsif (${ $tentry }{name} eq 'EXTRA_PROCESSING') {
     231                $extra_processing{$this_target} = ${ $tentry }{value};
     232            }
    224233            elsif (${ $tentry }{name} eq 'REDUCTION') {
    225234                $reduction_class{$this_target} = ${ $tentry }{value};
     
    726735        my ($Nexposures,$Nimfiles,$Nburntooled,$Nalready) = pre_chip_queue($date,$target);
    727736        if (defined($burntool_stats)) {
    728             print "$Nexposures $Nimfiles $Nburntooled $Nalready\n";
     737            print "BTSTATS: $date $target $Nexposures $Nimfiles $Nburntooled $Nalready\n";
    729738        }
    730739
    731740        if ($Nexposures == 0) {
    732741            print STDERR "execute_chips: Target $target on $date had no exposures.\n";
    733 #           next;
     742            next;
    734743        }
    735744        if ($Nalready != 0) {
    736745            print STDERR "execute_chips: Not queueing $target on $date due to already existing exposures.\n";
    737 #            next;
     746            next;
    738747        }
    739748        if ($Nimfiles != $Nburntooled) {
     
    11831192        &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    11841193    }
     1194   
     1195   
    11851196    return(0);
    11861197}
     
    11901201    my $pretend = shift;
    11911202    foreach my $target (@target_list) {
    1192         if ($stackable_list{$target} == 1) {
    1193             foreach my $filter (@filter_list) {
     1203        foreach my $filter (@filter_list) {
     1204            if (exists($extra_processing{$target})) {
     1205                do_extra_processing($date,$target,$filter,$pretend);
     1206            }
     1207            if ($stackable_list{$target} == 1) {
    11941208                my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter);
    11951209                if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :(
     
    12311245                }
    12321246            }
     1247            else {
     1248                # print STDERR "execute_stacks: Target $target is not auto-stackable.\n";
     1249            }
    12331250        }
    1234         else {
    1235             # print STDERR "execute_stacks: Target $target is not auto-stackable.\n";
    1236         }
    1237     }
    1238 
     1251    }
    12391252}
    12401253
     
    12911304
    12921305#
     1306# Extra processing
     1307################################################################################
     1308
     1309sub do_extra_processing {
     1310    my $date = shift;
     1311    my $target = shift;
     1312    my $filter = shift;
     1313    my $pretend = shift;
     1314    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
     1315
     1316    if ($target eq 'OSS') {
     1317        my $db = init_gpc_db();
     1318
     1319        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) ";
     1320        $obj_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' ORDER BY rawExp.object";
     1321        print STDERR "$obj_sth\n";
     1322        my $object_ref = $db->selectall_arrayref( $obj_sth );
     1323
     1324        foreach my $object_row (@{ $object_ref }) {
     1325            my $this_object = shift @{ $object_row };
     1326            my $input_sth = "select exp_id,warp_id,dateobs from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";
     1327            $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' ";
     1328            $input_sth .= " ORDER BY dateobs ";
     1329
     1330            my $warps = $db->selectall_arrayref( $input_sth );
     1331           
     1332            if (($#{ $warps } + 1) % 2 != 0) {
     1333                print STDERR "Number of input warps to make OSS diffs is not even! $#{ $warps }\n";
     1334                die;
     1335            }
     1336           
     1337            while ($#{ $warps } > -1) {
     1338                my $input_warp = shift @{ $warps };
     1339                my $template_warp = shift @{ $warps };
     1340                my $input_exp_id = ${ $input_warp }[0];
     1341                my $template_exp_id = ${ $template_warp }[0];
     1342               
     1343                my $cmd = "$difftool -dbname $dbname  -definewarpwarp ";
     1344                $cmd .= "-input_label $label  -template_label $label ";
     1345                $cmd .= "-backwards "; # Needed because difftool assumes a different date sorting.
     1346                $cmd .= "-set_workdir $workdir  -set_dist_group $dist_group  -set_data_group $data_group ";
     1347                $cmd .= " -simple  -set_label $label -exp_id $input_exp_id -template_exp_id $template_exp_id ";
     1348#               $cmd .= " -pretend ";
     1349                if (defined($pretend)) {
     1350                    $cmd .= ' -pretend ';
     1351                }
     1352                if ($debug == 1) {
     1353                    $cmd .= ' -pretend ';
     1354                }
     1355                print STDERR "EXTRA_PROCESSING: $cmd\n";
     1356                if (($debug == 0)&&(!defined($pretend))) {
     1357                    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1358                        run ( command => $cmd, verbose => $verbose );
     1359                    unless ($success) {
     1360                        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1361                        &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     1362                    }
     1363                }
     1364            }
     1365        }
     1366    }
     1367}
     1368
     1369           
     1370
     1371
     1372#
    12931373# Auto-Clean
    12941374################################################################################
     
    13801460    my $object   = $object_list{$target};
    13811461    my $comment = $comment_list{$target};
    1382     my $dist_group = $target;
     1462    my $dist_group = $distribution_list{$target};
    13831463    my $data_group = "${target}.${trunc_date}";
    13841464    my $tess_id = $tessID_list{$target};
     
    14271507        my $N = $metadata_out{N_MACROS};
    14281508        $metadata_out{"ns${N}Macro"} = $macro_formats{$proc_mode};
    1429         print STDERR "WORKING ON A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n";
     1509#       print STDERR "WORKING ON A MACRO: ns${N}Macro $proc_mode $macro_formats{$proc_mode}\n";
    14301510        if (defined($date)&&(defined($target))) {
    14311511
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/ipp_apply_burntool.pl

    r27299 r29515  
    5555my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    5656my $nebXattr = can_run('neb-xattr') or (warn "Can't find neb-xattr" and $missing_tools = 1);
     57my $nebreplicate = can_run('neb-replicate') or (warn "Can't find neb-replicate" and $missing_tools = 1);
    5758#my $fpack    = can_run('fpack')    or (warn "Can't find fpack" and $missing_tools = 1);
    5859if ($missing_tools) {
     
    214215
    215216        $status = vsystem ("$nebXattr --write $outTable user.copies:2",$REALRUN);
     217        $status = vsystem ("$nebreplicate --set_copies 2 $outTable",$REALRUN);
    216218        $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN);
    217219        if ($status) {
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/ipp_cleanup.pl

    r27959 r29515  
    5353}
    5454
     55# set this to 1 to enable checking for files on dead nodes
     56# it is off for now because the implementation is a hack
     57# See comments below.
     58my $check_for_gone = 0;
     59
    5560my $error_state;
    56 if ($mode eq "goto_cleaned")  { $error_state = "error_cleaned";  }
    57 if ($mode eq "goto_scrubbed") { $error_state = "error_scrubbed"; }
    58 if ($mode eq "goto_purged")   { $error_state = "error_purged";   }
     61my $done_state;
     62if ($mode eq "goto_cleaned")  { $error_state = "error_cleaned"; $done_state = "cleaned"; }
     63if ($mode eq "goto_scrubbed") { $error_state = "error_scrubbed"; $done_state = "scrubbed";}
     64if ($mode eq "goto_purged")   { $error_state = "error_purged";   $done_state = "purged";}
    5965
    6066
     
    9298    }
    9399
    94     # if there are no chipProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new'
    95     # XXX Why? This could just mean there's nothing to cleanup, or that we're trying to rerun an errored run.
     100    # if there are no chipProcessedImfiles (@$stdout_buf == 0) then assume that we're done
     101    # it could be that there are no chipProcessedImfiles at all if say if a run was changed from drop to goto_cleaned
     102    # or of a run was set to update and then back to goto_cleaned before any images were processed
    96103    if (@$stdout_buf == 0)  {
    97         my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state";
     104        my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $done_state";
    98105        $command .= " -dbname $dbname" if defined $dbname;
    99106
     
    126133
    127134                unless ($ipprc->file_exists($config_file)) {
    128                     print STDERR "skipping cleanup for chipRun $stage_id $class_id "
    129                         . " because config file ($config_file) is missing\n";
    130                     $status = 0;
     135                    if (file_gone($config_file)) {
     136                        print STDERR "forcing cleanup for chipRun $stage_id $class_id "
     137                            . " because config file ($config_file) is gone\n";
     138                    } else {
     139                        print STDERR "skipping cleanup for chipRun $stage_id $class_id "
     140                            . " because config file ($config_file) is missing\n";
     141                        $status = 0;
     142                    }
    131143                }
    132144            }
     
    354366
    355367    if (@$stdout_buf == 0) {
    356         # No skycells were found for some reason.
    357         # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself."
    358         my $command = "$warptool -updaterun -warp_id $stage_id -set_state $error_state";
     368        # No skycells were found for some reason.
     369        # it could be that there are no warpSkyfiles at all if say if a run was changed from drop to goto_cleaned
     370        # or of a run was cleaned, set to update, and then back to goto_cleaned before any images were successfully
     371        # updated
     372        my $command = "$warptool -updaterun -warp_id $stage_id -set_state $done_state";
    359373        $command .= " -dbname $dbname" if defined $dbname;
    360374
     
    384398
    385399                unless ($ipprc->file_exists($config_file)) {
    386                     print STDERR "skipping cleanup for warpRun $stage_id $skycell_id" .
    387                         " because config file is missing\n";
    388                     $status = 0;
     400                    if (file_gone($config_file)) {
     401                        print STDERR "forcing cleanup for warpRun $stage_id $skycell_id" .
     402                            " because config file is gone\n";
     403                    } else {
     404                        print STDERR "skipping cleanup for warpRun $stage_id $skycell_id" .
     405                            " because config file is missing\n";
     406                        $status = 0;
     407                    }
    389408                }
    390409            }
     
    624643
    625644    if (@$stdout_buf == 0) {
    626         # No skycells were found for some reason.
    627         # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself."
    628         my $command = "$difftool -updaterun -diff_id $stage_id -set_state $error_state";
     645        # No skycells were found for some reason.
     646        # it could be that there are no warpSkyfiles at all if say if a run was changed from drop to goto_cleaned
     647        # or of a run was cleaned, set to update, and then back to goto_cleaned before any images were successfully
     648        my $command = "$difftool -updaterun -diff_id $stage_id -set_state $done_state";
    629649        $command .= " -dbname $dbname" if defined $dbname;
    630650
     
    658678
    659679                unless ($ipprc->file_exists($config_file)) {
    660                     print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" .
    661                         " because config file ($config_file) is missing\n";
    662                     $status = 0;
     680                    if (file_gone($config_file)) {
     681                        print STDERR "forcing cleanup for diffRun $stage_id $skycell_id" .
     682                            " because config file ($config_file) is gone\n";
     683                    } else {
     684                        print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" .
     685                            " because config file ($config_file) is missing\n";
     686                        $status = 0;
     687                    }
    663688                }
    664689            }
     
    16651690}
    16661691
     1692my $whichnode;
     1693sub file_gone
     1694{
     1695    # if $check_for_gone check whether the only instance of file is on a lost volumen
     1696    # XXX: we don't have a proper interface for this.
     1697    # For now try to use Bill's hack the script 'whichnode'
     1698    return 0 if !$check_for_gone;
     1699
     1700    my $file = shift;
     1701
     1702    if (!$whichnode) {
     1703        $whichnode = can_run('whichnode') or
     1704            &my_die("Can't find whichnode", "chip", $stage_id, $PS_EXIT_CONFIG_ERROR);
     1705    }
     1706
     1707    my $command = "$whichnode $file";
     1708
     1709    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1710        run(command => $command, verbose => $verbose);
     1711    unless ($success) {
     1712        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1713        &my_die("Unable to perform whichnode: $error_code", "chip", $stage_id, $error_code);
     1714    }
     1715
     1716    my @lines = split "\n", (join "", @$stdout_buf);
     1717    my $numGone = 0;
     1718    my $numNotGone = 0;
     1719    foreach my $line (@lines) {
     1720        chomp $line;
     1721
     1722        # output lines are either
     1723        #   "volume available"
     1724        # or
     1725        #   "volume not available"
     1726
     1727        my ($volume, $answer, undef) = split " ", $line;
     1728        # our hack is if the volume has an X in the name it's gone
     1729        if ($volume =~ /X/) {
     1730            print STDERR "$file is on $volume which is gone\n";
     1731            $numGone++;
     1732        } elsif ($answer eq 'not') {
     1733            print STDERR "$file is on $volume which is not available\n";
     1734            $numNotGone++;
     1735        } else {
     1736            print STDERR "unexpected output from whichnode: $line\n";
     1737        }
     1738    }
     1739    # if there are any instances that are not on a gone node return 0
     1740    if ($numNotGone == 0 and $numGone > 0) {
     1741        return 1;
     1742    } else {
     1743        return 0;
     1744    }
     1745}
     1746
    16671747sub addFilename
    16681748{
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/magic_destreak.pl

    r28931 r29515  
    4242# Parse the command-line arguments
    4343my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction);
     44my ($streaks_path_base, $inv_streaks_path_base);
    4445my ($outroot, $recoveryroot, $magicked);
    4546my ($replace, $release);
     
    4950           'magic_ds_id=s'  => \$magic_ds_id,# Magic destreak run identifier
    5051           'camera=s'       => \$camera,     # camera for evaluating file rules
     52           'streaks_path_base=s'      => \$streaks_path_base,    # path_base for streaks data
     53           'inv_streaks_path_base=s'  => \$inv_streaks_path_base, #path_base for streaks from inverse diff
     54           'inv_streaks=s'  => \$inv_streaks,# file containing the list of streaks from the inverse diff
    5155           'streaks=s'      => \$streaks,    # file containing the list of streaks
    5256           'inv_streaks=s'  => \$inv_streaks,# file containing the list of streaks from the inverse diff
     
    7882    defined $camera and
    7983    defined $streaks and
     84    defined $streaks_path_base and
    8085    defined $stage and
    8186    defined $stage_id and
     
    108113    &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    109114}
     115$inv_streaks_path_base = undef if defined($inv_streaks_path_base) and ($inv_streaks_path_base eq "NULL");
    110116$inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL");
    111117
     
    240246    my ($allstreaks_fh, $allstreaks_name);
    241247
     248    # Set name of streaks files from their path_base. Note. ne 'NULL' test is for backward compatability
     249    # with runs that don't have path_base set yet
     250    if ($streaks_path_base ne 'NULL') {
     251        $streaks = "$streaks_path_base.streaks";
     252    }
     253    if ($inv_streaks_path_base and ($inv_streaks_path_base ne 'NULL')) {
     254        $inv_streaks = "$inv_streaks_path_base.streaks";
     255    }
     256
     257    my $streaks_resolved = $ipprc->file_resolve($streaks) or &my_die("failed to resolve streaks file $streaks", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR);
     258    my $inv_streaks_resolved;
     259    if ($inv_streaks) {
     260        $inv_streaks_resolved = $ipprc->file_resolve($inv_streaks) or &my_die("failed to resolve inverse streaks file $inv_streaks", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR);
     261    }
     262       
     263
    242264    if ($stage eq "raw") {
    243265        $image = $uri;
     
    301323        $sources    = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $path_base);
    302324
    303         if ($inv_streaks) {
     325        if ($inv_streaks_resolved) {
    304326            # create a temporary file containing the contents of the
    305327            # two streaks files
     
    307329                    UNLINK => !$save_temps);
    308330
    309             combine_streaks($allstreaks_fh, $streaks, $inv_streaks);
     331            combine_streaks($allstreaks_fh, $streaks_resolved, $inv_streaks_resolved);
    310332
    311333            # apply the combined streaks to both the forward and inverse diffs
    312             $streaks = $allstreaks_name;
     334            $streaks_resolved = $allstreaks_name;
    313335        }
    314336    }
    315337
    316338    {
    317         my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image";
     339        my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks_resolved -image $image";
    318340
    319341        $command .= " -stats $statsFile";
     
    340362        }
    341363    }
    342     if (($stage eq "diff") and $inv_streaks) {
     364    if (($stage eq "diff") and $inv_streaks_resolved) {
    343365        $image   = $ipprc->filename("PPSUB.INVERSE", $path_base);
    344366        $mask    = $ipprc->filename("PPSUB.INVERSE.MASK", $path_base);
     
    349371        my $invStatsFile = "$outroot/$exp_id.mds.$magic_ds_id.$stage_id.$component.inv.stats";
    350372
    351         my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image";
     373        my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks_resolved -image $image";
    352374        $command .= " -stats $invStatsFile";
    353375
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/magic_process.pl

    r28137 r29515  
    1717use IPC::Cmd 0.36 qw( can_run run );
    1818use File::Temp qw( tempfile );
     19use File::Copy;
    1920use PS::IPP::Metadata::Config;
    2021use PS::IPP::Metadata::List qw( parse_md_list );
     
    4142
    4243# Parse the command-line arguments
    43 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
     44my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile, $final_outroot);
    4445
    4546GetOptions(
     
    4950           'dbname=s'        => \$dbname,     # Database name
    5051           'baseroot=s'      => \$baseroot,   # Output root name
     52           'final-outroot=s' => \$final_outroot,   # location for final outputs
    5153           'save-temps'      => \$save_temps, # Save temporary files?
    5254           'verbose'         => \$verbose,    # Print stuff?
     
    8688
    8789my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     90
     91# list of VerifyStreaks input and output files to copy to nebulous
     92my @verify_outputs = qw(
     93clusterPos.txt
     94duplicate.png
     95mask.png
     96original.png
     97original.fits
     98residual.png
     99residual.fits
     100clusters.list
     101);
    88102
    89103### Get a list of inputs
     
    311325}
    312326
    313 
    314327### Input result into database
    315328{
     
    334347
    335348if ($node eq "root") {
     349    # XXXX: Since we just added the result above, all of these my_dies are going to fail
     350    # with a duplicate row error.
     351    # see more comments below
    336352    my $streaks_file = "$outroot.streaks";
    337353    my $resolved = $ipprc->file_resolve($streaks_file);
     
    349365    }
    350366
    351     &run_verifystreaks($baseroot);
    352367
    353368    my $exp_id;                 # Exposure identifier
     
    366381    }
    367382
     383    &run_verifystreaks($baseroot, $exp_id);
     384
    368385    {
    369386        my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path); # Astrometry file
     
    383400    }
    384401
     402    my $output_streaks = $final_outroot . ".streaks";
     403    if ($output_streaks and ($output_streaks ne $streaks_file)) {
     404        copy_to_nebulous($ipprc, $streaks_file, $output_streaks, 1);
     405        foreach my $f (@verify_outputs) {
     406            my $src = "$baseroot.verify/${exp_id}_$f";
     407            my $dest = "$final_outroot.${f}";
     408            copy_to_nebulous($ipprc, $src, $dest, 1);
     409        }
     410    } else {
     411        $output_streaks = $streaks_file;
     412    }
    385413
    386414    {
    387415        my $command = "$magictool -addmask";
    388416        $command   .= " -magic_id $magic_id";
    389         $command   .= " -uri $streaks_file";
     417        $command   .= " -path_base $final_outroot";
    390418        $command   .= " -streaks $num_streaks";
    391419        $command   .= " -dbname $dbname" if defined $dbname;
     
    397425            unless ($success) {
    398426                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    399                 # This isn't going to work because our result was already entered.
     427                # XXX: This my_die isn't going to work because the result for the root node was already
     428                # added to the database up above.
     429                # There is a magicMask has a fault column. Maybe we should
     430                # use that and add a new revert mode that deletes the magicMask and the magicNodeResult
     431                # for the root node.
    400432                &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code);
    401433            }
     
    406438}
    407439
     440
    408441### Pau.
    409442
     
    411444
    412445    my $baseroot = shift;
     446    my $exp_id = shift;
    413447
    414448    unless ($VerifyStreaks) {
     
    431465    my @files = <$baseroot.*.clusters>;
    432466
    433     unless (open ($FILE, ">$outdir/clusters.list")) {
    434         print "failed to create cluster file $outdir/clusters.list\n";
     467    my $clusters_list = "$outdir/${exp_id}_clusters.list";
     468    unless (open ($FILE, ">$clusters_list")) {
     469        print "failed to create cluster file $clusters_list\n";
    435470        return 1;
    436471    }
     
    441476    close ($FILE);
    442477    if ($status) {
    443         print "failed to create cluster file $outdir/clusters.list\n";
     478        print "failed to create cluster file $clusters_list\n";
    444479        return 1;
    445480    }
    446481
    447     my $command = "$VerifyStreaks --out $outdir --clusters $outdir/clusters.list $baseroot.root.streakMap";
     482    my $command = "$VerifyStreaks --out $outdir --clusters $clusters_list $baseroot.root.streakMap";
    448483
    449484    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    513548}
    514549
     550# Copy a file to nebulous and optionally replicate it
     551# We should consider making this an ipprc function. For now try it here so we can print
     552# the right error messages
     553sub copy_to_nebulous {
     554    my $ipprc = shift;
     555    my $src = shift;
     556    my $dest = shift;
     557    my $replicate = shift;
     558
     559    print "copying $src to $dest\n";
     560
     561    $ipprc->file_exists($src) or
     562        &my_die("expected output file does not exist: $src", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     563
     564    # copy the file to it's final destination - which is presumably in nebulous
     565    # we delete it so that all instances are deleted in case it has been replicated
     566    if ($ipprc->file_exists($dest)) {
     567        $ipprc->file_delete($dest) or
     568                &my_die("failed to delete existing file: $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     569    }
     570    my $dest_resolved = $ipprc->file_resolve($dest, 'create');
     571    &my_die("failed to resolve $dest", $PS_EXIT_UNKNOWN_ERROR) if !$dest_resolved;
     572
     573    copy ($src, $dest_resolved) or
     574        &my_die("failed to copy $src to $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     575
     576    if ($replicate and (file_scheme($dest) eq 'neb')) {
     577        my $neb = $ipprc->nebulous();
     578        $neb->setxattr($dest, 'user.copies', 2, 'create') or
     579            &my_die("failed to set user.copies for $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     580
     581        $neb->replicate($dest) or
     582            &my_die("failed to replicate $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     583    }
     584}
     585
    515586sub my_die
    516587{
  • branches/eam_branches/ipp-20100823/ippScripts/scripts/magic_tree.pl

    r27718 r29515  
    8383    unless ($success) {
    8484        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    85         &my_die("Unable to perform magictool -inputfile: $error_code", $magic_id, $error_code);
    86     }
    87 
    88     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     85        &my_die("Unable to perform magictool -inputskyfile: $error_code", $magic_id, $error_code);
     86    }
     87
     88    my $magictool_output = join "", @$stdout_buf;
     89    # if there is no output from magictool that means that there are no
     90    # diffSkyfiles with non-zero quality. Set fault to a special value so
     91    # that these magicRuns can be recognized and dropped.
     92    &my_die("magictool -inputskyfile returned no output. Inputs are probably all bad quality.", $magic_id, 42)
     93        if !$magictool_output;
     94    my $metadata = $mdcParser->parse($magictool_output) or
    8995        &my_die("Unable to parse metadata config doc", $magic_id, $PS_EXIT_PROG_ERROR);
    9096
Note: See TracChangeset for help on using the changeset viewer.