-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[ci] [python-package] Python tests leave files behind #6361
Comments
Hi @jameslamb , I'm new to open source and would like to take up this issue. Thanks! |
Sure, thanks! |
Hey @jameslamb, I have encountered a few issues while building the Python package. However, I have managed to build it successfully now. But, I am facing some errors while running the tests. I am not able to find the requirements.txt file. Can you suggest any way to install all the necessary modules? Best, Errors after running
|
Thanks for trying it out! Please post error messages and logs as plaintext, not images, so they can be found from search engines. See these resources:
Follow these steps (but add |
Sorry about that! I've updated my comment. Thanks for the information. I'll start working on it 😄 |
I found another one generated by the Dask tests, added it above. LightGBM/tests/python_package_test/test_dask.py Line 1534 in 631e0a2
|
@Hitro147 Are you still interested in pursuing this? |
Hello @jameslamb, I'm facing some issues with my current environment, but I'll need time to resolve them. However, I need to put it on hold for a while, if it's open after a while I'd like to return to it when I have more time. Feel free to assign this to someone if they are interested in this. Thanks for giving me this opportunity! 😄 |
Ok sure, no problem. Comment here or on #6350 any time if you need help. Anyone else reading this... you are welcome to contribute! A PR even just eliminating one of these left-behind files would be greatly appreciated 😊 |
@jameslamb, I would like to contribute to this issue, or any related good first issue (as there are multiple mentioned), here in the repository |
Sure! This is a great issue to start with @Arup-Chauhan . I recommend focusing on a single file like git grep -E 'categorical\.model' Thanks for spending some time on LightGBM, we really appreciate it! |
Hi @jameslamb , thanks for this, I will get started, will reach out to you if I need assistance |
Description
The Python unit tests in this project leave some files behind when they are done running.
They should be modified to use Python-managed temporary files that are automatically removed, so that:
Reproducible example
Build the Python package and run the Python tests.
cmake -B build -S . cmake --build build --target _lightgbm sh build-python.sh install --precompile pytest tests/python_package_test
(for more details on this, see #6350).
Look at the files created.
As of latest
master
(b27d81e), you'll see all of these created by tests:Approach
Find the tests that created those files, and ensure that they stop creating them.
For example, it looks like
lgb.model
probably comes from here:LightGBM/tests/python_package_test/test_engine.py
Line 1373 in b27d81e
And that that could be avoided using
pytests
'stmp_path
fixture, like this:LightGBM/tests/python_package_test/test_engine.py
Line 727 in b27d81e
LightGBM/tests/python_package_test/test_engine.py
Line 744 in b27d81e
For more on how that works, see "How to use temporary directories and files in tests" (pytest docs).
Additional Comments
You do not need to put up a pull request fixing all of these! Contributions that fix any of these would be welcomed.
This list will be updated as these are fixed:
categorical.model
andmodel.txt
files being left behind after testing #6590)lgb.model
andlgb.pkl
files being left behind after testing #6518)lgb.model
andlgb.pkl
files being left behind after testing #6518)train.binary.bin
andlgb_train_data.bin
files being left behind after testing #6606)categorical.model
andmodel.txt
files being left behind after testing #6590)train.binary.bin
andlgb_train_data.bin
files being left behind after testing #6606)If you are interested in working on this, comment here to indicate that and to ask for help if you need it.
The text was updated successfully, but these errors were encountered: