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

Pylint integration updates #643

Merged
merged 16 commits into from
Jan 19, 2024
Merged

Conversation

macohen
Copy link
Contributor

@macohen macohen commented Jan 8, 2024

Description

  • extracted a method for per-folder linting
  • created a feature flag for newer dynamic pylint so now lints can be fixed first locally and then enabled without forcing build failures
  • ignore opensearchpy for pylint
  • updated noxfile.lint_per_folder with type hints
  • enabled unspecified-encoding in pylint
  • added disable missing-function-docstring pragma to test_clients.py in test_async and test_server

Issues Resolved

Progress on #610

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…l continue to work on this before committing setup.cfg

Signed-off-by: Mark Cohen <[email protected]>
…'t fail while work on docstrings continues

Signed-off-by: Mark Cohen <[email protected]>
…ns; added a utility to automatically add these ignore instructions to most functions that should be self-describing; rolled back some automatically generated code mistakenly changed

Signed-off-by: Mark Cohen <[email protected]>
Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3eba72c) 72.10% compared to head (107469c) 72.04%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #643      +/-   ##
==========================================
- Coverage   72.10%   72.04%   -0.07%     
==========================================
  Files          89       89              
  Lines        7949     7945       -4     
==========================================
- Hits         5732     5724       -8     
- Misses       2217     2221       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@macohen macohen force-pushed the tests-doc-strings branch 4 times, most recently from 206dff7 to 1680f34 Compare January 8, 2024 16:06
* fixed some lints; created a feature flag for newer dynamic pylint so now lints can be fixed first in legacy code and then enabled by multiple people
* extracted a method for per-folder linting
* updated noxfile.lint_per_folder with type hints
* enabled unspecified-encoding in pylint
* added disable missing-function-docstring pragma to test_clients.py in test_async and test_server
* added more encodings to pass unspecified-encoding pylint tests
* updated changelog
Signed-off-by: Mark Cohen <[email protected]>
@macohen macohen force-pushed the tests-doc-strings branch from 1680f34 to d26eba5 Compare January 8, 2024 16:08
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I htink all or some of this PR should be merged, the thing I am strongly against is adding # pylint: disable=missing-function-docstring in every test. That is a huge burden on test authors for no value at all, so how can this be avoided? More comments inline.

CHANGELOG.md Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Looks better.

I am still against adding # pylint: disable=missing-function-docstring to all the test files. Can we undo that part and skip that linter for tests?

noxfile.py Show resolved Hide resolved
removed the feature flag for pylint lint_per_folder
fixed failures from mypy and pylint
removed pylint MESSAGE CONTROL config from setup.cfg after relocating to lint_per_folder method
Signed-off-by: Mark Cohen <[email protected]>
@macohen macohen force-pushed the tests-doc-strings branch 3 times, most recently from 066aa7b to 2a03f3e Compare January 11, 2024 14:09
test_opensearchpy/test_server/test_helpers/conftest.py Outdated Show resolved Hide resolved
yields the version of the OpenSearch cluster
:param client:
:return:
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing param description

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'm also adding a pylint extension to add missing-param-doc (when a parameter is missing from the docstring) and differing-param-doc (when a parameter is different in the function definition and the docstring).

updated some docstrings to correct parameters

removed pylint from setup.cfg

Signed-off-by: Mark Cohen <[email protected]>
dblock
dblock previously approved these changes Jan 17, 2024
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

@saimedhi what remains to be done to get this merged? Let's get an iteration in?

@saimedhi
Copy link
Collaborator

Thank you, @macohen , for your contribution! I'll thoroughly review the PR today and aim to merge it soon. I've observed a failing integration test, so I'm rerunning it to determine if it's a flaky test.

@macohen
Copy link
Contributor Author

macohen commented Jan 17, 2024

Thank you, @macohen , for your contribution! I'll thoroughly review the PR today and aim to merge it soon. I've observed a failing integration test, so I'm rerunning it to determine if it's a flaky test.

Thanks @saimedhi. That's the test against main?

FAILED test_opensearchpy/test_server/test_rest_api_spec.py::test_rest_api_spec[OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/stats/50_noop_update[0]] - opensearchpy.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=3))

I'm not sure I've ever seen that test succeed in this PR.

@saimedhi
Copy link
Collaborator

saimedhi commented Jan 17, 2024

Thank you, @macohen , for your contribution! I'll thoroughly review the PR today and aim to merge it soon. I've observed a failing integration test, so I'm rerunning it to determine if it's a flaky test.

Thanks @saimedhi. That's the test against main?

FAILED test_opensearchpy/test_server/test_rest_api_spec.py::test_rest_api_spec[OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/stats/50_noop_update[0]] - opensearchpy.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=3))

I'm not sure I've ever seen that test succeed in this PR.

Yes, it is test against main or unreleased OpenSearch. I will check, if the failing test is related to this PR or not.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Here's why the test fails.

:param client:
:return:
"""
info = client.info()
Copy link
Member

@dblock dblock Jan 17, 2024

Choose a reason for hiding this comment

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

This is missing an await, was edited out, so you get the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was also a dumb copy/paste error if you look at the wider scope. fixing. thanks, @dblock.

saimedhi
saimedhi previously approved these changes Jan 18, 2024
Copy link
Collaborator

@saimedhi saimedhi left a comment

Choose a reason for hiding this comment

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

A recently added test is failing. Please add it to the skip list here. Apart from that, I'm okay with merging this code. A few minor points below can be addressed in a follow-up PR if interested. Tested by running samples and generator, and they are working fine.

opensearchpy/compat.py Outdated Show resolved Hide resolved
test_opensearchpy/run_tests.py Outdated Show resolved Hide resolved
utils/generate_api.py Outdated Show resolved Hide resolved
@saimedhi
Copy link
Collaborator

Hi @macohen, in your latest commit, could you please remove the changes causing test failures? If not, consider excluding that commit and let's proceed with merging this code. We can address the other changes in a follow-up PR. Apologies for the delay.

@macohen macohen force-pushed the tests-doc-strings branch 4 times, most recently from 030d5ae to d8247a0 Compare January 19, 2024 01:34
@macohen
Copy link
Contributor Author

macohen commented Jan 19, 2024

Hi @macohen, in your latest commit, could you please remove the changes causing test failures? If not, consider excluding that commit and let's proceed with merging this code. We can address the other changes in a follow-up PR. Apologies for the delay.

Thanks. I was working on figuring out how to run the two tasks that are failing locally so I can reproduce the failures. I thought I needed to check out the appropriate branch of opensearch (2.0, main) and run the commands in the workflow, but I haven't been able to reproduce. If you have any guidance there, that would be helpful. Also, I will update this comment in about an hour with the command I'm running...

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I opened #651 with a trivial change and it failed in these integration tests the same way. @macohen open an issue please, fix the TODOs ask and we'll merge this.

renamed test_opensearchpy.test_async.test_server.test_helpers.conftest.setup_ubq_tests to setup_update_by_query_tests

added
OpenSearch-main/rest-api-spec/src/main/resources/rest-api-spec/test/indices/stats/50_noop_update[0]
to skip tests list

run_tests.py catches a CalledProcessError when the git repo already exists and the command to add the origin fails in fetch_opensearch_repo()

Signed-off-by: Mark Cohen <[email protected]>
@macohen
Copy link
Contributor Author

macohen commented Jan 19, 2024

I opened #651 with a trivial change and it failed in these integration tests the same way. @macohen open an issue please, fix the TODOs ask and we'll merge this.

Opened #653, pushed an update with the failing test skipped and all checks pass now! Thanks to @saimedhi and @dblock for all the help and patience. :)

@dblock dblock merged commit 0ddbf8c into opensearch-project:main Jan 19, 2024
54 checks passed
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.

3 participants