Skip to content
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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

aliel
Copy link
Member

@aliel aliel commented Feb 16, 2024

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

@github-actions github-actions bot added the BLUE This PR is simple and straightforward. label Feb 16, 2024
@aliel aliel force-pushed the aliel-feature-add-cpu-mem-capability branch 3 times, most recently from 54ff260 to 7185d02 Compare February 20, 2024 14:09
Copy link
Member

@hoh hoh left a 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"
Copy link
Member

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 ?

Copy link
Member Author

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.

@hoh
Copy link
Member

hoh commented Feb 20, 2024

Can you also provide an example of the JSON format returned by the API ?

@aliel aliel force-pushed the aliel-feature-add-cpu-mem-capability branch from 7185d02 to 9df2486 Compare March 5, 2024 14:42
src/aleph/vm/orchestrator/machine.py Outdated Show resolved Hide resolved

@lru_cache
def get_hardware_info():
lshw = subprocess.Popen(["lshw", "-sanitize", "-json"], stdout=subprocess.PIPE, shell=False)
Copy link
Member

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.

src/aleph/vm/orchestrator/machine.py Outdated Show resolved Hide resolved
@hoh hoh force-pushed the aliel-feature-add-cpu-mem-capability branch from 9df2486 to 55fae43 Compare March 7, 2024 16:12
@hoh
Copy link
Member

hoh commented Mar 7, 2024

Rebased on main.

"type": memory_type,
"clock": memory_clock,
"clock_units": "Hz",
}
Copy link
Member

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(),
}
Copy link
Member

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 ?

@hoh hoh assigned aliel Mar 7, 2024
@aliel aliel force-pushed the aliel-feature-add-cpu-mem-capability branch from 55fae43 to 1ae4da2 Compare April 5, 2024 09:38
…cpuinfo

Add CPU information (model, vendor, frequency) and memory details (clock, size, type) to API
@aliel aliel force-pushed the aliel-feature-add-cpu-mem-capability branch 2 times, most recently from 3bcda91 to a483efd Compare April 5, 2024 10:09
… concurrency

avoid Try-Catch using assertions
@aliel aliel force-pushed the aliel-feature-add-cpu-mem-capability branch from a483efd to a4d2a5c Compare April 5, 2024 10:26
@hoh hoh requested a review from olethanh April 9, 2024 12:41
@aleph-im aleph-im deleted a comment from github-actions bot Apr 9, 2024
memory_clock = ""

for bank in mem_info["children"]:
memory_clock = bank["clock"]
Copy link
Collaborator

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'}}

it's not really important but it was somehow anoying me
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 42.68293% with 47 lines in your changes are missing coverage. Please review.

Project coverage is 43.73%. Comparing base (7b89523) to head (4795a85).

Current head 4795a85 differs from pull request most recent head befc521

Please upload reports for the commit befc521 to get more accurate results.

Files Patch % Lines
src/aleph/vm/orchestrator/machine.py 17.07% 34 Missing ⚠️
src/aleph/vm/orchestrator/resources.py 70.00% 9 Missing ⚠️
src/aleph/vm/utils.py 60.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLUE This PR is simple and straightforward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants