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

    r37833 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 $warptool    = can_run('warptool') or (warn "Can't find warptool" 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,$warp_id,$camera,$dbname,$verbose,$path_base,$no_update);
     31my ($remote_id,$warp_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 -warp_id --camera --dbname --path_base", -exitval => 3) unless
     44pod2usage( -msg => "Required options: --remote_id -warp_id --camera --dbname --path_base --recipe", -exitval => 3) unless
    5145    defined($remote_id) and
    5246    defined($warp_id) and
    5347    defined($camera) and
    5448    defined($path_base) and
     49    defined($cmd_recipe) and
    5550    defined($dbname);
    5651
     52
     53# Hard coded values
     54# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     55# Now accessible from a recipe
     56my %remote_recipe = ();
     57{
     58    my $verbose = 0;
     59    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     60    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     61        run(command => $conf_cmd, verbose => $verbose);
     62    unless ($success) {
     63        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     64        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     65    }
     66    my $mdcParser = PS::IPP::Metadata::Config->new;
     67    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     68
     69    my $active_recipe = '';
     70    my %recipes = ();
     71   
     72#    print Dumper($metadata);
     73    foreach my $entry (@{ $metadata }) {
     74        if (${ $entry }{name} eq 'ACTIVE') {
     75            $active_recipe = ${ $entry }{value}; # Not actually used
     76        }
     77        else {
     78            if (${ $entry }{class} eq 'metadata') { # A real recipe
     79                my $name = ${ $entry }{name};
     80                foreach my $tentry (@{ ${ $entry }{value} }) {
     81                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     82                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     83                    }
     84                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     85                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     86                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     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
     100my $remote_root = $remote_recipe{REMOTE_ROOT};
     101my $hostname    = $remote_recipe{REMOTE_HOSTNAME};
     102my $have_warps  = $remote_recipe{TRANSFER_WARP_IMAGES};
     103my $threads_req     = 4;                      # How many threads are we going to use?
     104
     105my $fail_state = "prep_fail";
     106
     107
    57108my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $warp_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    58109
    59110my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    60111
    61 my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     112my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     113if ($have_warps) {
     114    push @return_component_list, ("PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE");
     115}
    62116
    63117# STEP 0: Open output files
Note: See TracChangeset for help on using the changeset viewer.