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

setup: Make validate_config to check for specified archs #97

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

marcosps
Copy link
Collaborator

@marcosps marcosps commented Mar 5, 2025

Up until now we could have a CONFIG_ being set on an archtecture and not on others and then it would pass the checks, only complaining for a missing symbol later on the setup phase.

IIRC this used to work in the past, but somehow it got broken. Added a test to ensure that we catch such cases in the future.

@marcosps marcosps requested review from vmezzela and fgyanz March 5, 2025 16:54
for arch in archs:
if arch in self.archs and arch not in cs_config_archs:
raise RuntimeError(f"{self.name()}: {conf} not set on {arch}. Aborting")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi Marcos, the patch looks good to me.

however, a slight improvement could be this:

arch_config = self.get_all_configs(conf)

for arch in archs:
    try:
        conf_entry = arch_config.pop(arch)
        # Here the body of the first for loop
   except KeyError:
       raise RuntimeError(f"{self.name()}: {conf} not set on {arch}. Aborting")

This relies on pop() raising a KeyError when the arch is not present in the dictionary, at the same time might be slightly more maintainable and fast (less loops, and we avoid checking unaffected archs in the first loop).

But this is just me proposing useless improvements, so you can also discard this comment and merge as it is 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Much better, indeed! What about the new version?

@marcosps marcosps force-pushed the arch-config-not-set branch from 805df16 to b0fab54 Compare March 6, 2025 12:21
Copy link
Collaborator

@vmezzela vmezzela left a comment

Choose a reason for hiding this comment

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

Hi Marcos, I've added a comment but is nothing important, you can merge as it is!

I've also tested on the last livepatch which didn't affect one arch and it worked as expected, thank you!

🚀

try:
conf_entry = cs_config.pop(arch)
except KeyError as exc:
if arch not in self.archs:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forgot we needed to check the arch is supported for the codestream. right!
Couldn't we just skip the iteration if the arch is not in self.archs? Like moving this if .. : continue right at the beginning of the loop, before the try?

Also, perhaps it could be a good idea to rename self.archs to self.supported_archs because I tend to make confusion with the archs supplied via arguments 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, I moved the if condition to the loop.

About changing self.archs to self.supported_archs is a bigger refactor, but maybe we can do in another moment :) Is that ok for now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah sure, I meant renaming in another PR, I should have specified! My bad 😆

Up until now we could have a CONFIG_ being set on an archtecture and not
on others and then it would pass the checks, only complaining for a missing
symbol later on the setup phase.

IIRC this used to work in the past, but somehow it got broken. Added a test
to ensure that we catch such cases in the future.

Signed-off-by: Marcos Paulo de Souza <[email protected]>
@marcosps marcosps force-pushed the arch-config-not-set branch from b0fab54 to 18f83d5 Compare March 7, 2025 14:51
@vmezzela
Copy link
Collaborator

vmezzela commented Mar 7, 2025

lgtm, thanks! 🚀

try:
conf_entry = cs_config.pop(arch)
except KeyError as exc:
raise RuntimeError(f"{self.name()}: {conf} not set on {arch}. Aborting") from exc
Copy link
Collaborator

Choose a reason for hiding this comment

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

humm is it really necessary to abort here? Perhaps it would be better to just skip the codestream+arch combination.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about it, but it might require additional work on the TemplateGen, or maybe in how are handle it. Maybe we could just remove the arch from self.archs? I'm not sure, but yeah, sounds a better idea.

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