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

feat: consider env_misc.platform as hardware #703

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

murilx
Copy link
Contributor

@murilx murilx commented Dec 19, 2024

Add a new logic to the backend where environment_misc.platform will work as a fallback case for when the environment_compatabile field is null in the database. When environment_misc.plaftorm is null, we'll use build.misc.platform, but the logic of the Hardware filter will be kept the same, meaning that the builds returned will be first the build associated with the tests that have that hardware. This means that even if build.misc.platform is null but the build is associated with a test that have environment_compatible or environment_misc.platform not null, it will also be added when filtering for that hardware

This drastically lowers the number of Unknown hardware but they can still occur if both environment_compatible and environment_misc.platform and build.misc.platform are null.

Closes #692

How to test

  • Add hardware filters from the Hardware Used card, Hardware Tested card and Filter modal and verify that they are correctly being added by comparing with staging. Verify that the commit graph is also working properly, showing the correct graph and changing the commit correctly
  • Add a platform filter (these are hardwares that do not appear in staging, e.g. acer-R721T-grunt) from the Hardware Used card, Hardware Tested card and Filter modal and make the same verifications as above, if the status are showing correctly (comparing the values in the Hardware Tested card and the value shown in the pie chart) and if the commit graph is working.
  • Test in other origins to verify that the behaviour is consistent between them

@@ -281,7 +281,7 @@ def handle_test(self, record, tests):

if status == "ERROR" or status == "FAIL" or status == "MISS":
tests["platformsFailing"].add(
extract_platform(record["environment_misc"])
handle_environment_misc(record["environment_misc"]).get("platform")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had no idea we were already getting platform faililng in hardware

@@ -0,0 +1,27 @@
import json
from typing import Union, TypedDict, Optional
from kernelCI_app.helpers.filters import UNKNOWN_STRING
Copy link
Collaborator

Choose a reason for hiding this comment

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

filters is probably not the best place for UNKNOWN_STRING maybe helper.constants

but I know it is not being introduced by this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. I can change this as well if you think it would be better

Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not worry for this for today, we need this quick

platform: str


def handle_environment_misc(misc: Union[str, dict, None]) -> Optional[EnvironmentMisc]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

the return here is not Optional, it is always returning

try:
misc = json.loads(misc)
except json.JSONDecodeError:
return parsed_misc
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe it is a good idea to add the log_message here, for now it just prints but in the future will be doing something more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And keep returning the default value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

omg that was lack of attention, make it the return value back to optional and make it return None

environmentCompatible={{
...data.testEnvironmentCompatible,
...data.testEnvironmentMisc,
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

useMemo especially when you have to spreads

@murilx murilx force-pushed the feat/use-misc-platform-field branch 2 times, most recently from 76ae7f1 to 38cd3a0 Compare December 19, 2024 16:52
@murilx murilx self-assigned this Dec 19, 2024
@murilx murilx marked this pull request as ready for review December 19, 2024 16:52
Copy link
Collaborator

@WilsonNet WilsonNet left a comment

Choose a reason for hiding this comment

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

it worked on my tests

@@ -218,8 +220,13 @@ def _process_rows(self, rows: Dict) -> None:
sanitized_rows = self.sanitize_rows(rows)

for row in sanitized_rows:
hardware_filter = row["hardware_compatibles"]
if hardware_filter is None or hardware_filter == UNKNOWN_STRING:
Copy link
Collaborator

Choose a reason for hiding this comment

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

the sanitized rows are simply the original rows but as an object, the row["hardware_compatibles"] hasn't been sanitized to receive UNKNOWN_STRING yet. In other words, the comparison hardware_filter == UNKNOWN_STRING will never be true unless the original row in the database is literally "Unknown", so I think this comparison is not needed

@@ -218,8 +220,13 @@ def _process_rows(self, rows: Dict) -> None:
sanitized_rows = self.sanitize_rows(rows)

for row in sanitized_rows:
hardware_filter = row["hardware_compatibles"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this variable referring to the current hardware of a row? I don't think hardware_filter is a good name for it

self.hardwareUsed.add(test_environment_compatible)
else:
hardware_filter = test_environment_misc.get("platform")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto about hardware_filter var name

Add a new logic to the backend where `environment_misc.platform` will
work as a fallback case for when the `environment_compatabile` field is
null in the database. When `environment_misc.plaftorm` is null, we'll
use `build.misc.platform`, but the logic of the Hardware filter will be
kept the same, meaning that the builds returned will be first the build
associated with the tests that have that hardware. This means that even
if `build.misc.platform` is null but the build is associated with
a test that have `environment_compatible` or `environment_misc.platform`
not null, it will also be added when filtering for that hardware

Closes #692
@murilx murilx force-pushed the feat/use-misc-platform-field branch from 38cd3a0 to 457bcce Compare December 19, 2024 20:43
Copy link
Collaborator

@MarceloRobert MarceloRobert left a comment

Choose a reason for hiding this comment

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

Worked well on my tests, just a note to split the commits into the feature and the formatter refactor for better reviewing

@murilx murilx merged commit 883517a into main Dec 20, 2024
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.

Use platform from misc field (if available) instead of just showing ‘Unknown’ hardware.
3 participants