[Bio] / FortyEight / get_number_of_external_jobs.pl Repository:
ViewVC logotype

View of /FortyEight/get_number_of_external_jobs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (download) (as text) (annotate)
Fri Feb 27 16:23:26 2009 UTC (10 years, 8 months ago) by wilke
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2009_07_09, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, HEAD
Changes since 1.6: +6 -1 lines
*** empty log message ***


=head1 check_jobs.pl

Check the status of the jobs in the 48-hour run queue to see if any 
action should be taken.

Actions taken are determined based on the metadata kept in meta.xml.

We do a quick check by looking for the file ACTIVE in the job directory.
If this file does not exist, the job should not be considered.

=cut

    
use strict;
use FIG;
use FIG_Config;
use GenomeMeta;
use Data::Dumper;
use Tracer;
use Job48;
use Mail::Mailer;

print "Jobs: ",$FIG_Config::fortyeight_jobs , "\n";

my @jobs = Job48::all_jobs();
print "Jobs: ",$FIG_Config::fortyeight_jobs , "\n";
my $exclude = { batch => 1 ,
		olson => 1 ,
		mkubal => 1 ,
		paczian => 1 ,
		dbartels => 1 ,
		tdisz => 1 ,
		paarmann => 1 ,
		mdsouza => 1 ,
		mcohoon => 1 ,
		arodriguez => 1 ,
		fmeyer => 1 , 
		gdpusch => 1 ,
		awilke => 1 ,
		vvons  => 1,
	      };

my %overview;

for my $job (@jobs)  {
  my $jobuser = $job->getUserObject();
  unless ($jobuser and ref $jobuser){
	print STDERR "No user for $job\n";
	next;
	}	
   print $jobuser->login."\t".$job->genome_name."\n";
  if ( $overview{ $jobuser->login }->{ $job->genome_name } ){ 
    my $nr = $overview{ $jobuser->login }->{ $job->genome_name };
    $nr++;
    $overview{ $jobuser->login }->{ $job->genome_name } = $nr;
  }
  else{
    $overview{ $jobuser->login }->{ $job->genome_name } = 1;
  }
}
  

my $nr_excluded = 0;
my $nr_external = 0;
foreach my $user ( keys %overview ){
  foreach my $genome ( keys %{ $overview{ $user } } ){
    if ( $exclude->{ $user } ){
      $nr_excluded++;
    }
    else{
      print $user , "\t" , $genome ,"\t", $overview{ $user }->{ $genome }, "\n";
      $nr_external++;
    }
  }
}

print "Jobs in current job directory = ". scalar @jobs ."\n";
print "Excluded jobs = $nr_excluded\n";
print "External jobs = $nr_external\n";

my $dbm = get_dbm();
#print scalar @{ get_user($dbm , "awilke") } , "\n";
print scalar @{ get_user($dbm) } , " Users\n";
print scalar @{ get_organisations($dbm) } , " Organisations\n";

sub get_user
{
    my($dbm, $user) = @_;
   
   
	
    my $users;
    if ( $user ){
      $users = $dbm->User->get_objects({ login => $user });
    }
    else{
      $users = $dbm->User->get_objects();
    }
    if ($users && @$users)
    {
	return $users;
    }
}
	     
 
sub get_organisations{
  my ($dbm, $org) = @_;
  my $organisations = $dbm->Organisation->get_objects();
  return $organisations;
}

sub get_dbm{

  my $old_env = $ENV{DBHOST};
  $ENV{DBHOST} = 'bioseed.mcs.anl.gov';
  my $dbm;
  eval {
    $dbm = DBMaster->new('FortyEight_WebApplication');
  };
  if ($@)
    {
      if ($@ =~ /No database name given/)
	{
	  $dbm = DBMaster->new(-database => 'FortyEight_WebApplication');
	}
      else
	{
	  die $@;
	}
    }
  return undef unless $dbm;
  $ENV{DBHOST} = $old_env;
  
  return $dbm;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3