Skip to content

Commit cb5348e

Browse files
authored
Cleanup warnings in tests (#6911)
* Only show 5 slowest test durations * Remove deprecation warning in cmd_node.py * Remove deprecation warnings in tests/cmdline/commands/test_node.py * Add stacklevel to warn_deprecation * Ignore plumpy get_event_loop deprecation warning * Fix fixture in tests/cmdline/commands/test_process.py * Ignore 'dict interface' spglib deprecation warning * Fix pymatgen deprecation warning tests/test_dataclasses.py::TestStructureDataFromPymatgen::test_1 tests/test_dataclasses.py:2098: FutureWarning: get_structures is deprecated; use parse_structures in pymatgen.io.cif instead. The only difference is that primitive defaults to False in the new parse_structures method. So parse_structures(primitive=True) is equivalent to the old behavior of get_structures(). pymatgen_struct = pymatgen_parser.get_structures()[0]
1 parent b235b3a commit cb5348e

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ ignore_errors = true
378378
module = 'plumpy'
379379

380380
[tool.pytest.ini_options]
381-
addopts = '--benchmark-skip --durations=50 --durations-min=1 --strict-config --strict-markers -ra --cov-report xml --cov-append '
381+
addopts = '--benchmark-skip --durations=5 --durations-min=1 --strict-config --strict-markers -ra --cov-report xml --cov-append '
382382
filterwarnings = [
383383
'ignore:.*and will be removed in NumPy 2.0.*:DeprecationWarning:ase:',
384384
'ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:pytz|dateutil|tqdm|aio_pika:',
@@ -398,6 +398,10 @@ filterwarnings = [
398398
'ignore:Identity map already had an identity for .* inside of an event handler within the flush?:sqlalchemy.exc.SAWarning',
399399
'ignore:The `aiida.orm.nodes.data.upf` module is deprecated.*:aiida.common.warnings.AiidaDeprecationWarning',
400400
'ignore:The `Code` class is deprecated.*:aiida.common.warnings.AiidaDeprecationWarning',
401+
# https://github.com/aiidateam/plumpy/issues/283
402+
'ignore:There is no current event loop:DeprecationWarning:plumpy',
403+
# spglib deprecation
404+
'ignore:dict interface is deprecated:DeprecationWarning',
401405
'default::ResourceWarning'
402406
]
403407
markers = [

src/aiida/cmdline/commands/cmd_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def _perform_delete():
372372
from aiida.orm.utils.remote import clean_mapping_remote_paths, get_calcjob_remote_paths
373373
from aiida.tools.graph.graph_traversers import get_nodes_delete
374374

375-
backend = get_manager().get_backend()
375+
backend = get_manager().get_profile_storage()
376376
# For here we ignore missing nodes will be raised via func:``delete_nodes`` in the next block
377377
pks_set_to_delete = get_nodes_delete(
378378
pks, get_links=False, missing_callback=lambda missing_pks: None, backend=backend, **traversal_rules

src/aiida/manage/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def get_backend(self) -> 'StorageBackend':
248248
"""
249249
from aiida.common.warnings import warn_deprecation
250250

251-
warn_deprecation('get_backend() is deprecated, use get_profile_storage() instead', version=3)
251+
warn_deprecation('get_backend() is deprecated, use get_profile_storage() instead', version=3, stacklevel=3)
252252
return self.get_profile_storage()
253253

254254
def get_profile_storage(self) -> 'StorageBackend':

tests/cmdline/commands/test_node.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def _setup(n_workflows=1, n_calcjobs=1, n_remotes=1):
606606

607607
for i in range(n_calcjobs):
608608
calcjob_node = CalcJobNode(computer=aiida_localhost)
609-
calcjob_node.add_incoming(workflow_node, link_type=LinkType.CALL_CALC, link_label='call')
609+
calcjob_node.base.links.add_incoming(workflow_node, link_type=LinkType.CALL_CALC, link_label='call')
610610

611611
workdir = tmp_path / f'calcjob_{uuid.uuid4()}'
612612
workdir.mkdir()
@@ -637,22 +637,22 @@ def verify_deletion(self, nodes_deleted=True, folders_deleted=True):
637637
if nodes_deleted:
638638
for workflow_pk in self.workflow_pks:
639639
with pytest.raises(NotExistent):
640-
WorkflowNode.objects.get(pk=workflow_pk)
640+
WorkflowNode.collection.get(pk=workflow_pk)
641641

642642
for calcjob_pk in self.calcjob_pks:
643643
with pytest.raises(NotExistent):
644-
CalcJobNode.objects.get(pk=calcjob_pk)
644+
CalcJobNode.collection.get(pk=calcjob_pk)
645645

646646
for remote_pk in self.remote_pks:
647647
with pytest.raises(NotExistent):
648-
RemoteData.objects.get(pk=remote_pk)
648+
RemoteData.collection.get(pk=remote_pk)
649649
else:
650650
for workflow_pk in self.workflow_pks:
651-
WorkflowNode.objects.get(pk=workflow_pk)
651+
WorkflowNode.collection.get(pk=workflow_pk)
652652
for calcjob_pk in self.calcjob_pks:
653-
CalcJobNode.objects.get(pk=calcjob_pk)
653+
CalcJobNode.collection.get(pk=calcjob_pk)
654654
for remote_pk in self.remote_pks:
655-
RemoteData.objects.get(pk=remote_pk)
655+
RemoteData.collection.get(pk=remote_pk)
656656

657657
for remote_folder in self.remote_folders:
658658
if folders_deleted:

tests/cmdline/commands/test_process.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ async def exponential_backoff_retry_fail_kill(fct: t.Callable[..., t.Any], *args
9595

9696

9797
@pytest.fixture(scope='function')
98-
@pytest.mark.usefixtures('started_daemon_client')
99-
def fork_worker_context(aiida_profile):
98+
def fork_worker_context(aiida_profile, started_daemon_client):
10099
"""Runs daemon worker on a new process with redirected stdout and stderr streams."""
101100
import multiprocessing
102101

103-
from aiida.engine.daemon.client import get_daemon_client
104-
105-
client = get_daemon_client(aiida_profile)
102+
client = started_daemon_client
106103
nb_workers = client.get_number_of_workers()
107104
# The workers are decreased to zero to ensure that the worker that is
108105
# subsequently started through this fixture is the one that receives all

tests/test_dataclasses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ def test_1(self):
20952095
)
20962096
tmpf.flush()
20972097
pymatgen_parser = CifParser(tmpf.name)
2098-
pymatgen_struct = pymatgen_parser.get_structures()[0]
2098+
pymatgen_struct = pymatgen_parser.parse_structures(primitive=True)[0]
20992099

21002100
structs_to_test = [StructureData(pymatgen=pymatgen_struct), StructureData(pymatgen_structure=pymatgen_struct)]
21012101

0 commit comments

Comments
 (0)