Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Nov 26, 2024
1 parent 411155a commit 77a4e20
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/aleph/vm/orchestrator/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,12 @@ class MachineUsage(BaseModel):
def parse_device_info(line) -> GpuProperties:
"""Parse device info from a line of lspci output."""

parts = line.split(" ", maxsplit=1)
domain_bus_device_func = parts[0]

device = parts[1].split(": ", maxsplit=1)
device_class_name, device_class_code = device[0].split(" [", maxsplit=1)
domain_bus_device_func, device = line.split(" ", maxsplit=1)
device_class, device_info = device.split(": ", maxsplit=1)
device_class_name, device_class_code = device_class.split(" [", maxsplit=1)
device_class_code = device_class_code.split("]", maxsplit=1)[0]

device_details = device[1].split(" [", maxsplit=1)
device_name = device_details[0]
vendor_and_device_id, extra = device_details[1].split("]", maxsplit=1)
device_name, device_details = device_info.split(" [", maxsplit=1)
vendor_and_device_id, extra = device_details.split("]", maxsplit=1)
revision = extra.split(" (rev ", maxsplit=1)[1][:-1] if "rev" in extra else None

return GpuProperties(
Expand Down

0 comments on commit 77a4e20

Please sign in to comment.