Skip to content
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

Flake8 Fixes (Part1) #1550

Merged
merged 22 commits into from
Oct 19, 2021
Merged

Flake8 Fixes (Part1) #1550

merged 22 commits into from
Oct 19, 2021

Conversation

laserprec
Copy link
Contributor

@laserprec laserprec commented Oct 15, 2021

Description

This a step in the a sequence of updates to our DevOps infrastructures:

  1. Propose and draft the CI pipeline in Github Action
  2. Setup self-hosted machines to run our GPU workloads
  3. Create feature parity with the existing CI pipelines (pr-gates & nightly-build)
  4. Run tests on the appropriate dependency subsets
  5. Optimize build time for unit tests
  6. Enforce flake8 (coding style checks) on the build and clean up coding styles to pass flake8 checks <---- (Current PR)
  7. Deprecate CI pipelines in ADO and switch to Github Actions

Existing flake8 Issues

In this PR, we addressed the following flake8 issues

Simple style issues (deletion/addition)

  • W291 trailing whitespace **
  • W292 no newline at end of file
  • W391 blank line at end of file **
  • W293 blank line contains whitespace **
  • E303 too many blank lines (2)
  • E262 inline comment should start with '# '
  • E266 too many leading '#' for block comment
  • E265 block comment should start with '# '
  • E501 line too long
  • E302 expected 2 blank lines, found 1
  • E128 continuation line under-indented for visual indent
  • E126 continuation line over-indented for hanging
  • E226 missing whitespace around arithmetic operator
  • E401 multiple imports on one line
  • F541 f-string is missing placeholders
  • F811 redefinition of unused 'pd' from line 4
  • F841 local variable 'a' is assigned to but never used**
  • F401 'X' imported but unused **
For reviewers: rules marked with (**) have significant number of violations and may need more attention there.

Below are the flake8 rules we can ignore permanently

  • W503 line break before binary operator
    • ex:
             print(
                     "at epoch {0:d}".format(epoch)
                     + "\ntrain info: "
                     + train_info
                     + "\neval info: "
                     + eval_info
                     + "\ntest info: "
                     + test_info
                 #___^
                 )
  • E203 whitespace before ':'
    • ex:
       lambda x: x[:, hparams.title_size + hparams.body_size + 1 :]
                                                           #____^

If there's any other flake8 rules we wish to undo and ignore permanently, we can do that easily too 😃 .

NOTE: folders including tests, docs, contrib, examples are excluded from flake8 checks. For more details please see tox.ini

Todo in a subsequent PR:

Coding Convention Issues

  • E712 comparison to True should be 'if cond is True:' or 'if cond:'
  • E711 comparison to None should be 'if cond is None:'
  • E722 do not use bare 'except'
  • E741 ambiguous variable name 'l'
  • F403 'from X import *' used; unable to detect undefined names
  • F405 'Dense' may be undefined, or defined from star imports: tensorflow.keras.layers

Critical issues (can be indication of potential bugs)

  • W605 invalid escape sequence
  • F821 undefined name 'K'

Checklist:

  • I have followed the contribution guidelines and code style for this project.
  • I have added tests covering my contributions.
  • I have updated the documentation accordingly.
  • This PR is being made to staging branch and not to main branch.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2021

Codecov Report

Merging #1550 (6f485c3) into staging (ce81bdd) will decrease coverage by 0.20%.
The diff coverage is 58.13%.

Impacted file tree graph

@@             Coverage Diff             @@
##           staging    #1550      +/-   ##
===========================================
- Coverage    62.07%   61.86%   -0.21%     
===========================================
  Files           84       84              
  Lines         8492     8436      -56     
===========================================
- Hits          5271     5219      -52     
+ Misses        3221     3217       -4     
Flag Coverage Δ
pr-gate 61.86% <58.13%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
recommenders/datasets/cosmos_cli.py 0.00% <ø> (ø)
recommenders/datasets/covid_utils.py 90.00% <ø> (-0.25%) ⬇️
recommenders/datasets/criteo.py 86.79% <ø> (ø)
recommenders/datasets/download_utils.py 90.00% <ø> (-0.20%) ⬇️
recommenders/datasets/movielens.py 68.44% <ø> (-0.14%) ⬇️
recommenders/datasets/sparse.py 90.47% <ø> (ø)
recommenders/datasets/split_utils.py 87.75% <ø> (-0.25%) ⬇️
recommenders/evaluation/python_evaluation.py 93.68% <ø> (ø)
recommenders/evaluation/spark_evaluation.py 86.60% <ø> (ø)
...ecommenders/models/deeprec/DataModel/ImplicitCF.py 80.68% <ø> (-0.22%) ⬇️
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d867e87...6f485c3. Read the comment docs.

@laserprec laserprec mentioned this pull request Oct 19, 2021
4 tasks
Copy link
Collaborator

@miguelgfierro miguelgfierro left a comment

Choose a reason for hiding this comment

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

This is great. @laserprec, were all these changes automatic or did you do them manually?

@@ -1071,16 +1076,20 @@ def user_diversity(
introducing serendipity into music recommendation, WSDM 2012

Args:
train_df (pandas.DataFrame): Data set with historical data for users and items they have interacted with; contains col_user, col_item. Assumed to not contain any duplicate rows.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you checked that these docstrings appear as before after compilation in the docs/html ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have but let me confirm again.

Copy link
Contributor Author

@laserprec laserprec Oct 19, 2021

Choose a reason for hiding this comment

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

After newlines added (<TEST_TEST_TEST> is added to differentiate):
image

Current version

Confirmed. Newlines shouldn't affect the sphinx documentation.

@laserprec
Copy link
Contributor Author

This is great. @laserprec, were all these changes automatic or did you do them manually?

Thanks @miguelgfierro! Some of the fixes are done using vscode shortcut and black, but it is orchestrated manually 😝.

@laserprec laserprec enabled auto-merge October 19, 2021 18:33
@laserprec laserprec merged commit b2b28c9 into staging Oct 19, 2021
@laserprec laserprec deleted the laserprec/flake8-fix branch October 19, 2021 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flake8 Issues
4 participants