Skip to content

Commit

Permalink
assert base attrs are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
CSY-ModelCloud committed Dec 4, 2024
1 parent 62e49cb commit 0cc1860
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion device_smi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class Device:
def __init__(self, device):

# init attribute first to avoid IDE not attr warning
# CPU/GPU Device
self.memory_total = None
self.type = None
Expand All @@ -35,6 +35,9 @@ def __init__(self, device):
device_index = device.index
elif f"{device}".lower() == "os":
self.device = OSDevice(self)
assert self.arch
assert self.version
assert self.name
return
else:
d = f"{device}".lower()
Expand Down Expand Up @@ -79,6 +82,12 @@ def __init__(self, device):
else:
raise Exception(f"The device {device_type} is not supported")

assert self.memory_total
assert self.type
assert self.features
assert self.vendor
assert self.model

def info(self):
warnings.warn(
"info() method is deprecated and will be removed in next release.",
Expand Down

0 comments on commit 0cc1860

Please sign in to comment.