-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CPU information (model, vendor, frequency) and memory details (clock, size, type) to API #544
base: main
Are you sure you want to change the base?
Conversation
54ff260
to
7185d02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have automated tests that ensure that this is working fine ?
Maybe in the .github/workflows/test-on-droplets-matrix.yml
file ?
if "x86_64" in cpu_info["capabilities"] or "x86-64" in cpu_info["capabilities"]: | ||
architecture = "x86_64" | ||
elif "arm64" in cpu_info["capabilities"] or "arm-64" in cpu_info["capabilities"]: | ||
architecture = "arm64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really the best approach to get the architecture ? Seems weird to look for it in the CPU capabilities.
What if a 32 bit system is running on a x86-64 capable system ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we want to know the architecture supported by the processor, not by the system
Obviously, 64-bit processors support 32-bit systems, but not vice versa.
Can you also provide an example of the JSON format returned by the API ? |
7185d02
to
9df2486
Compare
src/aleph/vm/orchestrator/machine.py
Outdated
|
||
@lru_cache | ||
def get_hardware_info(): | ||
lshw = subprocess.Popen(["lshw", "-sanitize", "-json"], stdout=subprocess.PIPE, shell=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A check in the settings that verifies that lshw
is available on the machine would be a good addition.
9df2486
to
55fae43
Compare
Rebased on |
"type": memory_type, | ||
"clock": memory_clock, | ||
"clock_units": "Hz", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return an instance of MemoryProperties
?
"model": cpu_info["product"], | ||
"frequency": cpu_info["capacity"], | ||
"count": psutil.cpu_count(), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return a dict and not instances of the Properties / Capabilities classes defined blow in the diff ?
55fae43
to
1ae4da2
Compare
…cpuinfo Add CPU information (model, vendor, frequency) and memory details (clock, size, type) to API
3bcda91
to
a483efd
Compare
… concurrency avoid Try-Catch using assertions
a483efd
to
a4d2a5c
Compare
src/aleph/vm/orchestrator/machine.py
Outdated
memory_clock = "" | ||
|
||
for bank in mem_info["children"]: | ||
memory_clock = bank["clock"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On CRN-TEST-2204 I have this in mem_info. No clock key. Should I remove the information conditionally?
{'capabilities': {'ecc': 'Multi-bit error-correcting code (ECC)'},
'children': [{'claimed': True,
'class': 'memory',
'description': 'DIMM RAM',
'handle': 'DMI:1100',
'id': 'bank',
'physid': '0',
'size': 17179869184,
'slot': 'DIMM 0',
'units': 'bytes',
'vendor': 'QEMU'}],
'claimed': True,
'class': 'memory',
'configuration': {'errordetection': 'multi-bit-ecc'},
'description': 'System Memory',
'handle': 'DMI:1000',
'id': 'memory',
'physid': '1000',
'size': 17179869184,
'units': 'bytes'}}
Solution: Introduce our own decorator
it's not really important but it was somehow anoying me
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #544 +/- ##
===========================================
- Coverage 53.87% 43.73% -10.15%
===========================================
Files 58 56 -2
Lines 5310 5053 -257
Branches 594 598 +4
===========================================
- Hits 2861 2210 -651
- Misses 2311 2726 +415
+ Partials 138 117 -21 ☔ View full report in Codecov by Sentry. |
Update CPU and memory details by switching to lshw method instead of cpuinfo
Add CPU information (model, vendor, frequency) and memory details (clock, size, type) to API