Skip to content

fix(computation): use exact match in cpu lookup consumption profile function#415

Merged
jonperron merged 1 commit intoBoavizta:mainfrom
jonperron:fix/boavitzapi-397
Jan 10, 2026
Merged

fix(computation): use exact match in cpu lookup consumption profile function#415
jonperron merged 1 commit intoBoavizta:mainfrom
jonperron:fix/boavitzapi-397

Conversation

@jonperron
Copy link
Copy Markdown
Collaborator

@jonperron jonperron commented Jul 27, 2025

In some cases, fuzzy match returns more than a single row. In this case, an exact match is run
to try to retrieve the correct consumption profile. It also align this comparison with the rest of the project,
which uses widely exact match. In addition, only one function depends on the look_up_consumption method, and it
expects a single value, not several.

Fix #397

@jonperron jonperron marked this pull request as ready for review July 27, 2025 07:37
@jonperron jonperron force-pushed the fix/boavitzapi-397 branch from 85f5a4f to 89988e4 Compare August 1, 2025 07:41
@Shillaker Shillaker self-assigned this Dec 30, 2025
@Shillaker
Copy link
Copy Markdown
Collaborator

Hi @jonperron, I agree with your assessment of the problem. In the example given, where model_name = Xeon E5, the current implementation matches on two consumption profiles: Xeon E5, and Xeon E, and thus returns None, rather than correctly taking the exact match.

However, I'm not sure changing to exact match is the correct solution for two reasons:

  1. It will create a breaking change where we alter the behavior of the code. For example, case-insensitive matching will no longer work (currently I can pass xeon gold and match the correct profile).
  2. We use fuzzy matching for all other CPU-related CSV data. If we change this to be exact-match, and leave other CPU CSV lookups as fuzzy-match, we could match some properties on fuzzy-match (e.g. the die size), but get the wrong consumption profile.

Instead, I propose we modify the fuzzy matching for looking up consumption profiles to match the existing CSV fuzzy-matching we do on the cpu_specs.csv file.

This happens in the attributes_from_cpu_name function, where we have a scoring system to determine whether there is a match. In the example above, this scoring system would rate Xeon E5 as a closer match than Xeon E, and return that.

@jonperron
Copy link
Copy Markdown
Collaborator Author

I agree with you @Shillaker, changing at one place is not the best solution. I proposed a solution which is matching the current behaviour of the API, i.e. to send only one expected result. I will look at implementing a utils function derived from the algorithm you pointed out in the attributes_from_cpu_name.

To be honest, I would rework the error handling of the API here. Indeed, it is ok, and normal, that fuzzy matching can return several results. But then, the API should return an error, or at least an indication that several values are available, rather than failing silently.

@jonperron jonperron force-pushed the fix/boavitzapi-397 branch 2 times, most recently from 055949f to bc1954f Compare January 3, 2026 08:44
@jonperron
Copy link
Copy Markdown
Collaborator Author

jonperron commented Jan 3, 2026

@Shillaker I thought about your proposition, and as the issue was happening with a call on /v1/component/cpu with a simple payload which did not contain the cpu name, I didn't go for it.

Instead, I kept the original fuzzy match and if multiple results were returned, I added an exact match filter (so Intel Xeon E or Intel Xeon E5 are returning the correct results, see the new tests). I didn't add an HTTP response with "multiple result returned, please precise", because it was a major breaking change in the code.

…n one result

Changelog
* Add exact match when fuzzy returns more than one result
* Add tests

397
Copy link
Copy Markdown
Collaborator

@Shillaker Shillaker left a comment

Choose a reason for hiding this comment

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

Ok great, LGTM 👍

@jonperron jonperron merged commit 387e4ca into Boavizta:main Jan 10, 2026
5 checks passed
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.

Model range is ignored in /v1/component/cpu

2 participants