[Bio] / FortyEight / SGE.pm Repository:
ViewVC logotype

Diff of /FortyEight/SGE.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed Sep 5 21:42:54 2007 UTC revision 1.2, Mon Nov 10 22:46:02 2008 UTC
# Line 4  Line 4 
4  use XML::LibXML;  use XML::LibXML;
5  use strict;  use strict;
6  use Data::Dumper;  use Data::Dumper;
7    use FIG_Config;
8    
9  #  #
10  # Utilities for dealing with a SGE-enabled cluster.  # Utilities for dealing with a SGE-enabled cluster.
# Line 19  Line 20 
20    
21      bless $self, $class;      bless $self, $class;
22    
23        #
24        # Initialize our environment with the SGE stuff we need.
25        #
26        my $sge_root = $FIG_Config::sge_root || "/vol/sge";
27        my $sge_cell = $FIG_Config::sge_cell || "default";
28    
29        my %env = map { /^([^=]+)=(.*)/  } `. $sge_root/$sge_cell/common/settings.sh; set`;
30        for my $k (grep { /SGE/ } keys %env)
31        {
32            $ENV{$k} = $env{$k};
33        }
34        my $arch = `$sge_root/util/arch`;
35        chomp $arch;
36        $ENV{PATH} = "$sge_root/bin/$arch:$ENV{PATH}" if $arch;
37    
38      $self->read_qstat();      $self->read_qstat();
39    
40      return $self;      return $self;
# Line 59  Line 75 
75      my($self, $job) = @_;      my($self, $job) = @_;
76    
77      push @{$self->{jobs}->{$job->id}}, $job;      push @{$self->{jobs}->{$job->id}}, $job;
78    
79        #
80        # Also push into job/task index. We need to expand tasks that show up as
81        # a-b:n,a-b etc
82        #
83    
84        my @tlist = split(/,/, $job->tasks);
85        for my $tent (@tlist)
86        {
87            if ($tent =~ /^\d+$/)
88            {
89                $self->{tasks}->{$job->id, $tent} = $job;
90            }
91            elsif ($tent =~ /^(\d+)-(\d+)$/)
92            {
93                map { $self->{tasks}->{$job->id, $_} = $job } $1..$2;
94            }
95            elsif ($tent =~ /^(\d+)-(\d+):(\d+)$/)
96            {
97                for (my $t = $1; $t <= $2; $t += $3)
98                {
99                    $self->{tasks}->{$job->id, $t} = $job;
100                }
101            }
102            else
103            {
104                die "unknown task specifier '$tent'\n";
105            }
106    
107        }
108  }  }
109    
110  #  #
# Line 85  Line 131 
131      return @running;      return @running;
132  }  }
133    
134    sub find_task
135    {
136        my($self, $job, $task) = @_;
137    
138        return $self->{tasks}->{$job, $task};
139    }
140    
141  sub submit_job  sub submit_job
142  {  {
143      my($self, $meta, $sge_args, $cmd) = @_;      my($self, $meta, $sge_args, $cmd) = @_;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3