Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion slurm2sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ def calc(row):
m_used = RE_TRES_MEM.search(row['TRESUsageInTot'])
m_alloc = RE_TRES_MEM.search(row['AllocTRES'])
if m_alloc and m_used:
return float_bytes(m_used.group(1)) / float_bytes(m_alloc.group(1))
alloc = float_bytes(m_alloc.group(1))
if alloc == 0: return None
return float_bytes(m_used.group(1)) / alloc
return None


Expand Down
12 changes: 12 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ def test_cpueff(db):
assert fetch(db, 1, 'TotalCPU') == 1500
assert fetch(db, 1, 'CPUeff', table='eff') == 0.5

def test_memeff(db):
data = """
JobID,AllocTRES,TRESUsageInTot
1,mem=1000K,mem=500K
2,mem=0K,mem=0K
"""
slurm2sql.slurm2sql(db, [], csv_input=csvdata(data))
print(db.execute('select * from eff;').fetchall())
assert fetch(db, 1, 'Memeff', table='eff') == 0.5
assert fetch(db, 2, 'Memeff', table='eff') == None


def test_gpueff(db):
data = """
JobID,AllocTRES,TRESUsageInTot
Expand Down