Use lscompute for hardware detection#390
Merged
Merged
Conversation
Pass machine info down to pci selector, where it can do filtering
2694ce1 to
e7daac5
Compare
There was a problem hiding this comment.
Pull request overview
This PR replaces the project’s in-repo hardware detection/types (pkg/hardware_info, pkg/types) with github.com/canonical/lscompute machine detection/types, and updates engine selection + CLI commands/tests to consume *machine.MachineInfo instead of the removed *types.HwInfo.
Changes:
- Switch engine scoring and device matchers (CPU/PCI) to use
lscompute’smachine.MachineInfo. - Remove the legacy hardware detection implementation and related custom types/tests.
- Update CLI/docs/tests for YAML-first machine info and selection output; introduce in-code machine fixtures for tests.
Reviewed changes
Copilot reviewed 65 out of 67 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates select-engine documentation to accept YAML/JSON input and default YAML output. |
| pkg/utils/layout.go | Fixes package name to utils so Layout can be shared by manifests. |
| pkg/types/pci.go | Removes legacy PCI device type. |
| pkg/types/memory.go | Removes legacy memory type. |
| pkg/types/hw_info.go | Removes legacy host hardware info type. |
| pkg/types/hw_info_test.go | Removes tests for legacy HwInfo JSON parsing. |
| pkg/types/disk.go | Removes legacy disk stats type. |
| pkg/types/custom_types.go | Removes legacy HexInt and YAML/JSON marshaling. |
| pkg/types/cpu.go | Removes legacy CPU info type. |
| pkg/types/clinfo.go | Removes legacy clinfo JSON model. |
| pkg/selector/selection_test.go | Updates selector tests to use lscompute fixtures and YAML v4. |
| pkg/selector/select_stack.go | Changes scoring API to accept *machine.MachineInfo and passes through to matchers. |
| pkg/selector/pci/properties.go | Updates PCI property checks to use lscompute PCI device type. |
| pkg/selector/pci/pci.go | Reworks PCI matching to extract PCI devices from machineInfo.Devices. |
| pkg/selector/pci/pci_test.go | Updates PCI tests to use lscompute PCI device type and wrapper scoring structs. |
| pkg/selector/fixtures_test.go | Adds large, in-code MachineInfo fixtures for selector tests. |
| pkg/selector/filter_test.go | Updates filter tests to use machine.MachineInfo and YAML v4. |
| pkg/selector/cpu/cpu.go | Updates CPU matcher to use machine.MachineInfo / lscompute CPU types. |
| pkg/selector/cpu/cpu_test.go | Updates CPU tests for new matcher signature / lscompute CPU types. |
| pkg/selector/compatible_test.go | Updates compatibility tests to use MachineInfo fixtures and YAML v4. |
| pkg/runtimes/types.go | Switches runtime manifest Layout to utils.Layout. |
| pkg/models/types.go | Switches model manifest Layout to utils.Layout. |
| pkg/hardware_info/pci/pci_devices.go | Removes legacy PCI detection/augmentation. |
| pkg/hardware_info/pci/nvidia/nvidia.go | Removes legacy NVIDIA property collection entrypoint. |
| pkg/hardware_info/pci/nvidia/gpu.go | Removes legacy NVIDIA nvidia-smi parsing/exec logic. |
| pkg/hardware_info/pci/nvidia/gpu_test.go | Removes legacy NVIDIA VRAM parsing tests. |
| pkg/hardware_info/pci/lspci.go | Removes legacy lspci parsing. |
| pkg/hardware_info/pci/lspci_test.go | Removes legacy lspci parsing tests. |
| pkg/hardware_info/pci/intel/intel.go | Removes legacy Intel property collection entrypoint. |
| pkg/hardware_info/pci/intel/gpu.go | Removes legacy Intel clinfo parsing/exec logic. |
| pkg/hardware_info/pci/intel/gpu_test.go | Removes legacy Intel clinfo parsing tests. |
| pkg/hardware_info/pci/amd/gpu.go | Removes legacy AMD sysfs VRAM/microarch logic. |
| pkg/hardware_info/pci/amd/gpu_test.go | Removes legacy AMD GPU property tests. |
| pkg/hardware_info/pci/amd/amd.go | Removes legacy AMD property collection entrypoint. |
| pkg/hardware_info/memory/proc_meminfo.go | Removes legacy /proc/meminfo parsing. |
| pkg/hardware_info/memory/proc_meminfo_test.go | Removes legacy meminfo parsing test. |
| pkg/hardware_info/memory/memory_info.go | Removes legacy memory info collector. |
| pkg/hardware_info/hardware-info.go | Removes legacy top-level hardware info collector and test helper. |
| pkg/hardware_info/hardware-info_test.go | Removes legacy hardware info roundtrip tests. |
| pkg/hardware_info/disk/syscall_statfs.go | Removes legacy disk statfs logic. |
| pkg/hardware_info/disk/syscall_statfs_test.go | Removes legacy disk statfs tests. |
| pkg/hardware_info/disk/disk_info.go | Removes legacy disk info collector. |
| pkg/hardware_info/disk/disk_df.go | Removes legacy df parsing/exec logic. |
| pkg/hardware_info/disk/disk_df_test.go | Removes legacy df parsing test. |
| pkg/hardware_info/cpu/types.go | Removes legacy /proc/cpuinfo model. |
| pkg/hardware_info/cpu/proc_cpuinfo.go | Removes legacy CPU parsing. |
| pkg/hardware_info/cpu/proc_cpuinfo_test.go | Removes legacy CPU parsing tests. |
| pkg/hardware_info/cpu/cpu.go | Removes legacy CPU info collector. |
| pkg/hardware_info/cpu/architecture.go | Removes legacy uname->debian arch mapping logic. |
| pkg/engines/validate.go | Switches YAML parsing to go.yaml.in/yaml/v4. |
| pkg/engines/types.go | Switches HexInt usage to lscompute machine types. |
| pkg/engines/types_test.go | Switches YAML parsing to go.yaml.in/yaml/v4. |
| pkg/engines/load.go | Switches YAML parsing to go.yaml.in/yaml/v4. |
| pkg/engines/devices_test.go | Switches HexInt usage to lscompute machine types. |
| pkg/engines/cpu_test.go | Switches HexInt usage to lscompute machine types. |
| go.sum | Adds lscompute and yaml v4 sums; removes unused sums. |
| go.mod | Adds lscompute and YAML v4 dependency; reclassifies x/sys as indirect. |
| cmd/modelctl/common/engine.go | Uses machine.Get(host.Real(), ...) and updates Layout types to utils.Layout. |
| cmd/modelctl/common/engine_test.go | Updates fakes to new machine-get/scorer signatures and utils.Layout. |
| cmd/modelctl/commands/use-engine_test.go | Updates example to use new machine fixture and MachineInfo. |
| cmd/modelctl/commands/show-machine.go | Switches to lscompute machine info retrieval and printing. |
| cmd/modelctl/commands/show-machine_test.go | Updates examples/tests to use MachineInfo fixtures and new output shape. |
| cmd/modelctl/commands/show-engine_test.go | Updates engine scoring tests to use MachineInfo fixtures. |
| cmd/modelctl/commands/list-engines_test.go | Updates list-engines tests to use MachineInfo fixtures. |
| cmd/modelctl/commands/fixtures_test.go | Adds small in-code MachineInfo fixtures for command tests. |
| cmd/modelctl/commands/debug/select.go | Updates debug selector to decode MachineInfo from stdin and score engines accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
farshidtz
requested changes
Jul 1, 2026
farshidtz
left a comment
Member
There was a problem hiding this comment.
Thanks for the refactoring and additional cleanups.
I've made a couple of suggestions.
farshidtz
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces the internal hardware_info package with the external lscompute module.