Grid-Request

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

t/23-getenv.t
t/24-multi-cmd-async.t
t/25-multi-cmd-serial.t
t/26-multi-cmd-to_xml.t
t/27-multi-opsys.t
t/28-block_size.t
t/29-test_mw_determination.t
t/30-account.t
t/31-dir_mw.t
t/32-new_command.t
t/33-job_formulator.t
t/34-show_invocations.t
t/35-shell_escaping.t
t/run_tests.pl
t/testlogger.conf
t/test_data/notify.sh
t/test_data/test_dir/10
t/test_data/test_dir/11
t/test_data/test_dir/12
t/test_data/test_dir/13
t/test_data/test_dir/50

META.json  view on Meta::CPAN

{
   "abstract" : "Easily formulate, submit, and monitor grid jobs.",
   "author" : [
      "unknown"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001",
   "license" : [
      "unknown"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Easily formulate, submit, and monitor grid jobs.'
author:
  - unknown
build_requires:
  ExtUtils::MakeMaker: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001'
license: unknown
meta-spec:

Makefile.PL  view on Meta::CPAN

#  make test
#  make install

BEGIN {
    require 5.6.0;
}

# See `perldoc ExtUtiles::MakeMaker` 
WriteMakefile(
    NAME          => 'Grid::Request',
    ABSTRACT      => 'Easily formulate, submit, and monitor grid jobs.',
    EXE_FILES     => [ 
                       "src/grid_request_worker",
                     ],
    VERSION_FROM  => 'VERSION', # finds $VERSION
    PREREQ_PM     => { Carp             => 0,
                       Config::IniFiles => 2.19,
                       Exception::Class => 1.23,
                       File::Path       => 1.0403,
                       File::Temp       => 0.12,
                       File::Which      => 0.05,

lib/Grid/Request.pm  view on Meta::CPAN

sub show_invocations {
    my $self = shift;

    # Remember, we may have multiple command objects...
    my @command_objs = $self->_com_obj_list();

    # Iterate over them...
    my $command_count = 1;

    eval { require Grid::Request::JobFormulator };
    my $formulator = Grid::Request::JobFormulator->new();

    foreach my $com_obj (@command_objs) {
        print "Command #" . $command_count . "\n"; 
        my $exe = $com_obj->command();
        my $block_size = $com_obj->block_size();
        my @params = $com_obj->params();
        my @param_strings = ();

        foreach my $param_obj (@params) {
            my $param_str = $param_obj->to_string();
            push (@param_strings, $param_str);
        }

        my @invocations = $formulator->formulate($block_size, $exe, @param_strings);
        foreach my $invocations (@invocations) {
            my @cli = @$invocations;
            my @esc_cli = _esc_chars(@cli);
            print join(" ", @esc_cli) . "\n";
        }
        
        $command_count++;
    }
}

lib/Grid/Request/JobFormulator.pm  view on Meta::CPAN

    $VERSION = $VERSION;
}

# The constructor.
sub new {
    my ($class, %args) = @_;
    my $self = bless {}, $class || ref($class);
    return $self;
}

sub formulate {
    $logger->debug("In formulate.");

    # The first argument is the blocksize, or how many invocations each worker
    # will be processing. The second argument is the executable to invoke to
    # invoke, and the remaining arguments are the MW parameters.
    my ($self, $blocksize, $executable, @mw_params) = @_; 

    if (! defined $blocksize || $blocksize <= 0) {
        Grid::Request::Exception->throw("Bad blocksize. Must be >= 1.");
    } else {
        $logger->debug("Blocksize: $blocksize");

src/grid_request_worker  view on Meta::CPAN

# If we are here, then the MW parameters look fine.
$logger->debug("MW parameters validated correctly.");

if (! defined $task_id || $task_id <= 0) {
    $logger->logdie("Unable to determine this worker's ID.");
}
$logger->info("Task id for this worker: $task_id");

# an array of arrays for all the parameters to invoke
my $jb = Grid::Request::JobFormulator->new();
my @invocations = $jb->formulate($block_size, $executable, @mw_params);

execute(\@invocations);

#############################################################################

sub execute {
    $logger->debug("In execute.");
    my ($arg_group_ref) = @_;
    my ($success, $failed) = (0,0);
    my $count = 0;

src/grid_request_worker  view on Meta::CPAN

        
        # This loop is to iterate across the argument arrays
        for (my $arg_index = 0; $arg_index < $arg_length; $arg_index++) {
            $count++;

            my @exec = ();

            for (my $group_index = 0; $group_index < $group_size; $group_index++) {
                my $arg = $arg_group_ref->[$group_index]->[$arg_index];

                # TODO: This should be done in the JobFormulator formulate() method
                # Replace $(Index) with the task id.
                $arg =~ s/\$\(Index\)/$task_id/g;
                
                push(@exec, $arg);
            }

            $logger->info("Invoking: ", sub { join(" ", @exec) } );

            if ($logger->is_debug()) {
                $logger->debug("Arg list for invokation of $executable:\n", sub{ Dumper(\@exec) } );

t/15-shell_script.t  view on Meta::CPAN


# Get the configured temporary directory
my $tempdir = $req->_config()->val($Grid::Request::HTC::config_section, "tempdir");

if (! defined $tempdir || ! -d $tempdir) {
    plan skip_all => 'tempdir not configured or not a directory.';
} else {
    plan tests => 5;
}

# Create the shell script we will submit and formulate the name of the output file
my $base = basename($0);
my $script = "$tempdir/test-${base}.sh";
my $output = $script . '.out';

# Remove files in case they are there from a previous run.
cleanup();

create_shell_script($script);

ok(-f $script, "Shell script created.");

t/33-job_formulator.t  view on Meta::CPAN

use strict;
use FindBin qw($Bin);
use File::Basename;
use File::Path;
use lib ("$Bin/../lib");
use Test::More tests => 7;
use Grid::Request::Test;
use_ok("Grid::Request::JobFormulator");

my $blocksize = 100;
my $formulator = Grid::Request::JobFormulator->new();

can_ok($formulator, ("formulate"));

test_dir();
test_file();
test_param_dir();
test_param_file();
test_limiting_files();

sub test_dir {
    my $dir = "$Bin/test_data/test_dir";

    my $executable = "/bin/echo";
    my $dir_param = Grid::Request::Param->new('DIR:' . $dir . ':$(Name)');

    my $dir_param_str = $dir_param->to_string();

    my @invocations = $formulator->formulate($blocksize, $executable, ( $dir_param_str ));

    is(scalar @invocations, 100, "Correct number of jobs for a dir param.");
}

sub test_file {
    my $file = "$Bin/test_data/test_file.txt";

    my $executable = "/bin/echo";
    my $file_param = Grid::Request::Param->new('FILE:' . $file . ':$(Name)');

    my $file_param_str = $file_param->to_string();

    my @invocations = $formulator->formulate($blocksize, $executable, ( $file_param_str ));
    #foreach my $inv (@invocations) { print join(" ", @$inv) . "\n"; }

    is(scalar @invocations, 100, "Correct number of jobs for a file param.");
}

sub test_param_dir {
    my $dir = "$Bin/test_data/test_dir";

    my $executable = "/bin/echo";
    my $regular_param = Grid::Request::Param->new('PARAM:regular');
    my $dir_param = Grid::Request::Param->new('DIR:' . $dir . ':$(Name)');

    my $dir_param_str = $dir_param->to_string();
    my $regular_param_str = $regular_param->to_string();

    my @invocations = $formulator->formulate($blocksize, $executable, ( $regular_param_str, $dir_param_str ));
    #foreach my $inv (@invocations) { print join(" ", @$inv) . "\n"; }

    is(scalar @invocations, 100, "Correct number of jobs for a dir param w/ regular param.");
}

sub test_param_file {
    my $file = "$Bin/test_data/test_file.txt";

    my $executable = "/bin/echo";
    my $regular_param = Grid::Request::Param->new('PARAM:regular');
    my $file_param = Grid::Request::Param->new('FILE:' . $file . ':$(Name)');

    my $file_param_str = $file_param->to_string();
    my $regular_param_str = $regular_param->to_string();

    my @invocations = $formulator->formulate($blocksize, $executable, ( $regular_param_str, $file_param_str ));
    #foreach my $inv (@invocations) { print join(" ", @$inv) . "\n"; }

    is(scalar @invocations, 100, "Correct number of jobs for a file param with regular param.");
}

# This test examines the ability to deal with varying array sizes. We accomplish this by
# specifyng two files, with varying sizes.
sub test_limiting_files {
    my $executable = "/bin/echo";
    my $test_file = "$Bin/test_data/test_file.txt";

t/33-job_formulator.t  view on Meta::CPAN

    my $regular_param = Grid::Request::Param->new('PARAM:regular');
    my $file_param = Grid::Request::Param->new('FILE:' . $test_file . ':$(Name)');

    my $smaller_param_str = $smaller_file_param->to_string();
    my $regular_param_str = $regular_param->to_string();
    my $file_param_str = $file_param->to_string();

    # Gather these param strings into an array for ease of legibility
    my @params = ($smaller_param_str, $regular_param_str, $file_param_str);

    my @invocations = $formulator->formulate($blocksize, $executable, @params);
    #foreach my $inv (@invocations) { print join(" ", @$inv) . "\n"; }

    diag("Number of invocations: " . scalar @invocations);
    ok(scalar @invocations < 100, "Invocation limitation seems to have worked.");
}



( run in 0.945 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )