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

Using xdist to run pytest in parallel #6620

Merged
merged 22 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d2750fd
Using xdist to run pytest in parallel
unkcpz Nov 19, 2024
577c188
Add to requirement deps list
unkcpz Nov 20, 2024
5848b8c
The regular tests suits as well
unkcpz Nov 20, 2024
115e041
Fix order change entry points test for xdist
unkcpz Nov 20, 2024
7bb6476
Clean storage before test_base_data_nodes
unkcpz Nov 21, 2024
81895bb
Rename the fixture for static node/data entry points
unkcpz Nov 21, 2024
3bf2c72
Make restapi ports dynamic and non-conflict
unkcpz Nov 21, 2024
e740a0e
test_all_plugins conflict when run in parallel
unkcpz Nov 21, 2024
9b4bd40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
d697748
Merge branch 'main' into xdist
unkcpz Nov 24, 2024
b2656d4
Merge branch 'main' into xdist
unkcpz Nov 28, 2024
9f591fe
Independent profile in test_log.py
unkcpz Nov 28, 2024
2612f52
Merge branch 'main' into xdist
unkcpz Nov 29, 2024
62f6a54
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 29, 2024
305cc54
Clean Db before query when the test need count
unkcpz Nov 29, 2024
2b4eda3
Clean storage for test_authinfo tests
unkcpz Nov 29, 2024
39d083f
test_group.py all require reset DB
unkcpz Nov 29, 2024
b832d6a
Replace string and then sort for graph node string tests
unkcpz Nov 29, 2024
1d5b9ba
Also for test in test-install
unkcpz Nov 29, 2024
f7d3072
clean storage before for test_walk_nodes
unkcpz Nov 29, 2024
bc69416
Merge branch 'main' into xdist
unkcpz Nov 30, 2024
311bee7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
AIIDA_WARN_v3: 1
# Python 3.12 has a performance regression when running with code coverage
# so run code coverage only for python 3.9.
run: pytest -v tests -m 'not nightly' ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
run: pytest -v tests -n auto -m 'not nightly' ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}

- name: Upload coverage report
if: matrix.python-version == 3.9 && github.repository == 'aiidateam/aiida-core'
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
- name: Run test suite
env:
AIIDA_WARN_v3: 0
run: pytest -m 'presto'
run: pytest -n auto -m 'presto'


verdi:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ tests = [
'pytest-rerunfailures~=12.0',
'pytest-benchmark~=4.0',
'pytest-regressions~=2.2',
'pytest-xdist~=3.6',
'pympler~=1.0',
'coverage~=7.0',
'sphinx~=7.2.0',
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-py-3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0
pytest-timeout==2.2.0
pytest-xdist==3.6.1
python-dateutil==2.8.2
python-json-logger==2.0.7
python-memcached==1.59
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-py-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0
pytest-timeout==2.2.0
pytest-xdist==3.6.1
python-dateutil==2.8.2
python-json-logger==2.0.7
python-memcached==1.59
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-py-3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pytest-datadir==1.5.0
pytest-regressions==2.5.0
pytest-rerunfailures==12.0
pytest-timeout==2.2.0
pytest-xdist==3.6.1
unkcpz marked this conversation as resolved.
Show resolved Hide resolved
python-dateutil==2.8.2
python-json-logger==2.0.7
python-memcached==1.59
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-py-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0
pytest-timeout==2.2.0
pytest-xdist==3.6.1
python-dateutil==2.8.2
python-json-logger==2.0.7
python-memcached==1.59
Expand Down
35 changes: 18 additions & 17 deletions tests/orm/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pytest
from aiida import orm
from aiida.orm.fields import add_field
from aiida.plugins import load_entry_point
from importlib_metadata import entry_points

EPS = entry_points()
Expand All @@ -27,24 +28,24 @@ def test_all_entity_fields(entity_cls, data_regression):
)


@pytest.mark.parametrize(
'group,name',
(
(group, name)
for group in (
'aiida.node',
'aiida.data',
)
for name in EPS.select(group=group).names
),
)
def test_all_node_fields(group, name, data_regression):
@pytest.fixture
def available_entry_points():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, this is much better. Maybe the name of the fixture should be more specific, since you're only returning node and data entry points. Perhaps node_and_data_entry_points?

"""Return a list of available entry points."""
_eps = []
eps = entry_points()
for group in ['aiida.node', 'aiida.data']:
_eps.extend((group, ep.name) for ep in eps.select(group=group))
return _eps


def test_all_node_fields(available_entry_points, data_regression):
"""Test that all the node fields are correctly registered."""
node_cls = next(iter(tuple(EPS.select(group=group, name=name)))).load()
data_regression.check(
{key: repr(value) for key, value in node_cls.fields._dict.items()},
basename=f'fields_{group}.{name}.{node_cls.__name__}',
)
for group, name in available_entry_points:
node_cls = load_entry_point(group, name)
data_regression.check(
{key: repr(value) for key, value in node_cls.fields._dict.items()},
basename=f'fields_{group}.{name}.{node_cls.__name__}',
)


def test_add_field():
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/archive/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


@pytest.mark.parametrize('entities', ['all', 'specific'])
def test_base_data_nodes(aiida_profile, tmp_path, entities):
def test_base_data_nodes(aiida_profile_clean, tmp_path, entities):
unkcpz marked this conversation as resolved.
Show resolved Hide resolved
"""Test ex-/import of Base Data nodes"""
# producing values for each base type
values = ('Hello', 6, -1.2399834e12, False)
Expand All @@ -45,7 +45,7 @@ def test_base_data_nodes(aiida_profile, tmp_path, entities):
# actually export now
create(filename=filename)
# cleaning:
aiida_profile.reset_storage()
aiida_profile_clean.reset_storage()
# Importing back the data:
import_archive(filename)
# Checking whether values are preserved:
Expand Down
Loading