Skip to content

Use lscompute for hardware detection#390

Merged
farshidtz merged 17 commits into
mainfrom
IENG-2454-lscompute
Jul 2, 2026
Merged

Use lscompute for hardware detection#390
farshidtz merged 17 commits into
mainfrom
IENG-2454-lscompute

Conversation

@jpm-canonical

@jpm-canonical jpm-canonical commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This PR replaces the internal hardware_info package with the external lscompute module.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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’s machine.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.

Comment thread pkg/selector/cpu/cpu.go
Comment thread pkg/selector/pci/pci.go
Comment thread pkg/selector/cpu/cpu_test.go Outdated
Comment thread cmd/modelctl/commands/fixtures_test.go
Comment thread cmd/modelctl/commands/fixtures_test.go
Comment thread cmd/modelctl/commands/fixtures_test.go
Comment thread pkg/selector/fixtures_test.go
jpm-canonical and others added 4 commits June 30, 2026 11:41
@jpm-canonical jpm-canonical requested a review from farshidtz June 30, 2026 09:50
@jpm-canonical jpm-canonical marked this pull request as ready for review June 30, 2026 15:19

@farshidtz farshidtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the refactoring and additional cleanups.

I've made a couple of suggestions.

Comment thread pkg/engines/layout.go
Comment thread go.mod Outdated
@jpm-canonical jpm-canonical requested a review from farshidtz July 2, 2026 07:52
@farshidtz farshidtz merged commit fa08c42 into main Jul 2, 2026
6 checks passed
@farshidtz farshidtz deleted the IENG-2454-lscompute branch July 2, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants