summaryrefslogtreecommitdiff
path: root/environment
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-10 20:03:53 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-10 20:03:53 +0000
commit963b7b96576de000a743ef377c439ea5c6787e2e (patch)
treec44b113de22473a74b831867dd2c8fed8d4d56f4 /environment
parent86ae2fcf6207630c03ec222131346a6fd8fee10a (diff)
support for running in multiple environments which are automatically detected
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@501 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'environment')
-rw-r--r--environment/LocalConfig.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/environment/LocalConfig.pm b/environment/LocalConfig.pm
new file mode 100644
index 00000000..e4269361
--- /dev/null
+++ b/environment/LocalConfig.pm
@@ -0,0 +1,68 @@
+package LocalConfig;
+
+use strict;
+use warnings;
+
+use base 'Exporter';
+our @EXPORT = qw( qsub_args mert_memory environment_name );
+
+use Net::Domain qw(hostname hostfqdn hostdomain domainname);
+
+my $host = domainname;
+
+# keys are: HOST_REGEXP, MERTMem, QSubQueue, QSubMemFlag, QSubExtraFlags
+my $CCONFIG = {
+ 'LTICluster' => {
+ 'HOST_REGEXP' => qr/^cluster\d+\.lti\.cs\.cmu\.edu$/,
+ 'QSubMemFlag' => '-l pmem=',
+ 'QSubQueue' => '-q long',
+ },
+ 'UMIACS' => {
+ 'HOST_REGEXP' => qr/^d.*\.umiacs\.umd\.edu$/,
+ 'QSubMemFlag' => '-l pmem=',
+ 'QSubQueue' => '-q batch',
+ 'QSubExtraFlags' => '-l walltime=144:00:00',
+ },
+ 'CLSP' => {
+ 'HOST_REGEXP' => qr/\.clsp\.jhu\.edu$/,
+ 'QSubMemFlag' => '-l mem_free=',
+ 'MERTMem' => '9G',
+ },
+ 'Valhalla' => {
+ 'HOST_REGEXP' => qr/^(thor|tyr)\.inf\.ed\.ac\.uk$/,
+ },
+};
+
+our $senvironment_name;
+for my $config_key (keys %$CCONFIG) {
+ my $re = $CCONFIG->{$config_key}->{'HOST_REGEXP'};
+ die "Can't find HOST_REGEXP for $config_key" unless $re;
+ if ($host =~ /$re/) {
+ $senvironment_name = $config_key;
+ }
+}
+
+die "NO ENVIRONMENT INFO FOR HOST: $host\nPLEASE EDIT LocalConfig.pm\n" unless $senvironment_name;
+
+our %CONFIG = %{$CCONFIG->{$senvironment_name}};
+print STDERR "**Environment: $senvironment_name\n";
+
+sub environment_name {
+ return $senvironment_name;
+}
+
+sub qsub_args {
+ my $mem = shift @_;
+ die "qsub_args requires a memory amount as a parameter, e.g. 4G" unless $mem;
+ my $mf = $CONFIG{'QSubMemFlag'} or die "QSubMemFlag not set for $senvironment_name";
+ my $cmd = "qsub -S /bin/bash ${mf}${mem}";
+ if ($CONFIG{'QSubQueue'}) { $cmd .= ' ' . $CONFIG{'QSubQueue'}; }
+ if ($CONFIG{'QSubExtraFlags'}) { $cmd .= ' ' . $CONFIG{'QSubExtraFlags'}; }
+ return $cmd;
+}
+
+sub mert_memory {
+ return ($CONFIG{'MERTMem'} || '2G');
+};
+
+1;