Beispiel #1
0
def get_memory(suffix='M'):
    """
    Queries a worker's /proc/meminfo for available memory and returns a float
    of the specified suffix size

    Args:
        suffix (str): One of 'M', 'K' or 'G' to return memory in Mib, KiB or
                      GiB, respectively.

    Returns:
        float: total_memory read from meminfo in MiB, KiB or GiB
            depending on specified suffix.
    Raises:
        dxpy.DXError is raised if suffix is not recognized or system memory
        cannot be read.
    """
    if suffix == 'K':
        shift = 1
    elif suffix == 'M':
        shift = 1 << 10
    elif suffix == 'G':
        shift = 1 << 20
    else:
        raise dxpy.DXError(
            'Unknown memory suffix {0}.  Please choose from K, M, or G.'.
            format(suffix))

    # Calc amount of memory available for gatk and Picard.
    total_mem = re.findall('^MemTotal:[\s]*([0-9]*) kB',
                           open('/proc/meminfo').read())
    if (len(total_mem) != 1):
        raise dxpy.DXError('Problem reading system memory from /proc/meminfo')
    return float(total_mem[0]) / shift
Beispiel #2
0
def get_memory(suffix='M'):
    if suffix == 'K':
        shift = 1
    elif suffix == 'M':
        shift = 1 << 10
    elif suffix == 'G':
        shift = 1 << 20
    else:
        raise dxpy.DXError('Unknown memory suffix {0}.  Please choose from K, M, or G.'.format(suffix))

    # Calc amount of memory available for gatk and Picard.
    total_mem = re.findall('^MemTotal:[\s]*([0-9]*) kB',
                           open('/proc/meminfo').read())
    if(len(total_mem) != 1):
        raise dxpy.DXError('Problem reading system memory from /proc/meminfo')
    return float(total_mem[0]) / shift
def get_java_cmd():
    # Calc amount of memory available for gatk and Picard.
    total_mem = re.findall('^MemTotal:[\s]*([0-9]*) kB',
                           open('/proc/meminfo').read())
    if (len(total_mem) != 1):
        raise dxpy.DXError('Problem reading system memory from /proc/meminfo')
    mem = int(0.9 * int(total_mem[0]) / 1024.0)
    java_cmd = 'java -Xmx{mem}m '.format(mem=mem)

    return java_cmd