IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2015, 3:12:58 PM (11 years ago)
Author:
watersc1
Message:

Updated remote code with ff support and ippconfig recipes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/sc_prepare_ff.pl

    r38145 r38168  
    1818use Pod::Usage qw( pod2usage );
    1919
    20 # Hard coded values
    21 # my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 my $remote_root     = '/scratch3/watersc1/';
    23 my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
    24 my $threads_req     = 4;                      # How many threads are we going to use?
    25 
    26 my $fail_state = "prep_fail";
    27 
    2820# Look for programs we need
    2921my $missing_tools;
    3022my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3123my $fftool    = can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
     24my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3225
    3326if ($missing_tools) {
     
    3629}
    3730
    38 my ($remote_id,$ff_id,$camera,$dbname,$verbose,$path_base,$no_update);
     31my ($remote_id,$ff_id,$camera,$dbname,$verbose,$path_base,$no_update,$cmd_recipe);
    3932GetOptions(
    4033    'remote_id=s'    => \$remote_id,
     
    4235    'camera|c=s'     => \$camera,
    4336    'dbname|d=s'     => \$dbname,
     37    'recipe=s'       => \$cmd_recipe,
    4438    'path_base=s'    => \$path_base,
    4539    'no_update'      => \$no_update,
     
    4842
    4943pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    50 pod2usage( -msg => "Required options: --remote_id -ff_id --camera --dbname --path_base", -exitval => 3) unless
     44pod2usage( -msg => "Required options: --remote_id -ff_id --camera --dbname --path_base --recipe", -exitval => 3) unless
    5145    defined($remote_id) and
    5246    defined($ff_id) and
    5347    defined($camera) and
    5448    defined($path_base) and
     49    defined($cmd_recipe) and
    5550    defined($dbname);
     51
     52
     53# Hard coded values
     54# Now accessible from a recipe
     55my %remote_recipe = ();
     56{
     57    my $verbose = 0;
     58    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     59    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     60        run(command => $conf_cmd, verbose => $verbose);
     61    unless ($success) {
     62        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     63        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     64    }
     65    my $mdcParser = PS::IPP::Metadata::Config->new;
     66    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     67
     68    my $active_recipe = '';
     69    my %recipes = ();
     70   
     71#    print Dumper($metadata);
     72    foreach my $entry (@{ $metadata }) {
     73        if (${ $entry }{name} eq 'ACTIVE') {
     74            $active_recipe = ${ $entry }{value}; # Not actually used
     75        }
     76        else {
     77            if (${ $entry }{class} eq 'metadata') { # A real recipe
     78                my $name = ${ $entry }{name};
     79                foreach my $tentry (@{ ${ $entry }{value} }) {
     80                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     81                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     82                    }
     83                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     84                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     85                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     86                        }
     87                    }
     88                }
     89            }
     90        }
     91    }
     92   
     93    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
     94#    print Dumper(%recipes);
     95    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
     96#    print Dumper(\%remote_recipe);
     97}
     98
     99# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     100my $remote_root     = $remote_recipe{REMOTE_ROOT};
     101my $remote_hostname = $remote_recipe{REMOTE_HOSTNAME};         # Name of the remote node.
     102my $remote_raw      = "${remote_root}/tmp/";  # Directory to find raw data in.
     103
     104my $threads_req     = 4;                      # How many threads are we going to use?
     105
     106my $fail_state = "prep_fail";
     107
    56108
    57109my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $ff_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     
    126178        my $ipp_insourc = $ipprc->filename("PSPHOT.OUTPUT.CFF",$source_pb);
    127179
    128         my ($ipp_disk_inimage, $remote_inimage) = &uri_to_outputs($ipp_inimage);
    129         my ($ipp_disk_inmask, $remote_inmask)  = &uri_to_outputs($ipp_inmask);
    130         my ($ipp_disk_inwt, $remote_inwt)    = &uri_to_outputs($ipp_inwt);
    131         my ($ipp_disk_insourc, $remote_insourc) = &uri_to_outputs($ipp_insourc);
     180#       my ($ipp_disk_inimage, $remote_inimage) = &uri_to_outputs($ipp_inimage);
     181#       my ($ipp_disk_inmask, $remote_inmask)  = &uri_to_outputs($ipp_inmask);
     182#       my ($ipp_disk_inwt, $remote_inwt)    = &uri_to_outputs($ipp_inwt);
     183#       my ($ipp_disk_insourc, $remote_insourc) = &uri_to_outputs($ipp_insourc);
     184
     185        my (undef,$remote_inimage) = uri_to_outputs_raw($ipp_inimage);
     186        my (undef,$remote_inmask)  = uri_to_outputs_raw($ipp_inmask);
     187        my (undef,$remote_inwt)    = uri_to_outputs_raw($ipp_inwt);
     188        my (undef,$remote_insourc) = uri_to_outputs_raw($ipp_insourc);
    132189
    133190        # make any directory we may need
     
    142199                    $remote_id,$ff_id,  $PS_EXIT_CONFIG_ERROR, $fail_state);
    143200        }
     201
    144202
    145203
     
    176234            print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    177235        }
     236        # If we're this far, we succeeded, so delete the input files.
     237        print CONFIG " && rm -f $remote_insourc $remote_inimage $remote_inmask $remote_inwt ";
    178238        print CONFIG "\n";
    179239#       die();
     
    234294    my $neb_uri = shift;
    235295    my ($ipp_disk, $remote_disk) = &uri_convert( $neb_uri );
     296
     297    print TRANSFER "$ipp_disk\n";
     298    print CHECK    "$remote_disk\n";
     299    return($ipp_disk,$remote_disk);
     300}
     301
     302sub uri_to_outputs_raw {
     303    my $neb_uri = shift;
     304    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
     305    $remote_disk = $remote_raw . $ipp_disk;
    236306
    237307    print TRANSFER "$ipp_disk\n";
Note: See TracChangeset for help on using the changeset viewer.