Commit 78d1787a authored by Mark Hymers's avatar Mark Hymers

Handle h_vmem more sensibly

Signed-off-by: Mark Hymers's avatarMark Hymers <mark.hymers@ynic.york.ac.uk>
parent d4229d21
......@@ -3,6 +3,7 @@
from os import popen
from sys import argv
from getpass import getuser
from math import ceil
import time
from datetime import datetime
......@@ -14,6 +15,16 @@ import wx
# Start Queue Utilities
############################################################################
def parse_memory(s):
if s.lower().endswith('g'):
return 1024 * 1024 * 1024 * int(s[:-1])
elif s.lower().endswith('m'):
return 1024 * 1024 * int(s[:-1])
elif s.lower().endswith('k'):
return 1024 * int(s[:-1])
else:
return int(s[:-1])
class QueueJob(object):
def __init__(self, xml=None):
self.job_number = None
......@@ -29,6 +40,8 @@ class QueueJob(object):
self.parse_xml(xml)
def parse_xml(self, job_list):
num_slots_direct = 1
num_slots_mem = 0
for i in job_list.getchildren():
if i.tag == 'JB_job_number':
self.job_number = i.text
......@@ -43,10 +56,20 @@ class QueueJob(object):
elif i.tag == 'JAT_start_time':
self.start_time = datetime.strptime(i.text, '%Y-%m-%dT%H:%M:%S')
elif i.tag == 'slots':
self.num_slots = int(i.text)
num_slots_direct = int(i.text)
elif i.tag == 'master':
if i.text == 'SLAVE':
self.master = False
elif i.tag == 'hard_request':
# This is a bit hard-coded for now, if we've asked for
# more h_vmem than the default, work out how many slots
# that is equivalent to; we have 8G per slot
BYTES_PER_SLOT = 1024 * 1024 * 1024 * 8
if i.get('name') == 'h_vmem':
num_bytes = parse_memory(i.text)
num_slots_mem = int(ceil(num_bytes / BYTES_PER_SLOT))
self.num_slots = max(num_slots_direct, num_slots_mem)
def __repr__(self):
s = '[QueueJob: ID: %s' % self.job_number
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment