Skip to content

[BUG]: Coverage in parallel #60

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
jorgensd opened this issue Oct 27, 2022 · 0 comments
Open

[BUG]: Coverage in parallel #60

jorgensd opened this issue Oct 27, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jorgensd
Copy link
Member

How to reproduce the bug

mpirun -n 2 python3 -m pytest .

Error output

============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.2.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root/reproducibility, configfile: pyproject.toml, testpaths: test
plugins: cov-4.0.0
collecting ... ============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.2.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root/reproducibility, configfile: pyproject.toml, testpaths: test
plugins: cov-4.0.0
collecting ... collected 1 item

test/test_code.py::test_addition collected 1 item

test/test_code.py::test_addition PASSED                                  [100%]PASSED                                  [100%]
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 1106, in execute
INTERNALERROR>     return self.con.execute(sql, parameters)
INTERNALERROR> sqlite3.OperationalError: no such table: coverage_schema
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 1111, in execute
INTERNALERROR>     return self.con.execute(sql, parameters)
INTERNALERROR> sqlite3.OperationalError: no such table: coverage_schema
INTERNALERROR> 
INTERNALERROR> The above exception was the direct cause of the following exception:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 272, in _read_db
INTERNALERROR>     schema_version, = db.execute_one("select version from coverage_schema")
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 1147, in execute_one
INTERNALERROR>     rows = list(self.execute(sql, parameters))
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 1128, in execute
INTERNALERROR>     raise DataError(f"Couldn't use data file {self.filename!r}: {msg}") from exc
INTERNALERROR> coverage.exceptions.DataError: Couldn't use data file '/root/reproducibility/.coverage': no such table: coverage_schema
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 324, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 55, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pytest_cov/plugin.py", line 297, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pytest_cov/engine.py", line 44, in ensure_topdir_wrapper
INTERNALERROR>     return meth(self, *args, **kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/pytest_cov/engine.py", line 247, in finish
INTERNALERROR>     self.cov.combine()
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/control.py", line 755, in combine
INTERNALERROR>     combine_parallel_data(
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/data.py", line 132, in combine_parallel_data
INTERNALERROR>     data.update(new_data, aliases=aliases)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 657, in update
INTERNALERROR>     with self._connect() as con:
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 315, in _connect
INTERNALERROR>     self._open_db()
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 266, in _open_db
INTERNALERROR>     self._read_db()
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 275, in _read_db
INTERNALERROR>     self._init_db(db)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 301, in _init_db
INTERNALERROR>     db.executescript(SCHEMA)
INTERNALERROR>   File "/usr/local/lib/python3.10/dist-packages/coverage/sqldata.py", line 1178, in executescript
INTERNALERROR>     self.con.executescript(script)
INTERNALERROR> sqlite3.OperationalError: table coverage_schema already exists

============================== 1 passed in 0.01s ===============================


---------- coverage: platform linux, python 3.10.6-final-0 -----------
Name                                                             Stmts   Miss  Cover   Missing
----------------------------------------------------------------------------------------------
/usr/local/lib/python3.10/dist-packages/mypackage/__init__.py        5      0   100%
/usr/local/lib/python3.10/dist-packages/mypackage/functions.py       7      3    57%   16-18
----------------------------------------------------------------------------------------------
TOTAL                                                               12      3    75%
Coverage HTML written to dir htmlcov


============================== 1 passed in 0.02s ===============================

Version

main branch

system

FROM ubuntu:22.04

WORKDIR /root/


RUN apt-get update && \
    apt-get install -y git mpich python3-pip && \
    python3 -m pip install --upgrade pip setuptools && \
    apt-get purge -y python3-setuptools

RUN git clone https://github.com/scientificcomputing/reproducibility


RUN python3 -m pip install ./reproducibility[test]

Additional information

Fixed with adding --cov-append to

[tool.pytest.ini_options]
addopts
@jorgensd jorgensd added the bug Something isn't working label Oct 27, 2022
@jorgensd jorgensd self-assigned this Oct 27, 2022
jorgensd added a commit to scientificcomputing/generate-python-package that referenced this issue Oct 28, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant