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

CLI: Validate strict in verdi config set caching.disabled_for #6197

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Nov 30, 2023

Values provided for verdi config set caching.disabled_for and verdi config set caching.enabled_for were validated, but without setting strict=True for the _validate_identifier_pattern validator. This keyword was recently added (b9144bb) and when set to True would actually attempt to load the entry point or import path.

Without this strict validation, a user could accidentally set an incorrect value to enable or disable caching for. Most common example is where a correct entry point was provided but without the entry point group, e.g., core.arithmetic.add. The validator would interpret this as an import path and not as an entry point, and since strict validation was turned off, it didn't attempt to actually import it.

The strict validation is now turned on causing the example above to return a validation error. The downside of this approach is that it is no longer possible to disable or enable caching for an entry point or import path that cannot be loaded in the current environment. But then again, the question is what the use would be of such a use-case.

@sphuber sphuber force-pushed the fix/verdi-config-set-caching-strict branch 2 times, most recently from 864180e to d183b93 Compare November 30, 2023 14:20
@sphuber sphuber requested a review from unkcpz November 30, 2023 14:24
@sphuber
Copy link
Contributor Author

sphuber commented Dec 13, 2023

@unkcpz shall we try to get this in the release?

@unkcpz
Copy link
Member

unkcpz commented Dec 14, 2023

Sorry, I missed this PR. I'll give it a look now.

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

Thanks! @sphuber

The downside of this approach is that it is no longer possible to disable or enable caching for an entry point or import path that cannot be loaded in the current environment. But then again, the question is what the use would be of such a use-case.

I think it is not a downside but even an upside to giving strict validation. Plus you add nice documentation for this case, it will be all fine I assume.

aiida/manage/configuration/options.py Show resolved Hide resolved
Values provided for `verdi config set caching.disabled_for` and `verdi
config set caching.enabled_for` were validated, but without setting
`strict=True` for the `_validate_identifier_pattern` validator. This
keyword was recently added and when set to `True` would actually attempt
to load the entry point or import path.

Without this strict validation, a user could accidentally set an
incorrect value to enable or disable caching for. Most common example is
where a correct entry point was provided but without the entry point
group, e.g., `core.arithmetic.add`. The validator would interpret this
as an import path and not as an entry point, and since strict validation
was turned off, it didn't attempt to actually import it.

The `strict` validation is now turned on causing the example above to
return a validation error. The downside of this approach is that it is
no longer possible to disable or enable caching for an entry point or
import path that cannot be loaded in the current environment. But then
again, the question is what the use would be of such a use-case.
@sphuber sphuber force-pushed the fix/verdi-config-set-caching-strict branch from d183b93 to 8a7dd66 Compare December 14, 2023 09:17
@sphuber sphuber merged commit 9cff592 into aiidateam:main Dec 14, 2023
18 checks passed
@sphuber sphuber deleted the fix/verdi-config-set-caching-strict branch December 14, 2023 09:57
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.

2 participants