Add kernel linting via @parcels.validate_kernel - #2842
Open
VeckoTheGecko wants to merge 5 commits into
Open
Conversation
We use ei now
VeckoTheGecko
force-pushed
the
2109-kernel-linting
branch
from
August 21, 2026 10:09
aa298c9 to
93823af
Compare
Contributor
Author
|
Still need to update the tests (will do next week), otherwise ready for review We need to decide where in docs to raise this (likely in quickstart and in migration guide) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds linting for Parcels kernels to help with correctness and for migration to v4.
The linting is broken up into errors and warnings:
particles.delete()particle_dlon- a user might intentionally define this variable in their v4 kernel. There's no way to distinguish between that usage and someone upgrading their v3 kernel.ei, they should be warned about where they're sampling itThis linting is exposed via a decorator for users, and the docstring for
validate_kernelshows which rules and looked for. I looked through the migration guide etc. and thought these rules were good, let me know @erikvansebille if you think additional rules are needed.providing an opt-in endpoint for raising these errors and warnings before the execution phase of a simulation
Internally in the execute loop these kernels are validated again. Providing the decorator is more for providing a good user experience for upgrading kernels.
Example kernel upgrade
The following kernel is taken from PlasticParcels
which gives
Note that there is a doubling up - the "report" is printed once for the warnings and once for the errors. I think that this is fine, and better than splitting them up (as warnings are likely errors as well, its nice to deal with them at the same time).
Checklist
mainfor normal development,v3-supportfor v3 support)AI Disclosure