-
Notifications
You must be signed in to change notification settings - Fork 228
[MRG] Address comments for sklearn-contrib integration #238
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
[MRG] Address comments for sklearn-contrib integration #238
Conversation
Mostly: - blank spaces (missing or to be removed) - lines too long - unused variables or imports - bad indentation
@@ -1,4 +1,3 @@ | |||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and the tests are run even if I remove this line
.travis.yml
Outdated
else | ||
pip install scikit-learn==0.20.3; | ||
fi | ||
- pip install wheel cython numpy scipy codecov pytest-cov scikit-learn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now for python versions that are not supported by scikit-learn 0.21 and up, pip will now automatically install the V0.20.3. Let's see if it works
I think the coverage failed because sometimes I broke some too long lines, adding lines of code but not increasing coverage. I think the coverage is still high so we should be able to merge |
About the imports in init, using |
For the skggm import, a hacky workaround could be to add an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise nice job on the pep8 corrections
Thanks @bellet, I just addressed your comments |
I also tried to add an automatic flake8 check that will be run on the whole code after each PR (last commit), now that it's all compliant it's possible to do that and not bother about doing it just on the diff |
I think there is a syntax problem with the if statement in bash for string comparison. You are missing the double square brackets [[ |
That's right, it should work now |
I just realized I was using an old flake8 so in fact there are some flake8 errors that are not solved, which explains the new fail |
I just updated the list of errors, removing W504, because it makes impossible situations when activated at the same time as W503 (see this for instance https://gitlab.com/pycqa/flake8/issues/466, also note that scikit-learn has disabled it (see https://github.com/scikit-learn/scikit-learn/blob/4cf4e6e519189c8969f5820ebbca388cf87bf0cb/setup.cfg#L29)) |
It appears to work now |
.travis.yml
Outdated
pip install git+https://github.com/skggm/skggm.git@a0ed406586c4364ea3297a658f415e13b5cbdaf8; | ||
fi | ||
script: | ||
# we run flake8 to ensure syntax (no need to run it on every version) | ||
- if [[ $TRAVIS_PYTHON_VERSION == "3.7" ]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for style, maybe put then
on the same line as if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, thanks
done
.travis.yml
Outdated
pip install git+https://github.com/skggm/skggm.git@a0ed406586c4364ea3297a658f415e13b5cbdaf8; | ||
fi | ||
script: | ||
# we run flake8 to ensure syntax (no need to run it on every version) | ||
- if [[ $TRAVIS_PYTHON_VERSION == "3.7" ]]; | ||
then flake8 --ignore=E111,E114,W504; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also ignore the other errors that are ignored by default by flake8, just like sklearn does, to avoid unimportant failures which could pop up in subsequent PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I used the syntax --extend-ignore
(https://flake8.pycqa.org/en/3.7.8/user/options.html?highlight=extend-ignore#cmdoption-flake8-extend-ignore), so that flake8 will ignore the default errors (including W504), and also E111 and E114
About this: I am not sure what is commonly done, but checking only the diff seems to me like a better solution in the long run: if at some point we have a very good reason to merge some PR which is not compliant, we can do so and continue to check compliance of newly added code. This is what is done in sklearn (script is here: https://github.com/scikit-learn/scikit-learn/blob/master/build_tools/circle/flake8_diff.sh). Not sure how difficult it is to make travis check only the diff but I think it may be preferable? |
Yes I agree it would be a good idea, and in theory it shouldn't be so difficult (locally that's what I do with the command |
As discussed with @bellet and @nvauquie, I modified |
It seems that there is a problem with the code coverage now... I forgot one of the fields |
It seems to work now, so I guess we can merge ? |
Nice! |
I guess that's fine, there is indeed a single report generated that takes into account each build (https://codecov.io/github/metric-learn/metric-learn/commit/d244bc59ad55ad8257eb82e21b466930c636ebc4), but the results are not shown here Maybe you can quickly try to introduce an error which is not in all builds to see what happens? (easiest way is probably to add an error in one of the skggm tests) |
.travis.yml
Outdated
before_install: | ||
- sudo apt-get install liblapack-dev | ||
- pip install --upgrade pip pytest | ||
- pip install wheel cython numpy scipy codecov pytest-cov scikit-learn flake8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove flake8 on pytest jobs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, thanks
.travis.yml
Outdated
script: | ||
- pytest test --cov; | ||
- bash <(curl -s https://codecov.io/bash) | ||
- name: "Syntax checking" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe name this "Syntax checking with flake8" to give an explicit mention of the tool used to check the syntax (for new contributors)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, will do
I’ve never done flake8 check only on the diff before. What’s the motivation for that? If we are worried about having to fix a lot of flake8 errors, I’ve had good experience with automatic code style fixer like black before. |
We considered it in case we ever need to let some flake8 errors through at some point (this is also what sklearn does). But for reasons explained above we agree that, at least for now, flake8 check on the whole project is better Thanks for the pointer to black, seems nice :-) |
Looks like things are working as expected? Let's remove the error and we should be good to merge? |
test_flake.py
Outdated
@@ -0,0 +1,3 @@ | |||
import nimp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this file do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, thanks, I forgot I created it in metric-learn
, and added it by mistake...
Using Travis stages is fine too but keep in mind that any subsequent stages won’t start until it’s previous stage passes. This might reduce Travis build time but will increase development time since developers won’t see all the errors besides lint check at once. |
Yep. In the end we are not using stages and running everything in parallel (see last CI results) |
After looking again at the build that failed that made me remove the |
Hurray! :D It worked this time, when there was no timeout error, so I guess it's ok to merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Merging
You can now update the sklearn-contrib integration issue :-) |
Done :-) |
Hi, we've made a request for inclusion in
scikit-learn-contrib
, this PR intends to address the comments of the issue:scikit-learn-contrib/scikit-learn-contrib#40
TODO:
metric_learn/__init__.py
, but I guess these are needed right ?) And alsoinverse_covariance.quic
is imported but unused, but this is normal since it's just to define the variableHAS_SKGGM
. I don't know if there's another way to bypass this. Here is the log of flake8 after the fixes:Note that I ignored some errors (E111 (indentation is not a multiple of four),E114 (indentation is not a multiple of four (comment)))