codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
199 stars 270 forks source link

Process killed on testing using current command mentioned in README. #547

Open Kishan-Ved opened 6 months ago

Kishan-Ved commented 6 months ago

Description of the problem

On running the mentioned command for testing: python3 -m pytest --doctest-modules --cov=./ --cov-report=html The process gets killed as shown:

======================================================== test session starts ========================================================
platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-0.13.0
rootdir: /home/kishan/Desktop/pydatastructs
plugins: xdist-3.5.0, cov-4.1.0
collected 167 items                                                                                                                 

pydatastructs/graphs/algorithms.py ..........                                                                                 [  5%]
pydatastructs/graphs/graph.py .                                                                                               [  6%]
pydatastructs/graphs/tests/test_adjacency_list.py .                                                                           [  7%]
pydatastructs/graphs/tests/test_adjacency_matrix.py .                                                                         [  7%]
pydatastructs/graphs/tests/test_algorithms.py .........                                                                       [ 13%]
pydatastructs/linear_data_structures/algorithms.py ......................                                                     [ 26%]
pydatastructs/linear_data_structures/arrays.py ...                                                                            [ 28%]
pydatastructs/linear_data_structures/linked_lists.py .....                                                                    [ 31%]
pydatastructs/linear_data_structures/tests/test_algorithms.py .......................                                         [ 44%]
pydatastructs/linear_data_structures/tests/test_arrays.py ...                                                                 [ 46%]
pydatastructs/linear_data_structures/tests/test_linked_lists.py .....                                                         [ 49%]
pydatastructs/linear_data_structures/tests/benchmarks/test_algorithms.py XXKilled

I found that using all available cores can prevent this problem, achieved by running: python3 -m pytest --doctest-modules --cov=./ --cov-report=html -n auto

This did end up better, it's not properly terminated, but this might also be a code issue. Here's the output:

======================================================== test session starts ========================================================
platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-0.13.0
rootdir: /home/kishan/Desktop/pydatastructs
plugins: xdist-3.5.0, cov-4.1.0
4 workers [167 items]   
............................................................................................................................. [ 74%]
..........................XXx..XX.XX[gw2] node down: Not properly terminated
F
replacing crashed worker gw2
5 workers [167 items]  .....
============================================================= FAILURES ==============================================================
_____________________________ pydatastructs/linear_data_structures/tests/benchmarks/test_algorithms.py ______________________________
[gw2] linux -- Python 3.10.12 /usr/bin/python3
worker 'gw2' crashed while running 'pydatastructs/linear_data_structures/tests/benchmarks/test_algorithms.py::test_selection_sort'
========================================================= warnings summary ==========================================================
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
../../.local/lib/python3.10/site-packages/xdist/plugin.py:252
  /home/kishan/.local/lib/python3.10/site-packages/xdist/plugin.py:252: DeprecationWarning: The --rsyncdir command line argument and rsyncdirs config variable are deprecated.
  The rsync feature will be removed in pytest-xdist 4.0.
    config.issue_config_time_warning(warning, 2)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.10.12-final-0 ----------
---------------------- coverage: failed workers ----------------------
The following workers failed to return coverage data, ensure that pytest-cov is installed on these workers.
gw2
Coverage HTML written to dir htmlcov

====================================================== short test summary info ======================================================
FAILED pydatastructs/linear_data_structures/tests/benchmarks/test_algorithms.py::test_selection_sort
============================ 1 failed, 159 passed, 1 xfailed, 6 xpassed, 6 warnings in 106.82s (0:01:46) ============================

End Note:

Should I make a PR to modify the README command to allow multiple cores to run? I'll also include how -n command is achieved (by installing pytest-xdist).

czgdp1807 commented 6 months ago

It got killed during benchmarking tests. I remember we added an option where you can turn off benchmarking tests if they are too heavy to run on your system. What's your system configuration?

Kishan-Ved commented 6 months ago

Sorry I might have missed the notification of this message. I'm using a Lenovo Ideapad Slim 3 having a 10th Gen core i5, with a 1TB HDD and 256GB SSD. For my OS, I use Ubuntu 22.04.3 LTS (though I have it dual booted with Windows 11).

Side note: I found that using all available cores can prevent this problem, achieved by running: python3 -m pytest --doctest-modules --cov=./ --cov-report=html -n auto

Kishan-Ved commented 5 months ago

Should I create a PR for this? I'll add: python3 -m pytest --doctest-modules --cov=./ --cov-report=html -n auto