Use mypy and ruff from pixi environment - #3124
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3124 +/- ##
=======================================
Coverage 96.48% 96.48%
=======================================
Files 282 282
Lines 16407 16409 +2
=======================================
+ Hits 15830 15832 +2
Misses 577 577 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
valeriupredoi
left a comment
There was a problem hiding this comment.
thanks bud - a very welcome approach indeed! Approving preemptively (don't pull a Klaus on me since I approve drafts 😆 ) since I'll be away most next week
9dd9763 to
639434b
Compare
|
gotta be a solution to have pre-commit.ci work - let me dig around for a bit tomorrow |
|
hey @bouweandela we has pixi in the pre-commit CI environment! Unfortunately that pixi is newer than the pixi we have in the box, so it says we should |
|
Thanks for having a go V! It looks like this installs the unrelated pixi package from PyPI. While it is probably possible to update the pre-commit hooks so they silently install pixi if it is not available locally by writing some script, I'm not convinced this would be doing our users a service. It may be more clear to just fail with the message that pixi is not installed, as they'll need to install it anyway in order to run ESMValTool. |
schlunma
left a comment
There was a problem hiding this comment.
Thanks Bouwe, I like the idea!
Tested this locally and on Levante.
Locally
First run: ~38s
Subsequent runs: ~4s
Levante
First run: ~2.25 min
Subsequent runs: ~26s
Locally, that waiting time is totally fine, but on Levante it feels very slow. I am not 100% sure if this is still acceptable or not. Not sure if this is related to the current maintenance though, but as far as I am aware /home should not be affected by it.
Do you know how long the cache is valid when running pre-commit manually? As far as I can tell, on CircleCI you configured it so that it's valid for a week.
With the current setup, pre-commit creates its own virtual environments and those are stored in |
schlunma
left a comment
There was a problem hiding this comment.
I am pretty sure that this is related to mypy, which is by far the slowest step.
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
|
I agree, it takes about 18 seconds to run mypy on Levante. There is the option of using the daemon to speed things up, I enabled that now, but only works for reruns. We could also consider switching to another type checker, see https://pydevtools.com/handbook/explanation/how-do-mypy-pyright-and-ty-compare/ for an overview. |
|
Yes, pyrefly looks very nice! I think we should give it a try. |
Description
Use mypy and ruff from the pixi environment instead of installing them with pre-commit.
Pros
mypyandruffcan be used without pre-commit. Useful if you want to run these tools with additional options, e.g.ruff check --fix --unsafe-fixesCons
We could decide to move away from pre-commit.ci and instead just run the pre-commit hooks on CircleCI as part of the test suite. That would also have the advantage that it has one less CI service, so easier to understand for new contributors.
Link to documentation: https://esmvaltool--3124.org.readthedocs.build/projects/ESMValCore/en/3124/contributing.html#code-quality
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
To help with the number pull requests: