MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / parse_devices

Function parse_devices

utils.py:180–200  ·  view source on GitHub ↗

Parse user's devices input str to standard format. e.g. [gpu0, gpu1, ...]

(input_devices)

Source from the content-addressed store, hash-verified

178
179
180def parse_devices(input_devices):
181
182 """Parse user's devices input str to standard format.
183 e.g. [gpu0, gpu1, ...]
184
185 """
186 ret = []
187 for d in input_devices.split(','):
188 for regex, func in REGEX:
189 m = regex.match(d.lower().strip())
190 if m:
191 tmp = func(m.groups())
192 # prevent duplicate
193 for x in tmp:
194 if x not in ret:
195 ret.append(x)
196 break
197 else:
198 raise NotSupportedCliException(
199 'Can not recognize device: "{}"'.format(d))
200 return ret

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected