Skip to content

Commit 36e0f83

Browse files
committed
Allow empty GPU type
1 parent 3cc914f commit 36e0f83

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/utils/resource_stat.py

-13
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,6 @@ def __ne__(self, other):
132132

133133
class Gpu(ResourceStat):
134134
def __init__(self, res=None):
135-
if res is None:
136-
res = {}
137-
elif isinstance(res, Gpu):
138-
res = res.resource
139-
elif not isinstance(res, dict):
140-
res = {}
141-
142-
# Disallow empty string for gpu type
143-
res_keys = list(res.keys())
144-
for k in res_keys:
145-
if k == "":
146-
res.pop(k)
147-
148135
ResourceStat.__init__(self, res=res)
149136

150137

src/utils/test_resource_stat.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from resource_stat import ResourceStat, Gpu, Cpu, Memory
55

66

7-
class TestResource(TestCase):
7+
class TestResourceStat(TestCase):
88
def init_with_class(self):
99
self.cls_name = ResourceStat
1010

@@ -177,19 +177,16 @@ def test_ne(self):
177177
self.assertTrue(t2 != self.a)
178178

179179

180-
class TestGpu(TestResource):
180+
class TestGpu(TestResourceStat):
181181
def init_with_class(self):
182182
self.cls_name = Gpu
183183

184-
def test_empty_gpu_type(self):
185-
self.assertEqual(Gpu(), Gpu({"": 1}))
186184

187-
188-
class TestCpu(TestResource):
185+
class TestCpu(TestResourceStat):
189186
def init_with_class(self):
190187
self.cls_name = Cpu
191188

192189

193-
class TestMemory(TestResource):
190+
class TestMemory(TestResourceStat):
194191
def init_with_class(self):
195192
self.cls_name = Memory

0 commit comments

Comments
 (0)