Skip to content

Conversation

jameslamb
Copy link
Collaborator

This project uses a script to auto-generate https://lightgbm.readthedocs.io/en/latest/Parameters.html from comments in https://github.com/microsoft/LightGBM/blob/master/include/LightGBM/config.h

To check that that's been done, we have some code that manually checks specific files with diff

LightGBM/.ci/test.sh

Lines 142 to 147 in 97ff708

# check the consistency of parameters' descriptions and other stuff
cp ./docs/Parameters.rst ./docs/Parameters-backup.rst
cp ./src/io/config_auto.cpp ./src/io/config_auto-backup.cpp
python ./.ci/parameter-generator.py || exit 1
diff ./docs/Parameters-backup.rst ./docs/Parameters.rst || exit 1
diff ./src/io/config_auto-backup.cpp ./src/io/config_auto.cpp || exit 1

This is often missed and has to be taught to new contributors, for example: #6863 (review)

To help simplify CI scripts and hopefully reduce friction for contributors, this proposes automatically re-running that via pre-commit.

(thanks to my colleague @KyleFromNVIDIA for introducing me to this pattern)

Notes for Reviewers

How I tested this

Changed a comment in config.h, ran pre-commit run --all-files, and saw pre-commit fail (exit code 1) like this:

regenerate-parameters....................................................Failed
- hook id: regenerate-parameters
- files were modified by this hook

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Wow, awesome change, thanks a lot!

@StrikerRUS StrikerRUS merged commit 8d7b6f9 into master Aug 20, 2025
49 checks passed
@StrikerRUS StrikerRUS deleted the ci/param-generator-in-precommit branch August 20, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants