Skip to content

Conversation

@Flamefire
Copy link
Contributor

Currently access to a constant by name is a bit awkward: next(e[1] for e in TEMPLATE_CONSTANTS if e[0] == name)

Also having them a list of strings or string and tuple of strings isn't obvious that it is rather a mapping of constants to values/documentation and not a real list. Thus it isn't clear either, that each name must only appear once.

This is a non-functional refactoring simplifying the code and improving the expressiveness.

E.g. to get all defined constants we can simply do: list(TEMPLATE_CONSTANTS) (or list(TEMPLATE_CONSTANTS.keys()))

Additionally I included a change similar to the EasyConfig constants such that you can import them directly, e.g. from easybuild.framework.easyconfig.templates import GITHUB_SOURCE

Those are easier to handle as we can
a) Access the names directly by iterating over the dict(-keys)
b) Avoid duplications
c) Make the semantic clearer
d) Allow direct access of values by template name
This allows direct access to the template constants, e.g. for use in hooks.
E.g.: `from easybuild.framework.easyconfig.templates import GITHUB_SOURCE`
@boegel
Copy link
Member

boegel commented Aug 14, 2024

@Flamefire A merge conflict emerged here.

Also, as a reminder: TEMPLATE_CONSTANTS is used in the Python and PythonPackage easyblocks, so those will need to be changed accordingly in a companion PR

@Flamefire
Copy link
Contributor Author

Also, as a reminder: TEMPLATE_CONSTANTS is used in the Python and PythonPackage easyblocks, so those will need to be changed accordingly in a companion PR

Already done -> easybuilders/easybuild-easyblocks#3410 :)

@Flamefire Flamefire force-pushed the template-constant-dict branch from 722253b to 2785c55 Compare August 15, 2024 12:21
@boegel boegel added the change label Aug 27, 2024
Copy link
Contributor

@Micket Micket left a comment

Choose a reason for hiding this comment

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

lgtm

@Micket
Copy link
Contributor

Micket commented Aug 29, 2024

A few selected test reports uploaded to easybuilders/easybuild-easyblocks#3410 (comment)

This seems fine to me. I haven't heard any objects to this. I would like to merge it, just want to check with others first.

@Micket Micket merged commit b5b773b into easybuilders:5.0.x Aug 30, 2024
Flamefire added a commit to Flamefire/easybuild-easyblocks that referenced this pull request Aug 30, 2024
@Flamefire Flamefire deleted the template-constant-dict branch August 30, 2024 12:19
'cuda_int_space_sep': 'Space-separated list of integer CUDA compute capabilities',
'cuda_int_semicolon_sep': 'Semicolon-separated list of integer CUDA compute capabilities',
'cuda_sm_comma_sep': 'Comma-separated list of sm_* values that correspond with CUDA compute capabilities',
'cuda_sm_space_sep': 'Space-separated list of sm_* values that correspond with CUDA compute capabilities',
Copy link
Member

Choose a reason for hiding this comment

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

software_commit is missing here, I'll open a PR to add it back

Copy link
Member

Choose a reason for hiding this comment

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

fixed in #4621

bartoldeman pushed a commit to ComputeCanada/easybuild-easyblocks that referenced this pull request Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants