Skip to content

599 improved profiling modes - #601

Open
Joerg Henrichs (hiker) wants to merge 7 commits into
mainfrom
599_improved_profiling_modes
Open

599 improved profiling modes#601
Joerg Henrichs (hiker) wants to merge 7 commits into
mainfrom
599_improved_profiling_modes

Conversation

@hiker

Copy link
Copy Markdown
Collaborator

Closes #599.
It simplifies the definition of compilation profiles.

I added two commits for very minor cleanup of some tests (improved an error message, removed left-over debug print, and handled a warning, so pytest now reports all tests as green).

I have tested this with skeleton, lfric_atm, jules, um so far, and will verify that everything else is updated to use this new feature as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few small things.

Comment thread source/fab/tools/profile_flags.py Outdated
# as an always available dummy profile.
_inherit_from: dict[str, str] = {"": ""}

def __init__(self: "ProfileFlags",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't normally hint the self object reference, but if you want to you can from __future__ import annotations, then you don't need to quote the name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh, no idea what I was thinking there. Removed.

:param inherit_from: Optional name of a profile to inherit
settings from.
'''
if name in cls._inherit_from:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it safer to force name.lower()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed.

if name in cls._inherit_from:
raise KeyError(f"Profile '{name}' is already defined.")

if inherit_from is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another candidate for inherit_from.lower()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, as well.

Comment thread source/fab/tools/profile_flags.py Outdated
'''
if not file_path:
# If no path, provide a dummy path
file_path = Path()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will be the currently selected directory. Is that the behaviour you want?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't matter (atm only compiler and preprocessor actually use the profile flags, and they all provide a path), but it is indeed not necessary here. So, I've removed that.

@hiker

Copy link
Copy Markdown
Collaborator Author

Ready for next review.

@hiker Joerg Henrichs (hiker) added the Ready for review Indicating that a PR is ready to be reviewed. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Indicating that a PR is ready to be reviewed.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Improvements to defining profiling modes

2 participants