Skip to content

Commit

Permalink
Allow empty GPU type
Browse files Browse the repository at this point in the history
  • Loading branch information
Anbang-Hu committed Jan 17, 2020
1 parent 3cc914f commit 36e0f83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
13 changes: 0 additions & 13 deletions src/utils/resource_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,6 @@ def __ne__(self, other):

class Gpu(ResourceStat):
def __init__(self, res=None):
if res is None:
res = {}
elif isinstance(res, Gpu):
res = res.resource
elif not isinstance(res, dict):
res = {}

# Disallow empty string for gpu type
res_keys = list(res.keys())
for k in res_keys:
if k == "":
res.pop(k)

ResourceStat.__init__(self, res=res)


Expand Down
11 changes: 4 additions & 7 deletions src/utils/test_resource_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from resource_stat import ResourceStat, Gpu, Cpu, Memory


class TestResource(TestCase):
class TestResourceStat(TestCase):
def init_with_class(self):
self.cls_name = ResourceStat

Expand Down Expand Up @@ -177,19 +177,16 @@ def test_ne(self):
self.assertTrue(t2 != self.a)


class TestGpu(TestResource):
class TestGpu(TestResourceStat):
def init_with_class(self):
self.cls_name = Gpu

def test_empty_gpu_type(self):
self.assertEqual(Gpu(), Gpu({"": 1}))


class TestCpu(TestResource):
class TestCpu(TestResourceStat):
def init_with_class(self):
self.cls_name = Cpu


class TestMemory(TestResource):
class TestMemory(TestResourceStat):
def init_with_class(self):
self.cls_name = Memory

0 comments on commit 36e0f83

Please sign in to comment.