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_stack.pl

    r38137 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/';  # Far side destination base location
    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 my $have_warps      = 0;                      # Do we have a copy of the warp if we don't find one there?
    26 
    27 my $fail_state = "prep_fail";
    28 
    2920# Look for programs we need
    3021my $missing_tools;
    3122my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3223my $stacktool    = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
     24my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3325
    3426if ($missing_tools) {
     
    3729}
    3830
    39 my ($remote_id,$stack_id,$camera,$dbname,$verbose,$path_base,$no_update);
     31my ($remote_id,$stack_id,$camera,$dbname,$verbose,$path_base,$no_update,$cmd_recipe);
    4032GetOptions(
    4133    'remote_id=s'    => \$remote_id,
     
    4335    'camera|c=s'     => \$camera,
    4436    'dbname|d=s'     => \$dbname,
     37    'recipe=s'       => \$cmd_recipe,
    4538    'path_base=s'    => \$path_base,
    4639    'no_update'      => \$no_update,
     
    4942
    5043pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    51 pod2usage( -msg => "Required options: --remote_id --stack_id --camera --dbname --path_base", -exitval => 3) unless
     44pod2usage( -msg => "Required options: --remote_id --stack_id --camera --dbname --path_base --recipe", -exitval => 3) unless
    5245    defined($remote_id) and
    5346    defined($stack_id) and
    5447    defined($camera) and
    55     defined($path_base) and
     48    defined($path_base) and   
     49    defined($cmd_recipe) and
    5650    defined($dbname);
     51
     52# Hard coded values
     53# Now accessible from a recipe
     54my %remote_recipe = ();
     55{
     56    my $verbose = 0;
     57    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     58    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     59        run(command => $conf_cmd, verbose => $verbose);
     60    unless ($success) {
     61        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     62        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     63    }
     64    my $mdcParser = PS::IPP::Metadata::Config->new;
     65    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     66
     67    my $active_recipe = '';
     68    my %recipes = ();
     69   
     70#    print Dumper($metadata);
     71    foreach my $entry (@{ $metadata }) {
     72        if (${ $entry }{name} eq 'ACTIVE') {
     73            $active_recipe = ${ $entry }{value}; # Not actually used
     74        }
     75        else {
     76            if (${ $entry }{class} eq 'metadata') { # A real recipe
     77                my $name = ${ $entry }{name};
     78                foreach my $tentry (@{ ${ $entry }{value} }) {
     79                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     80                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     81                    }
     82                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     83                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     84                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     85                        }
     86                    }
     87                }
     88            }
     89        }
     90    }
     91   
     92    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
     93#    print Dumper(%recipes);
     94    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
     95#    print Dumper(\%remote_recipe);
     96}
     97
     98# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     99my $remote_root     = $remote_recipe{REMOTE_ROOT};  # Far side destination base location
     100my $remote_hostname = $remote_recipe{REMOTE_HOSTNAME};         # Name of the remote node.
     101my $threads_req     = 4;                      # How many threads are we going to use?
     102my $have_warps      = $remote_recipe{TRANSFER_WARP_IMAGES};                      # Do we have a copy of the warp if we don't find one there?
     103
     104my $fail_state = "prep_fail";
     105
    57106
    58107my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $stack_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     
    158207        #  ${remote_root}/tmp/${ipp_disk}
    159208
    160         if ($have_warps != 0) { # Check to see if we have a copy, because if we do, then we can send it over if it's missing.
     209        if ($have_warps) { # Check to see if we have a copy, because if we do, then we can send it over if it's missing.
    161210            (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".fits");
    162211            ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".fits");
     
    201250    close(COMPMAP);
    202251
    203     my $mk_mdc_command = "mkdir -p $remote_outdir && sc_mk_stack_mdc.pl --compmap ${remote_root}/tmp/${component_map} $warp_path_base_string > ${remote_outroot}.in.mdc";
     252    my $mk_mdc_command = "mkdir -p $remote_outdir && sc_mk_stack_mdc.pl --remote_root ${remote_root} --compmap ${remote_root}/tmp/${component_map} $warp_path_base_string > ${remote_outroot}.in.mdc";
    204253    my $recipe_ppstack = $ipprc->reduction($reduction, 'STACK_PPSTACK'); # Recipe to use
    205254    my $ppstack_command  = " ppStack -input ${remote_outroot}.in.mdc ";
Note: See TracChangeset for help on using the changeset viewer.