From b945c610b18dfa60db3016dbc47a5cad2acd5518 Mon Sep 17 00:00:00 2001 From: "Mads M. Pedersen" <mmpe@dtu.dk> Date: Thu, 13 Oct 2016 08:30:24 +0200 Subject: [PATCH] hostname to parse_qstat_n1 --- wetb/utils/cluster_tools/cluster_resource.py | 8 +++--- wetb/utils/cluster_tools/pbswrap.py | 26 ++++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/wetb/utils/cluster_tools/cluster_resource.py b/wetb/utils/cluster_tools/cluster_resource.py index 49faaf3f..4ae9d065 100644 --- a/wetb/utils/cluster_tools/cluster_resource.py +++ b/wetb/utils/cluster_tools/cluster_resource.py @@ -62,7 +62,7 @@ class SSHPBSClusterResource(Resource, SSHClient): pbsnodes, nodes = pbswrap.parse_pbsnode_lall(output.split("\n")) _, output, _ = self.execute('qstat -n1') - users, host, nodesload = pbswrap.parse_qstat_n1(output.split("\n")) + users, host, nodesload = pbswrap.parse_qstat_n1(output.split("\n"), self.host) # if the user does not have any jobs, this will not exist @@ -76,10 +76,8 @@ class SSHPBSClusterResource(Resource, SSHClient): return nodeSum['used_cpu'] + cpu_free, cpu_free, cpu_user except Exception as e: - if str(e) == "Password not set": - raise EnvironmentError(str(e)) - else: - raise EnvironmentError("check resources failed") + raise EnvironmentError(str(e)) + def jobids(self, jobname_prefix): _, output, _ = self.execute('qstat -u %s' % self.username) diff --git a/wetb/utils/cluster_tools/pbswrap.py b/wetb/utils/cluster_tools/pbswrap.py index 2b10eb21..0c98858c 100644 --- a/wetb/utils/cluster_tools/pbswrap.py +++ b/wetb/utils/cluster_tools/pbswrap.py @@ -176,7 +176,7 @@ def parse_pbsnode_lall(output): return pbsnodes, nodes -def parse_qstat_n1(output): +def parse_qstat_n1(output, hostname=None): """ Parse the output of qstat -n1 """ @@ -188,26 +188,22 @@ def parse_qstat_n1(output): host = {} users = {} # get the hostname - hostname = socket.gethostname() - if hostname[:5] == 'g-000': - host['name'] = 'gorm' - host['cpu_per_node'] = 12 - else: - # 272 nodes are 2 x 10 core (twenty) processors + if hostname is None: + hostname = socket.gethostname() + if 'jess' in hostname: host['name'] = 'jess' - #total_nodes = 80 host['cpu_per_node'] = 20 + else: + host['name'] = 'gorm' + host['cpu_per_node'] = 12 + # take the available nodes in nr_nodes: it excludes the ones # who are down #queue['_total_cpu_'] = cpu_node*nr_nodes - ii = 0 - for line in output: - # first 5 are not relevant - if ii < 5: - ii += 1 + for line in output[5:]: + if len(line.strip()) == 0: continue - items = line.split() queue = items[2] @@ -268,8 +264,6 @@ def parse_qstat_n1(output): except KeyError: nodesload[node] = [userid] - ii += 1 - return users, host, nodesload # FIXME: counts diffferent compared to launch.py.... -- GitLab