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

GH-36642: [Python][CI] Configure warnings as errors during pytest #37018

Merged
merged 5 commits into from
Aug 7, 2023

Conversation

danepitkin
Copy link
Member

@danepitkin danepitkin commented Aug 3, 2023

Rationale for this change

Warnings are constantly being introduced into the pyarrow tests. Let's try enforcing them as errors in an effort to keep the codebase healthy.

What changes are included in this PR?

  • Fixed existing warnings
  • Set warnings as errors in CI

Are these changes tested?

Yes, ran pytests locally w/o warnings.

Are there any user-facing changes?

No

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

In the case of PARQUET issues on JIRA the title also supports:

PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

See also:

@danepitkin
Copy link
Member Author

I enabled warnings as errors for conda python 3.8 through 3.11 and for conda python pandas integration to see what happens. Realistically, we probably want to limit warnings to just the latest python version (currently 3.11).

@danepitkin
Copy link
Member Author

@github-actions crossbow submit test-conda-python*

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Revision: 9195826

Submitted crossbow builds: ursacomputing/crossbow @ actions-1e510b906c

Task Status
test-conda-python-3.10 Github Actions
test-conda-python-3.10-hdfs-2.9.2 Github Actions
test-conda-python-3.10-hdfs-3.2.1 Github Actions
test-conda-python-3.10-pandas-latest Github Actions
test-conda-python-3.10-pandas-nightly Github Actions
test-conda-python-3.10-spark-v3.4.1 Github Actions
test-conda-python-3.10-substrait Github Actions
test-conda-python-3.11 Github Actions
test-conda-python-3.11-dask-latest Github Actions
test-conda-python-3.11-dask-upstream_devel Github Actions
test-conda-python-3.11-hypothesis Github Actions
test-conda-python-3.11-pandas-upstream_devel Github Actions
test-conda-python-3.11-spark-master Github Actions
test-conda-python-3.8 Github Actions
test-conda-python-3.8-pandas-1.0 Github Actions
test-conda-python-3.8-spark-v3.4.1 Github Actions
test-conda-python-3.9 Github Actions
test-conda-python-3.9-pandas-latest Github Actions

@danepitkin
Copy link
Member Author

For python 3.8 through 3.11 there is only 1 warning (repeated in 5 test cases).

____________________ ERROR at setup of test_read_s3fs[True] ____________________
___________________ ERROR at setup of test_read_s3fs[False] ____________________
_______________ ERROR at setup of test_read_directory_s3fs[True] _______________
______________ ERROR at setup of test_read_directory_s3fs[False] _______________
__________ ERROR at setup of test_write_metadata_fs_file_combinations __________

cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7fd5884620f0>
when = 'setup'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

opt/conda/envs/arrow/lib/python3.9/site-packages/_pytest/runner.py:341: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
opt/conda/envs/arrow/lib/python3.9/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
opt/conda/envs/arrow/lib/python3.9/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
opt/conda/envs/arrow/lib/python3.9/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
opt/conda/envs/arrow/lib/python3.9/site-packages/_pytest/unraisableexception.py:83: in pytest_runtest_setup
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
E               
E               Traceback (most recent call last):
E                 File "/opt/conda/envs/arrow/lib/python3.9/site-packages/_pytest/fixtures.py", line 902, in call_fixture_func
E                   fixture_result = fixturefunc(**kwargs)
E               ResourceWarning: unclosed <socket.socket fd=189, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 35258), raddr=('127.0.0.1', 56633)>

opt/conda/envs/arrow/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning

@danepitkin
Copy link
Member Author

@github-actions crossbow submit test-conda-python*

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Revision: 6db95f6

Submitted crossbow builds: ursacomputing/crossbow @ actions-2a9b540c67

Task Status
test-conda-python-3.10 Github Actions
test-conda-python-3.10-hdfs-2.9.2 Github Actions
test-conda-python-3.10-hdfs-3.2.1 Github Actions
test-conda-python-3.10-pandas-latest Github Actions
test-conda-python-3.10-pandas-nightly Github Actions
test-conda-python-3.10-spark-v3.4.1 Github Actions
test-conda-python-3.10-substrait Github Actions
test-conda-python-3.11 Github Actions
test-conda-python-3.11-dask-latest Github Actions
test-conda-python-3.11-dask-upstream_devel Github Actions
test-conda-python-3.11-hypothesis Github Actions
test-conda-python-3.11-pandas-upstream_devel Github Actions
test-conda-python-3.11-spark-master Github Actions
test-conda-python-3.8 Github Actions
test-conda-python-3.8-pandas-1.0 Github Actions
test-conda-python-3.8-spark-v3.4.1 Github Actions
test-conda-python-3.9 Github Actions
test-conda-python-3.9-pandas-latest Github Actions

@danepitkin
Copy link
Member Author

@github-actions crossbow submit test-conda-python*

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Revision: fca7663

Submitted crossbow builds: ursacomputing/crossbow @ actions-45800058d0

Task Status
test-conda-python-3.10 Github Actions
test-conda-python-3.10-hdfs-2.9.2 Github Actions
test-conda-python-3.10-hdfs-3.2.1 Github Actions
test-conda-python-3.10-pandas-latest Github Actions
test-conda-python-3.10-pandas-nightly Github Actions
test-conda-python-3.10-spark-v3.4.1 Github Actions
test-conda-python-3.10-substrait Github Actions
test-conda-python-3.11 Github Actions
test-conda-python-3.11-dask-latest Github Actions
test-conda-python-3.11-dask-upstream_devel Github Actions
test-conda-python-3.11-hypothesis Github Actions
test-conda-python-3.11-pandas-upstream_devel Github Actions
test-conda-python-3.11-spark-master Github Actions
test-conda-python-3.8 Github Actions
test-conda-python-3.8-pandas-1.0 Github Actions
test-conda-python-3.8-spark-v3.4.1 Github Actions
test-conda-python-3.9 Github Actions
test-conda-python-3.9-pandas-latest Github Actions

@danepitkin danepitkin changed the title WIP: [Python][CI] Configure warnings as errors during pytest GH-36642: [Python][CI] Configure warnings as errors during pytest Aug 4, 2023
@github-actions
Copy link

github-actions bot commented Aug 4, 2023

⚠️ GitHub issue #36642 has been automatically assigned in GitHub to PR creator.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

BTW, are you interested in taking over #36745 from me...?

@kou kou merged commit 2b36521 into apache:main Aug 7, 2023
@kou kou removed the awaiting review Awaiting review label Aug 7, 2023
@github-actions github-actions bot added the awaiting merge Awaiting merge label Aug 7, 2023
@danepitkin
Copy link
Member Author

Hey @kou, sure I can take a look!

@kou
Copy link
Member

kou commented Aug 8, 2023

Thanks!

@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 2b36521.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
…st (apache#37018)

### Rationale for this change

Warnings are constantly being introduced into the pyarrow tests. Let's try enforcing them as errors in an effort to keep the codebase healthy.

### What changes are included in this PR?

* Fixed existing warnings
* Set warnings as errors in CI

### Are these changes tested?

Yes, ran pytests locally w/o warnings.

### Are there any user-facing changes?

No
* Closes: apache#36642

Authored-by: Dane Pitkin <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants