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

    r38145 r38168  
    2121use Pod::Usage qw( pod2usage );
    2222
     23#use Data::Dumper;
     24# Look for programs we need
     25my $missing_tools;
     26my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
     27my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     28
     29if ($missing_tools) {
     30    warn("Can't find required tools.");
     31    exit($PS_EXIT_CONFIG_ERROR);
     32}
     33
     34# Options
     35my ($remote_id,$cmd_recipe,$stage,$camera,$path_base,$dbname,$verbose,$no_update);
     36GetOptions(
     37    'remote_id=s'    => \$remote_id,
     38    'recipe=s'       => \$cmd_recipe,
     39    'stage=s'        => \$stage,
     40    'camera|c=s'     => \$camera,
     41    'path_base=s'    => \$path_base,
     42    'dbname|d=s'     => \$dbname,
     43    'verbose'        => \$verbose,
     44    'no_update'      => \$no_update,
     45    ) or pod2usage( 2 );
     46
     47pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     48pod2usage( -msg => "Required options: --remote_id --stage --camera --dbname --path_base --recipe", -exitval => 3) unless
     49    defined($remote_id) and
     50    defined($stage) and
     51    defined($camera) and
     52    defined($path_base) and
     53    defined($cmd_recipe) and
     54    defined($dbname) and
     55    defined($dbname);
     56
    2357# Hard coded values
    24 # my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    25 my $remote_root = '/scratch3/watersc1/';
     58# Now accessible from a recipe
     59my %remote_recipe = ();
     60{
     61    my $verbose = 0;
     62    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     63    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     64        run(command => $conf_cmd, verbose => $verbose);
     65    unless ($success) {
     66        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     67        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     68    }
     69    my $mdcParser = PS::IPP::Metadata::Config->new;
     70    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     71
     72    my $active_recipe = '';
     73    my %recipes = ();
     74   
     75#    print Dumper($metadata);
     76    foreach my $entry (@{ $metadata }) {
     77        if (${ $entry }{name} eq 'ACTIVE') {
     78            $active_recipe = ${ $entry }{value}; # Not actually used
     79        }
     80        else {
     81            if (${ $entry }{class} eq 'metadata') { # A real recipe
     82                my $name = ${ $entry }{name};
     83                foreach my $tentry (@{ ${ $entry }{value} }) {
     84                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     85                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     86                    }
     87                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     88                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     89                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     90                        }
     91                    }
     92                }
     93            }
     94        }
     95    }
     96   
     97    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
     98#    print Dumper(%recipes);
     99    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
     100#    print Dumper(\%remote_recipe);
     101}
     102
     103my $remote_root = $remote_recipe{REMOTE_ROOT};
    26104my $remote_raw  = "${remote_root}/tmp/";  # Directory to find raw data in.
    27105
     
    51129$job_subscription{"ff"} = 1;
    52130
    53 my $proc_per_node = 24;                     # processors per node
    54 my $min_nodes     = 1;                      # smallest allocation to ask for
    55 my $max_nodes     = 1000;                   # largest allocation to ask for
    56 my $min_time      = 1;                      # shortest allocation to ask for
    57 my $max_time      = 8;                      # longest allocation to ask for
     131my $proc_per_node = $remote_recipe{PROC_PER_NODE};  # processors per node
     132my $min_nodes     = $remote_recipe{MIN_NODES};      # smallest allocation to ask for
     133my $max_nodes     = $remote_recipe{MAX_NODES};      # largest allocation to ask for
     134my $min_time      = $remote_recipe{MIN_TIME};       # shortest allocation to ask for
     135my $max_time      = $remote_recipe{MAX_TIME};       # longest allocation to ask for
    58136
    59137# We need to ensure we only ever try to transfer a file once.
    60138my %file_filter = ();
    61139
    62 # Look for programs we need
    63 my $missing_tools;
    64 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    65 
    66 if ($missing_tools) {
    67     warn("Can't find required tools.");
    68     exit($PS_EXIT_CONFIG_ERROR);
    69 }
    70 
    71 # Options
    72 my ($remote_id,$stage,$camera,$path_base,$dbname,$verbose,$no_update);
    73 GetOptions(
    74     'remote_id=s'    => \$remote_id,
    75     'stage=s'        => \$stage,
    76     'camera|c=s'     => \$camera,
    77     'path_base=s'    => \$path_base,
    78     'dbname|d=s'     => \$dbname,
    79     'verbose'        => \$verbose,
    80     'no_update'      => \$no_update,
    81     ) or pod2usage( 2 );
    82 
    83 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    84 pod2usage( -msg => "Required options: --remote_id --stage --camera --dbname --path_base", -exitval => 3) unless
    85     defined($remote_id) and
    86     defined($stage) and
    87     defined($camera) and
    88     defined($path_base) and
    89     defined($dbname);
    90 
     140
     141# Finish setup
    91142my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    92143
Note: See TracChangeset for help on using the changeset viewer.