MCPcopy Create free account
hub / github.com/mlco2/codecarbon / test_normalize_gpu_ids

Method test_normalize_gpu_ids

tests/test_config.py:70–82  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

68 self.assertEqual(parse_gpu_ids(ids), target)
69
70 def test_normalize_gpu_ids(self):
71 for ids, target in [
72 (None, None),
73 ("0,1,2", ["0", "1", "2"]),
74 ("MIG-f1e$%^", ["MIG-f1e"]),
75 ([1, 2, 3], [1, 2, 3]),
76 (
77 [0, "MIG-f1e$%^", "1, 2", "GPU-abcd!"],
78 [0, "MIG-f1e", "1", "2", "GPU-abcd"],
79 ),
80 ([0, {"invalid": "entry"}, "GPU-123"], [0, "GPU-123"]),
81 ]:
82 self.assertEqual(normalize_gpu_ids(ids), target)
83
84 @mock.patch.dict(
85 os.environ,

Callers

nothing calls this directly

Calls 1

normalize_gpu_idsFunction · 0.90

Tested by

no test coverage detected