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

Devops: Address deprecation warnings from internal code and dependencies #6272

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/source/topics/processes/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ They can be accessed through the corresponding properties on the process node as
:code: python

The source code of the file in which the function is defined is also stored, but since it can be quite big, it is stored as a raw file in the repository of the process node.
It can be retrieved through the :py:meth:`~aiida.orm.utils.mixins.FunctionCalculationMixin.get_function_source_code` method.
It can be retrieved through the :py:meth:`~aiida.orm.utils.mixins.FunctionCalculationMixin.get_source_code_file` method.

The attributes give some querability to the process functions stored in the provenance graph and by storing the source code of the function that was executed, there will be some reference in the future to track how the function created its output nodes.
Note, however, that just storing the source file of the function does not guarantee that one can reproduce the exact result.
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ rest = [
'flask-cors~=3.0',
'flask-restful~=0.3.7',
'flask~=2.2',
'pyparsing~=2.4',
'pyparsing~=3.0',
'python-memcached~=1.59',
'seekpath~=1.9,>=1.9.3'
]
Expand All @@ -233,12 +233,12 @@ tests = [
'pytest~=7.0',
'pytest-asyncio~=0.12,<0.17',
'pytest-timeout~=2.0',
'pytest-cov~=2.7,<2.11',
'pytest-cov~=4.1',
'pytest-rerunfailures~=12.0',
'pytest-benchmark~=4.0',
'pytest-regressions~=2.2',
'pympler~=0.9',
'coverage~=6.0',
'pympler~=1.0',
'coverage~=7.0',
'sphinx~=7.2',
'docutils~=0.20'
]
Expand Down Expand Up @@ -356,8 +356,11 @@ filterwarnings = [
'ignore::DeprecationWarning:pymatgen:',
'ignore::DeprecationWarning:jsonbackend:',
'ignore::DeprecationWarning:pkg_resources:',
'ignore:Object of type .* not in session, .* operation along .* will not proceed:sqlalchemy.exc.SAWarning',
'ignore::pytest.PytestCollectionWarning',
'ignore:Creating AiiDA configuration folder.*:UserWarning',
'ignore:Object of type .* not in session, .* operation along .* will not proceed:sqlalchemy.exc.SAWarning',
'ignore:The `aiida.orm.nodes.data.upf` module is deprecated.*:aiida.common.warnings.AiidaDeprecationWarning',
'ignore:The `Code` class is deprecated.*:aiida.common.warnings.AiidaDeprecationWarning',
'default::ResourceWarning'
]
markers = [
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements-py-3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ click==8.1.3
click-spinner==0.1.10
comm==0.1.3
contourpy==1.1.0
coverage==6.5.0
coverage==7.4.1
cryptography==41.0.1
cycler==0.11.0
debugpy==1.6.7
Expand Down Expand Up @@ -136,15 +136,15 @@ pydantic==2.4.0
pydata-sphinx-theme==0.13.3
pygments==2.15.1
pymatgen==2023.9.25
pympler==0.9
pympler==1.0.1
pymysql==0.9.3
pynacl==1.5.0
pyparsing==2.4.7
pyparsing==3.1.1
pyrsistent==0.19.3
pytest==7.3.2
pytest-asyncio==0.16.0
pytest-benchmark==4.0.0
pytest-cov==2.10.1
pytest-cov==4.1.0
pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0.0
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements-py-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ click==8.1.3
click-spinner==0.1.10
comm==0.1.3
contourpy==1.1.0
coverage==6.5.0
coverage==7.4.1
cryptography==41.0.1
cycler==0.11.0
debugpy==1.6.7
Expand Down Expand Up @@ -135,15 +135,15 @@ pydantic==2.4.0
pydata-sphinx-theme==0.13.3
pygments==2.15.1
pymatgen==2023.9.25
pympler==0.9
pympler==1.0.1
pymysql==0.9.3
pynacl==1.5.0
pyparsing==2.4.7
pyparsing==3.1.1
pyrsistent==0.19.3
pytest==7.3.2
pytest-asyncio==0.16.0
pytest-benchmark==4.0.0
pytest-cov==2.10.1
pytest-cov==4.1.0
pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0.0
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements-py-3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ click==8.1.7
click-spinner==0.1.10
comm==0.1.4
contourpy==1.1.1
coverage==6.5.0
coverage==7.4.1
cryptography==41.0.5
cycler==0.12.1
debugpy==1.8.0
Expand Down Expand Up @@ -133,15 +133,15 @@ pydantic==2.4.0
pydata-sphinx-theme==0.13.3
pygments==2.16.1
pymatgen==2023.10.11
pympler==0.9
pympler==1.0.1
pymysql==0.9.3
pynacl==1.5.0
pyparsing==2.4.7
pyparsing==3.1.1
pyrsistent==0.19.3
pytest==7.4.2
pytest-asyncio==0.16.0
pytest-benchmark==4.0.0
pytest-cov==2.10.1
pytest-cov==4.1.0
pytest-datadir==1.5.0
pytest-regressions==2.5.0
pytest-rerunfailures==12.0.0
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements-py-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ click==8.1.3
click-spinner==0.1.10
comm==0.1.3
contourpy==1.1.0
coverage==6.5.0
coverage==7.4.1
cryptography==41.0.1
cycler==0.11.0
debugpy==1.6.7
Expand Down Expand Up @@ -138,15 +138,15 @@ pydantic==2.4.0
pydata-sphinx-theme==0.13.3
pygments==2.15.1
pymatgen==2023.9.25
pympler==0.9
pympler==1.0.1
pymysql==0.9.3
pynacl==1.5.0
pyparsing==2.4.7
pyparsing==3.1.1
pyrsistent==0.19.3
pytest==7.3.2
pytest-asyncio==0.16.0
pytest-benchmark==4.0.0
pytest-cov==2.10.1
pytest-cov==4.1.0
pytest-datadir==1.4.1
pytest-regressions==2.4.2
pytest-rerunfailures==12.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/engine/processes/calcjobs/calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def run(self) -> Union[plumpy.process_states.Stop, int, plumpy.process_states.Wa
# this case, the parser will not be called. The outputs will already have been added to the process node
# though, so all that needs to be done here is just also assign them to the process instance. This such that
# when the process returns its results, it returns the actual outputs and not an empty dictionary.
self._outputs = self.node.get_outgoing(link_type=LinkType.CREATE).nested()
self._outputs = self.node.base.links.get_outgoing(link_type=LinkType.CREATE).nested()
return self.node.exit_status

# Launch the upload operation
Expand Down
2 changes: 2 additions & 0 deletions src/aiida/engine/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def close(self) -> None:
"""Close the runner by stopping the loop."""
assert not self._closed
self.stop()
if not self._loop.is_running():
self._loop.close()
reset_event_loop_policy()
self._closed = True

Expand Down
5 changes: 1 addition & 4 deletions src/aiida/orm/nodes/data/code/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ def get_description(self):

:return: string description of this Code instance
"""
warn_deprecation(
'`Code.get_description` method is deprecated, use the `description` property instead.', version=3
)
return f'{self.description}'
return self.full_label

@classmethod
def get_code_helper(cls, label, machinename=None, backend=None):
Expand Down
15 changes: 8 additions & 7 deletions src/aiida/storage/sqlite_zip/migrations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ def copy_tar_to_zip(
temp_extracted = Path(tmpdirname) / 'extracted'
with get_progress_reporter()(total=1) as progress:
callback = create_callback(progress)
TarPath(inpath, mode='r:*').extract_tree(
temp_extracted,
allow_dev=False,
allow_symlink=False,
callback=callback,
cb_descript=f'{title} (extracting tar)',
)
with TarPath(inpath, mode='r:*') as path:
path.extract_tree(
temp_extracted,
allow_dev=False,
allow_symlink=False,
callback=callback,
cb_descript=f'{title} (extracting tar)',
)
temp_archive = Path(tmpdirname) / 'archive.zip'
with ZipPath(temp_archive, mode='w', compresslevel=compression, info_order=info_order) as new_path:
length = sum(1 for _ in temp_extracted.glob('**/*'))
Expand Down
8 changes: 8 additions & 0 deletions src/aiida/transports/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def close(self):
break
time.sleep(0.2)

for f in [self.process.stdout, self.process.stderr, self.process.stdin]:
if f is None:
continue
try:
f.close()
except ValueError:
pass
Comment on lines +72 to +73
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why ignore the ValueError specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be raised iof the file handle was already closed, which can happen

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks.



def copy_from_remote_to_remote(transportsource, transportdestination, remotesource, remotedestination, **kwargs):
"""Copy files or folders from a remote computer to another remote computer.
Expand Down
13 changes: 8 additions & 5 deletions tests/cmdline/commands/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gzip
import io
import os
import warnings

import pytest
from aiida import orm
Expand Down Expand Up @@ -401,11 +402,13 @@ def test_node_id_label_format(self, run_cli_command):
@pytest.mark.parametrize('output_file', ('without_extension', 'without_extension.pdf'))
def test_output_file(self, run_cli_command, output_file):
"""Test that the output file can be specified through an argument."""
try:
run_cli_command(cmd_node.graph_generate, [str(self.node.pk), output_file])
assert os.path.isfile(output_file)
finally:
delete_temporary_file(output_file)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
try:
run_cli_command(cmd_node.graph_generate, [str(self.node.pk), output_file])
assert os.path.isfile(output_file)
finally:
delete_temporary_file(output_file)


COMMENT = 'Well I never...'
Expand Down
50 changes: 26 additions & 24 deletions tests/cmdline/params/options/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
###########################################################################
"""Unit tests for the :class:`aiida.cmdline.params.options.config.ConfigOption`."""
import functools
import tempfile
import textwrap

import click
Expand All @@ -32,37 +31,40 @@ def cmd(integer, boolean):
click.echo(f'Boolean: {boolean}')


def test_valid(run_cli_command):
def test_valid(run_cli_command, tmp_path):
"""Test the option for a valid configuration file."""
with tempfile.NamedTemporaryFile('w+') as handle:
handle.write(
textwrap.dedent(
"""
filepath = tmp_path / 'config.yml'
filepath.write_text(
textwrap.dedent(
"""
integer: 1
boolean: false
"""
)
"""
)
handle.flush()
)

result = run_cli_command(cmd, ['--config', handle.name])
assert 'Integer: 1' in result.output_lines[0]
assert 'Boolean: False' in result.output_lines[1]
result = run_cli_command(cmd, ['--config', str(filepath)])
assert 'Integer: 1' in result.output_lines[0]
assert 'Boolean: False' in result.output_lines[1]


def test_invalid_unknown_keys(run_cli_command):
"""Test the option for an invalid configuration file containing unknown keys."""
with tempfile.NamedTemporaryFile('w+') as handle:
handle.write(
textwrap.dedent(
"""
@pytest.mark.filterwarnings('ignore')
def test_invalid_unknown_keys(run_cli_command, tmp_path):
"""Test the option for an invalid configuration file containing unknown keys.

The test emits a ``ResourceWarning`` because the config file is not closed since the command errors, but this is
just a side-effect of how the test is run and doesn't apply to the real CLI command invocation.
"""
filepath = tmp_path / 'config.yml'
filepath.write_text(
textwrap.dedent(
"""
integer: 1
unknown: 2.0
"""
)
"""
)
handle.flush()
)

result = run_cli_command(cmd, ['--config', handle.name], raises=True)
assert "Error: Invalid value for '--config': Invalid configuration file" in result.stderr
assert "the following keys are not supported: {'unknown'}" in result.stderr
result = run_cli_command(cmd, ['--config', str(filepath)], raises=True)
assert "Error: Invalid value for '--config': Invalid configuration file" in result.stderr
assert "the following keys are not supported: {'unknown'}" in result.stderr
1 change: 0 additions & 1 deletion tests/cmdline/params/options/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ def test_default_value_prompt(run_cli_command):
returns.append(result)
expected = 'Opt [default]: TEST\nTEST\n'
assert expected in result.output
return returns


def test_default_value_empty_opt(run_cli_command):
Expand Down
2 changes: 1 addition & 1 deletion tests/engine/processes/calcjobs/test_calc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def test_get_hash(self, get_calcjob_builder):
"""Test that :meth:`aiida.orm.CalcJobNode.get_hash` returns the same hash as what is stored in the extras."""
builder = get_calcjob_builder()
_, node = launch.run_get_node(builder)
assert node.base.extras.get(node.base.caching._HASH_EXTRA_KEY) == node.get_hash()
assert node.base.extras.get(node.base.caching._HASH_EXTRA_KEY) == node.base.caching.get_hash()

def test_process_status(self):
"""Test that the process status is properly reset if calculation ends successfully."""
Expand Down
6 changes: 5 additions & 1 deletion tests/engine/processes/workchains/test_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# For further information please visit http://www.aiida.net #
###########################################################################
"""Tests for `aiida.engine.processes.workchains.restart` module."""
import warnings

import pytest
from aiida import engine, orm
from aiida.engine.processes.workchains.awaitable import Awaitable
Expand Down Expand Up @@ -66,7 +68,9 @@ def test_get_process_handlers():
)
def test_get_process_handlers_by_priority(generate_work_chain, inputs, priorities):
"""Test the `BaseRestartWorkChain.get_process_handlers_by_priority` method."""
process = generate_work_chain(SomeWorkChain, inputs)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
process = generate_work_chain(SomeWorkChain, inputs)
process.setup()
assert sorted([priority for priority, handler in process.get_process_handlers_by_priority()]) == priorities

Expand Down
2 changes: 1 addition & 1 deletion tests/engine/test_calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_calcfunction_caching_change_code(self):
result_cached, cached = add_calcfunction.run_get_node(self.default_int)
assert result_original != result_cached
assert not cached.base.caching.is_created_from_cache
assert cached.is_valid_cache
assert cached.base.caching.is_valid_cache

# Test that the locally-created calcfunction can be cached in principle
result2_cached, cached2 = add_calcfunction.run_get_node(self.default_int)
Expand Down
2 changes: 1 addition & 1 deletion tests/engine/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def define(cls, spec):
spec.input('any_type', required=False)


@pytest.mark.usefixtures('clear_database_before_test')
@pytest.mark.usefixtures('aiida_profile_clean')
def test_not_required_accepts_none():
"""Test that a port that is not required, accepts ``None``."""
from aiida.engine.utils import instantiate_process
Expand Down
Loading
Loading