diff --git a/.github/system_tests/pytest/test_unittest_example.py b/.github/system_tests/pytest/test_unittest_example.py deleted file mode 100644 index 412a6199c7..0000000000 --- a/.github/system_tests/pytest/test_unittest_example.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Test running unittest test cases through pytest.""" -import unittest -import pytest - - -class TestInt(unittest.TestCase): - """Test integers - Compatible with pytest.""" - - @pytest.fixture(autouse=True) - def setup_temp_dir(self, temp_dir): - self.temp_dir = temp_dir # pylint: disable=attribute-defined-outside-init - - def test_int(self): # pylint: disable=no-self-use - """Just testing that the database environment is available and working.""" - from aiida import orm - i = orm.Int(5) - i.store() - - def test_temp_dir(self): - """Test that temp dir was set.""" - assert self.temp_dir is not None diff --git a/.github/system_tests/test_plugin_testcase.py b/.github/system_tests/test_plugin_testcase.py deleted file mode 100644 index 0a8df61324..0000000000 --- a/.github/system_tests/test_plugin_testcase.py +++ /dev/null @@ -1,117 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -""" -Test the plugin test case - -This must be in a standalone script because it would clash with other tests, -Since the dbenv gets loaded on the temporary profile. -""" - -import sys -import unittest -import tempfile -import shutil - -from aiida.manage.tests.unittest_classes import PluginTestCase, TestRunner - - -class PluginTestCase1(PluginTestCase): - """ - Test the PluginTestCase from utils.fixtures - """ - - def setUp(self): - self.temp_dir = tempfile.mkdtemp() - self.data = self.get_data() - self.data_pk = self.data.pk - self.computer = self.get_computer(temp_dir=self.temp_dir) - - def tearDown(self): - super().tearDown() - shutil.rmtree(self.temp_dir) - - @staticmethod - def get_data(): - """ - Return some Dict - """ - from aiida.plugins import DataFactory - data = DataFactory('dict')(dict={'data': 'test'}) - data.store() - return data - - @classmethod - def get_computer(cls, temp_dir): - """ - Create and store a new computer, and return it - """ - from aiida import orm - - computer = orm.Computer( - label='localhost', - hostname='localhost', - description='my computer', - transport_type='local', - scheduler_type='direct', - workdir=temp_dir, - backend=cls.backend - ).store() - return computer - - def test_data_loaded(self): - """ - Check that the data node is indeed in the DB when calling load_node - """ - from aiida import orm - self.assertEqual(orm.load_node(self.data_pk).uuid, self.data.uuid) - - def test_computer_loaded(self): - """ - Check that the computer is indeed in the DB when calling load_node - - Note: Important to have at least two test functions in order to verify things - work after resetting the DB. - """ - from aiida import orm - self.assertEqual(orm.Computer.objects.get(label='localhost').uuid, self.computer.uuid) - - def test_tear_down(self): - """ - Check that after tearing down, the previously stored nodes - are not there anymore. - """ - from aiida.orm import load_node - super().tearDown() # reset DB - with self.assertRaises(Exception): - load_node(self.data_pk) - - -class PluginTestCase2(PluginTestCase): - """ - Second PluginTestCase. - """ - - def test_dummy(self): - """ - Dummy test for 2nd PluginTestCase class. - - Just making sure that setup/teardown is safe for - multiple testcase classes (this was broken in #1425). - """ - super().tearDown() - - -if __name__ == '__main__': - MODULE = sys.modules[__name__] - SUITE = unittest.defaultTestLoader.loadTestsFromModule(MODULE) - RESULT = TestRunner().run(SUITE) - - EXIT_CODE = int(not RESULT.wasSuccessful()) - sys.exit(EXIT_CODE) diff --git a/.github/workflows/tests.sh b/.github/workflows/tests.sh index db69cfa29c..4fbe18352c 100755 --- a/.github/workflows/tests.sh +++ b/.github/workflows/tests.sh @@ -29,7 +29,6 @@ verdi daemon stop pytest --noconftest ${SYSTEM_TESTS}/test_test_manager.py pytest --noconftest ${SYSTEM_TESTS}/test_ipython_magics.py pytest --noconftest ${SYSTEM_TESTS}/test_profile_manager.py -python ${SYSTEM_TESTS}/test_plugin_testcase.py # uses custom unittest test runner # Until the `${SYSTEM_TESTS}/pytest` tests are moved within `tests` we have to run them separately and pass in the path to the # `conftest.py` explicitly, because otherwise it won't be able to find the fixtures it provides diff --git a/aiida/__init__.py b/aiida/__init__.py index fa8655f8ff..d6d0f83bd4 100644 --- a/aiida/__init__.py +++ b/aiida/__init__.py @@ -20,10 +20,7 @@ More information at http://www.aiida.net """ -import warnings - from aiida.common.log import configure_logging -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.configuration import get_config_option, get_profile, load_profile __copyright__ = ( @@ -40,57 +37,6 @@ __paper_short__ = 'S. P. Huber et al., Scientific Data 7, 300 (2020).' -def load_dbenv(profile=None): - """Alias for `load_dbenv` from `aiida.backends.utils` - - :param profile: name of the profile to load - :type profile: str - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use :func:`aiida.manage.configuration.load_profile` instead. - """ - warnings.warn('function is deprecated, use `load_profile` instead', AiidaDeprecationWarning) # pylint: disable=no-member - current_profile = get_profile() - from aiida.common import InvalidOperation - - if current_profile: - raise InvalidOperation('You cannot call load_dbenv multiple times!') - - load_profile(profile) - - -def try_load_dbenv(profile=None): - """Run `load_dbenv` unless the dbenv has already been loaded. - - :param profile: name of the profile to load - :type profile: str - - :returns: whether profile was loaded - :rtype: bool - - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use :func:`aiida.manage.configuration.load_profile` instead. - """ - warnings.warn('function is deprecated, use `load_profile` instead', AiidaDeprecationWarning) # pylint: disable=no-member - if not is_dbenv_loaded(): - load_dbenv(profile) - return True - return False - - -def is_dbenv_loaded(): - """Determine whether database environment is already loaded. - - :rtype: bool - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use :func:`aiida.manage.configuration.load_profile` instead. - """ - warnings.warn('function is deprecated, use `load_profile` instead', AiidaDeprecationWarning) # pylint: disable=no-member - return get_profile() is not None - - def get_strict_version(): """ Return a distutils StrictVersion instance with the current distribution version diff --git a/aiida/calculations/plugins/__init__.py b/aiida/calculations/plugins/__init__.py deleted file mode 100644 index 2776a55f97..0000000000 --- a/aiida/calculations/plugins/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### diff --git a/aiida/calculations/plugins/arithmetic/__init__.py b/aiida/calculations/plugins/arithmetic/__init__.py deleted file mode 100644 index 2776a55f97..0000000000 --- a/aiida/calculations/plugins/arithmetic/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### diff --git a/aiida/calculations/plugins/arithmetic/add.py b/aiida/calculations/plugins/arithmetic/add.py deleted file mode 100644 index 1117ad5e72..0000000000 --- a/aiida/calculations/plugins/arithmetic/add.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""`CalcJob` implementation to add two numbers using bash for testing and demonstration purposes.""" -import warnings - -from aiida.common.warnings import AiidaDeprecationWarning -from aiida.calculations.arithmetic.add import ArithmeticAddCalculation # pylint: disable=unused-import - -warnings.warn( # pylint: disable=no-member - 'The add module has moved to aiida.calculations.arithmetic.add. ' - 'This path will be removed in`v2.0.0`.', AiidaDeprecationWarning -) diff --git a/aiida/calculations/plugins/templatereplacer.py b/aiida/calculations/plugins/templatereplacer.py deleted file mode 100644 index 8f939d10bc..0000000000 --- a/aiida/calculations/plugins/templatereplacer.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Generic `CalcJob` implementation where input file is a parametrized template file.""" -import warnings - -from aiida.common.warnings import AiidaDeprecationWarning -from aiida.calculations.templatereplacer import TemplatereplacerCalculation # pylint: disable=unused-import - -warnings.warn( # pylint: disable=no-member - 'The templatereplacer module has moved to aiida.calculations.templatereplacer. ' - 'This path will be removed in a future release.', AiidaDeprecationWarning -) diff --git a/aiida/cmdline/commands/__init__.py b/aiida/cmdline/commands/__init__.py index c80c47b6e8..f70ae9b046 100644 --- a/aiida/cmdline/commands/__init__.py +++ b/aiida/cmdline/commands/__init__.py @@ -17,6 +17,6 @@ # Import to populate the `verdi` sub commands from aiida.cmdline.commands import ( cmd_archive, cmd_calcjob, cmd_code, cmd_comment, cmd_completioncommand, cmd_computer, cmd_config, cmd_data, - cmd_database, cmd_daemon, cmd_devel, cmd_export, cmd_graph, cmd_group, cmd_help, cmd_import, cmd_node, cmd_plugin, - cmd_process, cmd_profile, cmd_rehash, cmd_restapi, cmd_run, cmd_setup, cmd_shell, cmd_status, cmd_user + cmd_database, cmd_daemon, cmd_devel, cmd_group, cmd_help, cmd_node, cmd_plugin, cmd_process, cmd_profile, + cmd_rehash, cmd_restapi, cmd_run, cmd_setup, cmd_shell, cmd_status, cmd_user ) diff --git a/aiida/cmdline/commands/cmd_archive.py b/aiida/cmdline/commands/cmd_archive.py index 43878ca126..748cac63c5 100644 --- a/aiida/cmdline/commands/cmd_archive.py +++ b/aiida/cmdline/commands/cmd_archive.py @@ -36,17 +36,12 @@ def verdi_archive(): @verdi_archive.command('inspect') @click.argument('archive', nargs=1, type=click.Path(exists=True, readable=True)) @click.option('-v', '--version', is_flag=True, help='Print the archive format version and exit.') -@click.option('-d', '--data', hidden=True, is_flag=True, help='Print the data contents and exit.') @click.option('-m', '--meta-data', is_flag=True, help='Print the meta data contents and exit.') -def inspect(archive, version, data, meta_data): +def inspect(archive, version, meta_data): """Inspect contents of an archive without importing it. By default a summary of the archive contents will be printed. The various options can be used to change exactly what information is displayed. - - .. deprecated:: 1.5.0 - Support for the --data flag - """ import dataclasses from aiida.tools.importexport import CorruptArchive, detect_archive_type, get_reader @@ -57,10 +52,6 @@ def inspect(archive, version, data, meta_data): try: if version: echo.echo(reader.export_version) - elif data: - # data is an internal implementation detail - echo.echo_deprecated('--data is deprecated and will be removed in v2.0.0') - echo.echo_dictionary(reader._get_data()) # pylint: disable=protected-access elif meta_data: echo.echo_dictionary(dataclasses.asdict(reader.metadata)) else: @@ -200,7 +191,6 @@ def create( @options.ARCHIVE_FORMAT() @options.FORCE(help='overwrite output file if it already exists') @click.option('-i', '--in-place', is_flag=True, help='Migrate the archive in place, overwriting the original file.') -@options.SILENT(hidden=True) @click.option( '-v', '--version', @@ -218,21 +208,13 @@ def create( type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'CRITICAL']), help='Control the verbosity of console logging' ) -def migrate(input_file, output_file, force, silent, in_place, archive_format, version, verbosity): - """Migrate an export archive to a more recent format version. - - .. deprecated:: 1.5.0 - Support for the --silent flag, replaced by --verbosity - - """ +def migrate(input_file, output_file, force, in_place, archive_format, version, verbosity): + """Migrate an export archive to a more recent format version.""" from aiida.common.log import override_log_formatter_context from aiida.common.progress_reporter import set_progress_bar_tqdm, set_progress_reporter from aiida.tools.importexport import detect_archive_type, EXPORT_VERSION from aiida.tools.importexport.archive.migrators import get_migrator, MIGRATE_LOGGER - if silent is True: - echo.echo_deprecated('the --silent option is deprecated, use --verbosity') - if in_place: if output_file: echo.echo_critical('output file specified together with --in-place flag') diff --git a/aiida/cmdline/commands/cmd_devel.py b/aiida/cmdline/commands/cmd_devel.py index e58dfff18c..387a942e53 100644 --- a/aiida/cmdline/commands/cmd_devel.py +++ b/aiida/cmdline/commands/cmd_devel.py @@ -8,13 +8,9 @@ # For further information please visit http://www.aiida.net # ########################################################################### """`verdi devel` commands.""" - import sys -import click from aiida.cmdline.commands.cmd_verdi import verdi -from aiida.cmdline.params import options -from aiida.cmdline.params.types import TestModuleParamType from aiida.cmdline.utils import decorators, echo @@ -89,19 +85,6 @@ def devel_validate_plugins(): echo.echo_success('all registered plugins could successfully loaded.') -@verdi_devel.command('tests') -@click.argument('paths', nargs=-1, type=TestModuleParamType(), required=False) -@options.VERBOSE(help='Print the class and function name for each test.') -@decorators.deprecated_command("This command has been removed in aiida-core v1.1.0. Please run 'pytest' instead.") -@decorators.with_dbenv() -def devel_tests(paths, verbose): # pylint: disable=unused-argument - """Run the unittest suite or parts of it. - - .. deprecated:: 1.1.0 - Entry point will be completely removed in `v2.0.0`. - """ - - @verdi_devel.command('play', hidden=True) def devel_play(): """Play the Aida triumphal march by Giuseppe Verdi.""" diff --git a/aiida/cmdline/commands/cmd_export.py b/aiida/cmdline/commands/cmd_export.py deleted file mode 100644 index 0e959de06c..0000000000 --- a/aiida/cmdline/commands/cmd_export.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -# pylint: disable=too-many-arguments,import-error,too-many-locals,unused-argument -"""`verdi export` command.""" -import click - -from aiida.cmdline.commands.cmd_verdi import verdi -from aiida.cmdline.params import arguments, options -from aiida.cmdline.utils import decorators -from aiida.common.links import GraphTraversalRules - -from aiida.cmdline.commands import cmd_archive - - -@verdi.group('export', hidden=True) -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi archive' instead.") -def verdi_export(): - """Deprecated, use `verdi archive`.""" - - -@verdi_export.command('inspect') -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi archive inspect' instead.") -@click.argument('archive', nargs=1, type=click.Path(exists=True, readable=True)) -@click.option('-v', '--version', is_flag=True, help='Print the archive format version and exit.') -@click.option('-d', '--data', hidden=True, is_flag=True, help='Print the data contents and exit.') -@click.option('-m', '--meta-data', is_flag=True, help='Print the meta data contents and exit.') -@click.pass_context -def inspect(ctx, archive, version, data, meta_data): - """Inspect contents of an exported archive without importing it. - - By default a summary of the archive contents will be printed. The various options can be used to change exactly what - information is displayed. - - .. deprecated:: 1.5.0 - Support for the --data flag - - """ - ctx.forward(cmd_archive.inspect) - - -@verdi_export.command('create') -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi archive create' instead.") -@arguments.OUTPUT_FILE(type=click.Path(exists=False)) -@options.CODES() -@options.COMPUTERS() -@options.GROUPS() -@options.NODES() -@options.ARCHIVE_FORMAT( - type=click.Choice(['zip', 'zip-uncompressed', 'zip-lowmemory', 'tar.gz', 'null']), -) -@options.FORCE(help='overwrite output file if it already exists') -@click.option( - '-v', - '--verbosity', - default='INFO', - type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'CRITICAL']), - help='Control the verbosity of console logging' -) -@options.graph_traversal_rules(GraphTraversalRules.EXPORT.value) -@click.option( - '--include-logs/--exclude-logs', - default=True, - show_default=True, - help='Include or exclude logs for node(s) in export.' -) -@click.option( - '--include-comments/--exclude-comments', - default=True, - show_default=True, - help='Include or exclude comments for node(s) in export. (Will also export extra users who commented).' -) -@click.pass_context -@decorators.with_dbenv() -def create( - ctx, output_file, codes, computers, groups, nodes, archive_format, force, input_calc_forward, input_work_forward, - create_backward, return_backward, call_calc_backward, call_work_backward, include_comments, include_logs, verbosity -): - """ - Export subsets of the provenance graph to file for sharing. - - Besides Nodes of the provenance graph, you can export Groups, Codes, Computers, Comments and Logs. - - By default, the archive file will include not only the entities explicitly provided via the command line but also - their provenance, according to the rules outlined in the documentation. - You can modify some of those rules using options of this command. - """ - ctx.forward(cmd_archive.create) - - -@verdi_export.command('migrate') -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi archive migrate' instead.") -@arguments.INPUT_FILE() -@arguments.OUTPUT_FILE(required=False) -@options.ARCHIVE_FORMAT() -@options.FORCE(help='overwrite output file if it already exists') -@click.option('-i', '--in-place', is_flag=True, help='Migrate the archive in place, overwriting the original file.') -@options.SILENT(hidden=True) -@click.option( - '-v', - '--version', - type=click.STRING, - required=False, - metavar='VERSION', - # Note: Adding aiida.tools.EXPORT_VERSION as a default value explicitly would result in a slow import of - # aiida.tools and, as a consequence, aiida.orm. As long as this is the case, better determine the latest export - # version inside the function when needed. - help='Archive format version to migrate to (defaults to latest version).', -) -@click.option( - '--verbosity', - default='INFO', - type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'CRITICAL']), - help='Control the verbosity of console logging' -) -@click.pass_context -def migrate(ctx, input_file, output_file, force, silent, in_place, archive_format, version, verbosity): - """Migrate an export archive to a more recent format version. - - .. deprecated:: 1.5.0 - Support for the --silent flag, replaced by --verbosity - - """ - ctx.forward(cmd_archive.migrate) diff --git a/aiida/cmdline/commands/cmd_graph.py b/aiida/cmdline/commands/cmd_graph.py deleted file mode 100644 index 9811adf16c..0000000000 --- a/aiida/cmdline/commands/cmd_graph.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""`verdi graph` commands""" - -import click - -from aiida.cmdline.commands.cmd_verdi import verdi -from aiida.cmdline.params import arguments, options -from aiida.cmdline.utils import decorators - - -@verdi.group('graph') -@decorators.deprecated_command("This command group has been deprecated. Please use 'verdi node graph' instead.") -def verdi_graph(): - """Create visual representations of the provenance graph.""" - - -@verdi_graph.command('generate') -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi node graph generate' instead.") -@arguments.NODE('root_node') -@click.option( - '-l', - '--link-types', - help=( - 'The link types to include: ' - "'data' includes only 'input_calc' and 'create' links (data provenance only), " - "'logic' includes only 'input_work' and 'return' links (logical provenance only)." - ), - default='all', - type=click.Choice(['all', 'data', 'logic']) -) -@click.option( - '--identifier', - help='the type of identifier to use within the node text', - default='uuid', - type=click.Choice(['pk', 'uuid', 'label']) -) -@click.option( - '-a', - '--ancestor-depth', - help='The maximum depth when recursing upwards, if not set it will recurse to the end.', - type=click.IntRange(min=0) -) -@click.option( - '-d', - '--descendant-depth', - help='The maximum depth when recursing through the descendants. If not set it will recurse to the end.', - type=click.IntRange(min=0) -) -@click.option('-o', '--process-out', is_flag=True, help='Show outgoing links for all processes.') -@click.option('-i', '--process-in', is_flag=True, help='Show incoming links for all processes.') -@options.VERBOSE(help='Print verbose information of the graph traversal.') -@click.option( - '-e', - '--engine', - help="The graphviz engine, e.g. 'dot', 'circo', ... " - '(see http://www.graphviz.org/doc/info/output.html)', - default='dot' -) -@click.option('-f', '--output-format', help="The output format used for rendering ('pdf', 'png', etc.).", default='pdf') -@click.option('-s', '--show', is_flag=True, help='Open the rendered result with the default application.') -@click.pass_context -@decorators.with_dbenv() -def generate( # pylint: disable=too-many-arguments, unused-argument - ctx, root_node, link_types, identifier, ancestor_depth, descendant_depth, process_out, process_in, engine, verbose, - output_format, show -): - """ - Generate a graph from a ROOT_NODE (specified by pk or uuid). - """ - from aiida.cmdline.commands.cmd_node import graph_generate as node_generate - - ctx.forward(node_generate) diff --git a/aiida/cmdline/commands/cmd_group.py b/aiida/cmdline/commands/cmd_group.py index 20b8303f0e..f11b50dafc 100644 --- a/aiida/cmdline/commands/cmd_group.py +++ b/aiida/cmdline/commands/cmd_group.py @@ -8,12 +8,10 @@ # For further information please visit http://www.aiida.net # ########################################################################### """`verdi group` commands""" -import warnings import logging import click from aiida.common.exceptions import UniquenessError -from aiida.common.warnings import AiidaDeprecationWarning from aiida.cmdline.commands.cmd_verdi import verdi from aiida.cmdline.params import options, arguments from aiida.cmdline.utils import echo @@ -99,20 +97,13 @@ def group_remove_nodes(group, nodes, clear, force): @options.graph_traversal_rules(GraphTraversalRules.DELETE.value) @options.DRY_RUN() @options.VERBOSE() -@options.GROUP_CLEAR( - help='Remove all nodes before deleting the group itself.' + - ' [deprecated: No longer has any effect. Will be removed in 2.0.0]' -) @with_dbenv() -def group_delete(group, clear, delete_nodes, dry_run, force, verbose, **traversal_rules): +def group_delete(group, delete_nodes, dry_run, force, verbose, **traversal_rules): """Delete a group and (optionally) the nodes it contains.""" from aiida.common.log import override_log_formatter_context from aiida.tools import delete_group_nodes, DELETE_LOGGER from aiida import orm - if clear: - warnings.warn('`--clear` is deprecated and no longer has any effect.', AiidaDeprecationWarning) # pylint: disable=no-member - label = group.label klass = group.__class__.__name__ @@ -234,14 +225,6 @@ def group_show(group, raw, limit, uuid): @options.ALL_USERS(help='Show groups for all users, rather than only for the current user.') @options.USER(help='Add a filter to show only groups belonging to a specific user') @options.ALL(help='Show groups of all types.') -@click.option( - '-t', - '--type', - 'group_type', - default=None, - help='Show groups of a specific type, instead of user-defined groups. Start with semicolumn if you want to ' - 'specify aiida-internal type. [deprecated: use `--type-string` instead. Will be removed in 2.0.0]' -) @options.TYPE_STRING() @click.option( '-d', @@ -279,8 +262,8 @@ def group_show(group, raw, limit, uuid): @options.NODE(help='Show only the groups that contain the node.') @with_dbenv() def group_list( - all_users, user, all_entries, group_type, type_string, with_description, count, past_days, startswith, endswith, - contains, order_by, order_dir, node + all_users, user, all_entries, type_string, with_description, count, past_days, startswith, endswith, contains, + order_by, order_dir, node ): """Show a list of existing groups.""" # pylint: disable=too-many-branches,too-many-arguments,too-many-locals,too-many-statements @@ -293,14 +276,6 @@ def group_list( builder = orm.QueryBuilder() filters = {} - if group_type is not None: - warnings.warn('`--group-type` is deprecated, use `--type-string` instead', AiidaDeprecationWarning) # pylint: disable=no-member - - if type_string is not None: - raise click.BadOptionUsage('group-type', 'cannot use `--group-type` and `--type-string` at the same time.') - else: - type_string = group_type - # Have to specify the default for `type_string` here instead of directly in the option otherwise it will always # raise above if the user specifies just the `--group-type` option. Once that option is removed, the default can # be moved to the option itself. diff --git a/aiida/cmdline/commands/cmd_import.py b/aiida/cmdline/commands/cmd_import.py deleted file mode 100644 index 1dad604063..0000000000 --- a/aiida/cmdline/commands/cmd_import.py +++ /dev/null @@ -1,89 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""`verdi import` command.""" -# pylint: disable=broad-except,unused-argument -import click - -from aiida.cmdline.commands.cmd_verdi import verdi -from aiida.cmdline.params import options -from aiida.cmdline.params.types import GroupParamType, PathOrUrl -from aiida.cmdline.utils import decorators - -from aiida.cmdline.commands.cmd_archive import import_archive, EXTRAS_MODE_EXISTING, EXTRAS_MODE_NEW, COMMENT_MODE - - -@verdi.command('import', hidden=True) -@decorators.deprecated_command("This command has been deprecated. Please use 'verdi archive import' instead.") -@click.argument('archives', nargs=-1, type=PathOrUrl(exists=True, readable=True)) -@click.option( - '-w', - '--webpages', - type=click.STRING, - cls=options.MultipleValueOption, - help='Discover all URL targets pointing to files with the .aiida extension for these HTTP addresses. ' - 'Automatically discovered archive URLs will be downloaded and added to ARCHIVES for importing' -) -@options.GROUP( - type=GroupParamType(create_if_not_exist=True), - help='Specify group to which all the import nodes will be added. If such a group does not exist, it will be' - ' created automatically.' -) -@click.option( - '-e', - '--extras-mode-existing', - type=click.Choice(EXTRAS_MODE_EXISTING), - default='keep_existing', - help='Specify which extras from the export archive should be imported for nodes that are already contained in the ' - 'database: ' - 'ask: import all extras and prompt what to do for existing extras. ' - 'keep_existing: import all extras and keep original value of existing extras. ' - 'update_existing: import all extras and overwrite value of existing extras. ' - 'mirror: import all extras and remove any existing extras that are not present in the archive. ' - 'none: do not import any extras.' -) -@click.option( - '-n', - '--extras-mode-new', - type=click.Choice(EXTRAS_MODE_NEW), - default='import', - help='Specify whether to import extras of new nodes: ' - 'import: import extras. ' - 'none: do not import extras.' -) -@click.option( - '--comment-mode', - type=click.Choice(COMMENT_MODE), - default='newest', - help='Specify the way to import Comments with identical UUIDs: ' - 'newest: Only the newest Comments (based on mtime) (default).' - 'overwrite: Replace existing Comments with those from the import file.' -) -@click.option( - '--migration/--no-migration', - default=True, - show_default=True, - help='Force migration of archive file archives, if needed.' -) -@click.option( - '-v', - '--verbosity', - default='INFO', - type=click.Choice(['DEBUG', 'INFO', 'WARNING', 'CRITICAL']), - help='Control the verbosity of console logging' -) -@options.NON_INTERACTIVE() -@decorators.with_dbenv() -@click.pass_context -def cmd_import( - ctx, archives, webpages, group, extras_mode_existing, extras_mode_new, comment_mode, migration, non_interactive, - verbosity -): - """Deprecated, use `verdi archive import`.""" - ctx.forward(import_archive) diff --git a/aiida/cmdline/commands/cmd_node.py b/aiida/cmdline/commands/cmd_node.py index b7ac1e14d2..9286a0e765 100644 --- a/aiida/cmdline/commands/cmd_node.py +++ b/aiida/cmdline/commands/cmd_node.py @@ -8,7 +8,6 @@ # For further information please visit http://www.aiida.net # ########################################################################### """`verdi node` command.""" - import logging import shutil import pathlib @@ -279,23 +278,6 @@ def extras(nodes, keys, fmt, identifier, raw): echo_node_dict(nodes, keys, fmt, identifier, raw, use_attrs=False) -@verdi_node.command() -@arguments.NODES() -@click.option('-d', '--depth', 'depth', default=1, help='Show children of nodes up to given depth') -@with_dbenv() -@decorators.deprecated_command('This command will be removed in `aiida-core==2.0.0`.') -def tree(nodes, depth): - """Show a tree of nodes starting from a given node.""" - from aiida.common import LinkType - from aiida.cmdline.utils.ascii_vis import NodeTreePrinter - - for node in nodes: - NodeTreePrinter.print_node_tree(node, depth, tuple(LinkType.__members__.values())) - - if len(nodes) > 1: - echo.echo('') - - @verdi_node.command('delete') @click.argument('identifier', nargs=-1, metavar='NODES') @options.VERBOSE() @@ -432,7 +414,6 @@ def verdi_graph(): ) @click.option('-o', '--process-out', is_flag=True, help='Show outgoing links for all processes.') @click.option('-i', '--process-in', is_flag=True, help='Show incoming links for all processes.') -@options.VERBOSE(help='Print verbose information of the graph traversal.') @click.option( '-e', '--engine', @@ -453,15 +434,14 @@ def verdi_graph(): @click.option('-s', '--show', is_flag=True, help='Open the rendered result with the default application.') @decorators.with_dbenv() def graph_generate( - root_node, link_types, identifier, ancestor_depth, descendant_depth, process_out, process_in, engine, verbose, - output_format, highlight_classes, show + root_node, link_types, identifier, ancestor_depth, descendant_depth, process_out, process_in, engine, output_format, + highlight_classes, show ): """ Generate a graph from a ROOT_NODE (specified by pk or uuid). """ # pylint: disable=too-many-arguments from aiida.tools.visualization import Graph - print_func = echo.echo_info if verbose else None link_types = {'all': (), 'logic': ('input_work', 'return'), 'data': ('input_calc', 'create')}[link_types] echo.echo_info(f'Initiating graphviz engine: {engine}') @@ -475,7 +455,6 @@ def graph_generate( annotate_links='both', include_process_outputs=process_out, highlight_classes=highlight_classes, - print_func=print_func ) echo.echo_info(f'Recursing descendants, max depth={descendant_depth}') graph.recurse_descendants( @@ -485,7 +464,6 @@ def graph_generate( annotate_links='both', include_process_inputs=process_in, highlight_classes=highlight_classes, - print_func=print_func ) output_file_name = graph.graphviz.render( filename=f'{root_node.pk}.{engine}', format=output_format, view=show, cleanup=True diff --git a/aiida/cmdline/commands/cmd_run.py b/aiida/cmdline/commands/cmd_run.py index 727bfe1286..766ff51417 100644 --- a/aiida/cmdline/commands/cmd_run.py +++ b/aiida/cmdline/commands/cmd_run.py @@ -12,14 +12,12 @@ import os import functools import sys -import warnings import click from aiida.cmdline.commands.cmd_verdi import verdi from aiida.cmdline.params.options.multivalue import MultipleValueOption from aiida.cmdline.utils import decorators, echo -from aiida.common.warnings import AiidaDeprecationWarning @contextlib.contextmanager @@ -64,14 +62,6 @@ def validate_entrypoint_string(ctx, param, value): # pylint: disable=unused-arg help='Specify the prefix of the label of the auto group (numbers might be automatically ' 'appended to generate unique names per run).' ) -@click.option( - '-n', - '--group-name', - type=click.STRING, - required=False, - help='Specify the name of the auto group [DEPRECATED, USE --auto-group-label-prefix instead]. ' - 'This also enables auto-grouping.' -) @click.option( '-e', '--exclude', @@ -89,7 +79,7 @@ def validate_entrypoint_string(ctx, param, value): # pylint: disable=unused-arg callback=validate_entrypoint_string ) @decorators.with_dbenv() -def run(scriptname, varargs, auto_group, auto_group_label_prefix, group_name, exclude, include): +def run(scriptname, varargs, auto_group, auto_group_label_prefix, exclude, include): # pylint: disable=too-many-arguments,exec-used """Execute scripts with preloaded AiiDA environment.""" from aiida.cmdline.utils.shell import DEFAULT_MODULES_LIST @@ -108,17 +98,6 @@ def run(scriptname, varargs, auto_group, auto_group_label_prefix, group_name, ex for app_mod, model_name, alias in DEFAULT_MODULES_LIST: globals_dict[f'{alias}'] = getattr(__import__(app_mod, {}, {}, model_name), model_name) - if group_name: - warnings.warn('--group-name is deprecated, use `--auto-group-label-prefix` instead', AiidaDeprecationWarning) # pylint: disable=no-member - if auto_group_label_prefix: - raise click.BadParameter( - 'You cannot specify both --group-name and --auto-group-label-prefix; ' - 'use --auto-group-label-prefix only' - ) - auto_group_label_prefix = group_name - # To have the old behavior, with auto-group enabled. - auto_group = True - if auto_group: aiida_verdilib_autogroup = autogroup.Autogroup() # Set the ``group_label_prefix`` if defined, otherwise a default prefix will be used diff --git a/aiida/cmdline/utils/ascii_vis.py b/aiida/cmdline/utils/ascii_vis.py index f7fa03d78e..b706fbdf6d 100644 --- a/aiida/cmdline/utils/ascii_vis.py +++ b/aiida/cmdline/utils/ascii_vis.py @@ -8,255 +8,13 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Utility functions to draw ASCII diagrams to the command line.""" -from aiida.common.links import LinkType - -__all__ = ('draw_children', 'draw_parents', 'format_call_graph') +__all__ = ('format_call_graph',) TREE_LAST_ENTRY = '\u2514\u2500\u2500 ' TREE_MIDDLE_ENTRY = '\u251C\u2500\u2500 ' TREE_FIRST_ENTRY = TREE_MIDDLE_ENTRY -class NodeTreePrinter: - """Utility functions for printing node trees. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - """ - - # Note: when removing this code, also remove the `ete3` as a dependency as it will no longer be used. - - @classmethod - def print_node_tree(cls, node, max_depth, follow_links=()): - """Top-level function for printing node tree.""" - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('class is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - from ete3 import Tree - from aiida.cmdline.utils.common import get_node_summary - from aiida.cmdline.utils import echo - - echo.echo(get_node_summary(node)) - - tree_string = f'({cls._build_tree(node, max_depth=max_depth, follow_links=follow_links)});' - tmp = Tree(tree_string, format=1) - echo.echo(tmp.get_ascii(show_internal=True)) - - @staticmethod - def _ctime(link_triple): - return link_triple.node.ctime - - @classmethod - def _build_tree(cls, node, show_pk=True, max_depth=None, follow_links=(), depth=0): - """Return string with tree.""" - if max_depth is not None and depth > max_depth: - return None - - children = [] - for entry in sorted(node.get_outgoing(link_type=follow_links).all(), key=cls._ctime): - child_str = cls._build_tree( - entry.node, show_pk, follow_links=follow_links, max_depth=max_depth, depth=depth + 1 - ) - if child_str: - children.append(child_str) - - out_values = [] - if children: - out_values.append('(') - out_values.append(', '.join(children)) - out_values.append(')') - - lab = node.__class__.__name__ - - if show_pk: - lab += f' [{node.pk}]' - - out_values.append(lab) - - return ''.join(out_values) - - -def draw_parents(node, node_label=None, show_pk=True, dist=2, follow_links_of_type=None): - """ - Print an ASCII tree of the parents of the given node. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - - :param node: The node to draw for - :type node: :class:`aiida.orm.nodes.data.Data` - :param node_label: The label to use for the nodes - :type node_label: str - :param show_pk: Show the PK of nodes alongside the label - :type show_pk: bool - :param dist: The number of steps away from this node to branch out - :type dist: int - :param follow_links_of_type: Follow links of this type when making steps, - if None then it will follow CREATE and INPUT links - :type follow_links_of_type: str - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - return get_ascii_tree(node, node_label, show_pk, dist, follow_links_of_type, False) - - -def draw_children(node, node_label=None, show_pk=True, dist=2, follow_links_of_type=None): - """ - Print an ASCII tree of the parents of the given node. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - - :param node: The node to draw for - :type node: :class:`aiida.orm.nodes.data.Data` - :param node_label: The label to use for the nodes - :type node_label: str - :param show_pk: Show the PK of nodes alongside the label - :type show_pk: bool - :param dist: The number of steps away from this node to branch out - :type dist: int - :param follow_links_of_type: Follow links of this type when making steps, - if None then it will follow CREATE and INPUT links - :type follow_links_of_type: str - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - return get_ascii_tree(node, node_label, show_pk, dist, follow_links_of_type, True) - - -def get_ascii_tree(node, node_label=None, show_pk=True, max_depth=1, follow_links_of_type=None, descend=True): - """ - Get a string representing an ASCII tree for the given node. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - - :param node: The node to get the tree for - :type node: :class:`aiida.orm.nodes.node.Node` - :param node_label: What to label the nodes with (can be an attribute name) - :type node_label: str - :param show_pk: If True, show the pk with the node label - :type show_pk: bool - :param max_depth: The maximum depth to follow starting from the node - :type max_depth: int - :param follow_links_of_type: Follow links of a given type, can be None - :type follow_links_of_type: One of the members from - :class:`aiida.common.links.LinkType` - :param descend: if True will follow outputs, if False inputs - :type descend: bool - :return: The string giving an ASCII representation of the tree from the node - :rtype: str - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - from ete3 import Tree - tree_string = build_tree(node, node_label, show_pk, max_depth, follow_links_of_type, descend) - tree = Tree(f'({tree_string});', format=1) - return tree.get_ascii(show_internal=True) - - -def build_tree(node, node_label=None, show_pk=True, max_depth=1, follow_links_of_type=None, descend=True, depth=0): - """ - Recursively build an ASCII string representation of the node tree - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - - :param node: The node to get the tree for - :type node: :class:`aiida.orm.nodes.node.Node` - :param node_label: What to label the nodes with (can be an attribute name) - :type node_label: str - :param show_pk: If True, show the pk with the node label - :type show_pk: bool - :param max_depth: The maximum depth to follow starting from the node - :type max_depth: int - :param follow_links_of_type: Follow links of a given type, can be None - :type follow_links_of_type: One of the members from - :class:`aiida.common.links.LinkType` - :param descend: if True will follow outputs, if False inputs - :type descend: bool - :param depth: the current depth - :type depth: int - :return: The string giving an ASCII representation of the tree from the node - :rtype: str - """ - # pylint: disable=too-many-arguments - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - out_values = [] - - if depth < max_depth: - relatives = [] - - if descend: - outputs = node.get_outgoing(link_type=follow_links_of_type).all_nodes() - else: # ascend - if follow_links_of_type is None: - follow_links_of_type = (LinkType.CREATE, LinkType.INPUT_CALC, LinkType.INPUT_WORK) - - outputs = node.get_incoming(link_type=follow_links_of_type).all_nodes() - - for child in sorted(outputs, key=lambda node: node.ctime): - relatives.append( - build_tree(child, node_label, show_pk, max_depth, follow_links_of_type, descend, depth + 1) - ) - - if relatives: - out_values.append(f"({', '.join(relatives)})") - - out_values.append(_generate_node_label(node, node_label, show_pk)) - - return ''.join(out_values) - - -def _generate_node_label(node, node_attr, show_pk): - """ - Generate a label for the node. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`. - - :param node: The node to generate the label for - :type node: :class:`aiida.orm.nodes.node.Node` - :param node_attr: The attribute to use as the label, can be None - :type node_attr: str - :param show_pk: if True, show the PK alongside the label - :type show_pk: bool - :return: The generated label - :rtype: str - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated and will be removed in `aiida-core==2.0.0`.', AiidaDeprecationWarning) # pylint: disable=no-member - label = None - if node_attr is None: - try: - label = node.process_label - except AttributeError: - label = None - else: - try: - label = str(getattr(node, node_attr)) - except AttributeError: - try: - label = node.get_attribute(node_attr) - except AttributeError: - pass - - # Couldn't find one, so just use the class name - if label is None: - label = node.__class__.__name__ - - if show_pk: - label += f' [{node.pk}]' - - return label - - def calc_info(node): """Return a string with the summary of the state of a CalculationNode.""" from aiida.orm import ProcessNode, WorkChainNode diff --git a/aiida/common/datastructures.py b/aiida/common/datastructures.py index 271cdaec48..99d7faadac 100644 --- a/aiida/common/datastructures.py +++ b/aiida/common/datastructures.py @@ -70,13 +70,6 @@ class CalcInfo(DefaultFieldsAttributeDict): and stored temporarily in a FolderData, that will be available only during the parsing call. The format of the list is the same as that of 'retrieve_list' - * retrieve_singlefile_list: a list of tuples with format - ('linkname_from calc to singlefile', 'subclass of singlefile', 'filename') - Each tuple represents a file that will be retrieved from cluster and saved in SinglefileData nodes - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use `retrieve_temporary_list` instead. - * local_copy_list: a list of tuples with format ('node_uuid', 'filename', relativedestpath') * remote_copy_list: a list of tuples with format ('remotemachinename', 'remoteabspath', 'relativedestpath') * remote_symlink_list: a list of tuples with format ('remotemachinename', 'remoteabspath', 'relativedestpath') @@ -93,29 +86,10 @@ class CalcInfo(DefaultFieldsAttributeDict): """ _default_fields = ( - 'job_environment', - 'email', - 'email_on_started', - 'email_on_terminated', - 'uuid', - 'prepend_text', - 'append_text', - 'num_machines', - 'num_mpiprocs_per_machine', - 'priority', - 'max_wallclock_seconds', - 'max_memory_kb', - 'rerunnable', - 'retrieve_list', - 'retrieve_temporary_list', - 'retrieve_singlefile_list', # Deprecated as of 1.0.0, use instead `retrieve_temporary_list` - 'local_copy_list', - 'remote_copy_list', - 'remote_symlink_list', - 'provenance_exclude_list', - 'codes_info', - 'codes_run_mode', - 'skip_submit' + 'job_environment', 'email', 'email_on_started', 'email_on_terminated', 'uuid', 'prepend_text', 'append_text', + 'num_machines', 'num_mpiprocs_per_machine', 'priority', 'max_wallclock_seconds', 'max_memory_kb', 'rerunnable', + 'retrieve_list', 'retrieve_temporary_list', 'local_copy_list', 'remote_copy_list', 'remote_symlink_list', + 'provenance_exclude_list', 'codes_info', 'codes_run_mode', 'skip_submit' ) diff --git a/aiida/engine/daemon/execmanager.py b/aiida/engine/daemon/execmanager.py index 9e1e3459e3..1e11ade925 100644 --- a/aiida/engine/daemon/execmanager.py +++ b/aiida/engine/daemon/execmanager.py @@ -26,7 +26,6 @@ from aiida.common.links import LinkType from aiida.orm import load_node, CalcJobNode, Code, FolderData, Node, RemoteData from aiida.orm.utils.log import get_dblogger_extra -from aiida.plugins import DataFactory from aiida.schedulers.datastructures import JobState from aiida.transports import Transport @@ -432,18 +431,12 @@ def retrieve_calculation(calculation: CalcJobNode, transport: Transport, retriev # First, retrieve the files of folderdata retrieve_list = calculation.get_retrieve_list() retrieve_temporary_list = calculation.get_retrieve_temporary_list() - retrieve_singlefile_list = calculation.get_retrieve_singlefile_list() with SandboxFolder() as folder: retrieve_files_from_list(calculation, transport, folder.abspath, retrieve_list) # Here I retrieved everything; now I store them inside the calculation retrieved_files.put_object_from_tree(folder.abspath) - # Second, retrieve the singlefiles, if any files were specified in the 'retrieve_temporary_list' key - if retrieve_singlefile_list: - with SandboxFolder() as folder: - _retrieve_singlefiles(calculation, transport, folder, retrieve_singlefile_list, logger_extra) - # Retrieve the temporary files in the retrieved_temporary_folder if any files were # specified in the 'retrieve_temporary_list' key if retrieve_temporary_list: @@ -503,41 +496,6 @@ def kill_calculation(calculation: CalcJobNode, transport: Transport) -> None: ) -def _retrieve_singlefiles( - job: CalcJobNode, - transport: Transport, - folder: SandboxFolder, - retrieve_file_list: List[Tuple[str, str, str]], - logger_extra: Optional[dict] = None -): - """Retrieve files specified through the singlefile list mechanism.""" - singlefile_list = [] - for (linkname, subclassname, filename) in retrieve_file_list: - EXEC_LOGGER.debug( - '[retrieval of calc {}] Trying ' - "to retrieve remote singlefile '{}'".format(job.pk, filename), - extra=logger_extra - ) - localfilename = os.path.join(folder.abspath, os.path.split(filename)[1]) - transport.get(filename, localfilename, ignore_nonexisting=True) - singlefile_list.append((linkname, subclassname, localfilename)) - - # ignore files that have not been retrieved - singlefile_list = [i for i in singlefile_list if os.path.exists(i[2])] - - # after retrieving from the cluster, I create the objects - singlefiles = [] - for (linkname, subclassname, filename) in singlefile_list: - cls = DataFactory(subclassname) - singlefile = cls(file=filename) - singlefile.add_incoming(job, link_type=LinkType.CREATE, link_label=linkname) - singlefiles.append(singlefile) - - for fil in singlefiles: - EXEC_LOGGER.debug(f'[retrieval of calc {job.pk}] Storing retrieved_singlefile={fil.pk}', extra=logger_extra) - fil.store() - - def retrieve_files_from_list( calculation: CalcJobNode, transport: Transport, folder: str, retrieve_list: List[Union[str, Tuple[str, str, int], list]] diff --git a/aiida/engine/processes/calcjobs/calcjob.py b/aiida/engine/processes/calcjobs/calcjob.py index f13a65a965..f0744b190c 100644 --- a/aiida/engine/processes/calcjobs/calcjob.py +++ b/aiida/engine/processes/calcjobs/calcjob.py @@ -495,7 +495,6 @@ def presubmit(self, folder: Folder) -> CalcInfo: from aiida.common.utils import validate_list_of_string_tuples from aiida.common.datastructures import CodeInfo, CodeRunMode from aiida.orm import load_node, Code, Computer - from aiida.plugins import DataFactory from aiida.schedulers.datastructures import JobTemplate computer = self.node.computer @@ -548,18 +547,6 @@ def presubmit(self, folder: Folder) -> CalcInfo: retrieve_list.extend(self.node.get_option('additional_retrieve_list') or []) self.node.set_retrieve_list(retrieve_list) - retrieve_singlefile_list = calc_info.retrieve_singlefile_list or [] - # a validation on the subclasses of retrieve_singlefile_list - for _, subclassname, _ in retrieve_singlefile_list: - file_sub_class = DataFactory(subclassname) - if not issubclass(file_sub_class, orm.SinglefileData): - raise PluginInternalError( - '[presubmission of calc {}] retrieve_singlefile_list subclass problem: {} is ' - 'not subclass of SinglefileData'.format(self.node.pk, file_sub_class.__name__) - ) - if retrieve_singlefile_list: - self.node.set_retrieve_singlefile_list(retrieve_singlefile_list) - # Handle the retrieve_temporary_list retrieve_temporary_list = calc_info.retrieve_temporary_list or [] self.node.set_retrieve_temporary_list(retrieve_temporary_list) diff --git a/aiida/manage/configuration/__init__.py b/aiida/manage/configuration/__init__.py index a22620573e..6860ab2c07 100644 --- a/aiida/manage/configuration/__init__.py +++ b/aiida/manage/configuration/__init__.py @@ -115,8 +115,8 @@ def _merge_deprecated_cache_yaml(config, filepath): cache_path_backup = f"{cache_path}.{timezone.now().strftime('%Y%m%d-%H%M%S.%f')}" warnings.warn( - f'cache_config.yml use is deprecated, merging into config.json and moving to: {cache_path_backup}', - AiidaDeprecationWarning + 'cache_config.yml use is deprecated and support will be removed in `v3.0`. Merging into config.json and ' + f'moving to: {cache_path_backup}', AiidaDeprecationWarning ) import yaml with open(cache_path, 'r', encoding='utf8') as handle: diff --git a/aiida/manage/database/delete/__init__.py b/aiida/manage/database/delete/__init__.py deleted file mode 100644 index 2776a55f97..0000000000 --- a/aiida/manage/database/delete/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### diff --git a/aiida/manage/database/delete/nodes.py b/aiida/manage/database/delete/nodes.py deleted file mode 100644 index 03a7edc47f..0000000000 --- a/aiida/manage/database/delete/nodes.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Functions to delete nodes from the database, preserving provenance integrity.""" -from typing import Callable, Iterable, Optional, Set, Tuple, Union -import warnings - - -def delete_nodes( - pks: Iterable[int], - verbosity: Optional[int] = None, - dry_run: Union[bool, Callable[[Set[int]], bool]] = True, - force: Optional[bool] = None, - **traversal_rules: bool -) -> Tuple[Set[int], bool]: - """Delete nodes given a list of "starting" PKs. - - .. deprecated:: 1.6.0 - This function has been moved and will be removed in `v2.0.0`. - It should now be imported using `from aiida.tools import delete_nodes` - - """ - from aiida.common.warnings import AiidaDeprecationWarning - from aiida.tools import delete_nodes as _delete - - warnings.warn( - 'This function has been moved and will be removed in `v2.0.0`.' - 'It should now be imported using `from aiida.tools import delete_nodes`', AiidaDeprecationWarning - ) # pylint: disable=no-member - - return _delete(pks, verbosity, dry_run, force, **traversal_rules) diff --git a/aiida/manage/external/pgsu.py b/aiida/manage/external/pgsu.py deleted file mode 100644 index 05c58e2a97..0000000000 --- a/aiida/manage/external/pgsu.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Connect to an existing PostgreSQL cluster as the `postgres` superuser and execute SQL commands. - -Note: Once the API of this functionality has converged, this module should be moved out of aiida-core and into a - separate package that can then be tested on multiple OS / postgres setups. Therefore, **please keep this - module entirely AiiDA-agnostic**. -""" -import warnings -from pgsu import PGSU, PostgresConnectionMode, DEFAULT_DSN as DEFAULT_DBINFO # pylint: disable=unused-import,no-name-in-module -from aiida.common.warnings import AiidaDeprecationWarning - -warnings.warn( # pylint: disable=no-member - '`aiida.manage.external.pgsu` is now available in the separate `pgsu` package. ' - 'This module will be removed entirely in AiiDA 2.0.0', AiidaDeprecationWarning -) diff --git a/aiida/manage/fixtures.py b/aiida/manage/fixtures.py deleted file mode 100644 index ebc7e65752..0000000000 --- a/aiida/manage/fixtures.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -""" -Testing infrastructure for easy testing of AiiDA plugins. - -""" - -import warnings -from aiida.common.warnings import AiidaDeprecationWarning -from aiida.manage.tests import TestManager as FixtureManager -from aiida.manage.tests import test_manager as fixture_manager -from aiida.manage.tests import _GLOBAL_TEST_MANAGER as _GLOBAL_FIXTURE_MANAGER -from aiida.manage.tests.unittest_classes import PluginTestCase - -warnings.warn('this module is deprecated, use `aiida.manage.tests` and its submodules instead', AiidaDeprecationWarning) # pylint: disable=no-member - -__all__ = ('FixtureManager', 'fixture_manager', '_GLOBAL_FIXTURE_MANAGER', 'PluginTestCase') diff --git a/aiida/manage/tests/__init__.py b/aiida/manage/tests/__init__.py index 258773db31..24e0d218a7 100644 --- a/aiida/manage/tests/__init__.py +++ b/aiida/manage/tests/__init__.py @@ -67,7 +67,6 @@ class TestManager: temporary AiiDA environment. For usage with pytest, see :py:class:`~aiida.manage.tests.pytest_fixtures`. - For usage with unittest, see :py:class:`~aiida.manage.tests.unittest_classes`. """ def __init__(self): diff --git a/aiida/manage/tests/unittest_classes.py b/aiida/manage/tests/unittest_classes.py deleted file mode 100644 index e722a78c8e..0000000000 --- a/aiida/manage/tests/unittest_classes.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -""" -Test classes and test runners for testing AiiDA plugins with unittest. -""" - -import unittest - -from aiida.manage.manager import get_manager -from . import _GLOBAL_TEST_MANAGER, test_manager, get_test_backend_name, get_test_profile_name - -__all__ = ('PluginTestCase', 'TestRunner') - - -class PluginTestCase(unittest.TestCase): - """ - Set up a complete temporary AiiDA environment for plugin tests. - - Note: This test class needs to be run through the :py:class:`~aiida.manage.tests.unittest_classes.TestRunner` - and will **not** work simply with `python -m unittest discover`. - - Usage example:: - - MyTestCase(aiida.manage.tests.unittest_classes.PluginTestCase): - - def setUp(self): - # load my tests data - - # optionally extend setUpClass / tearDownClass / tearDown if needed - - def test_my_plugin(self): - # execute tests - """ - # Filled in during setUpClass - backend = None # type :class:`aiida.orm.implementation.Backend` - - @classmethod - def setUpClass(cls): - cls.test_manager = _GLOBAL_TEST_MANAGER - if not cls.test_manager.has_profile_open(): - raise ValueError( - 'Fixture mananger has no open profile.' + - 'Please use aiida.manage.tests.unittest_classes.TestRunner to run these tests.' - ) - - cls.backend = get_manager().get_backend() - - def tearDown(self): - self.test_manager.reset_db() - - -class TestRunner(unittest.runner.TextTestRunner): - """ - Testrunner for unit tests using the fixture manager. - - Usage example:: - - import unittest - from aiida.manage.tests.unittest_classes import TestRunner - - tests = unittest.defaultTestLoader.discover('.') - TestRunner().run(tests) - - """ - - # pylint: disable=arguments-differ - def run(self, suite, backend=None, profile_name=None): - """ - Run tests using fixture manager for specified backend. - - :param suite: A suite of tests, as returned e.g. by :py:meth:`unittest.TestLoader.discover` - :param backend: name of database backend to be used. - :param profile_name: name of test profile to be used or None (will use temporary profile) - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn( # pylint: disable=no-member - 'Please use "pytest" for testing AiiDA plugins. Support for "unittest" will be removed in `v2.0.0`', - AiidaDeprecationWarning - ) - - with test_manager( - backend=backend or get_test_backend_name(), profile_name=profile_name or get_test_profile_name() - ): - return super().run(suite) diff --git a/aiida/orm/autogroup.py b/aiida/orm/autogroup.py index 0a9ba72358..3008fe8d38 100644 --- a/aiida/orm/autogroup.py +++ b/aiida/orm/autogroup.py @@ -9,11 +9,9 @@ ########################################################################### """Module to manage the autogrouping functionality by ``verdi run``.""" import re -import warnings from aiida.common import exceptions, timezone from aiida.common.escaping import escape_for_sql_like, get_regex_pattern_from_sql -from aiida.common.warnings import AiidaDeprecationWarning from aiida.orm import AutoGroup from aiida.plugins.entry_point import get_entry_point_string_from_class @@ -85,16 +83,6 @@ def get_group_label_prefix(self): If no group label prefix was set, it will set a default one by itself.""" return self._group_label_prefix - def get_group_name(self): - """Get the label of the group. - If no group label was set, it will set a default one by itself. - - .. deprecated:: 1.2.0 - Will be removed in `v2.0.0`, use :py:meth:`.get_group_label_prefix` instead. - """ - warnings.warn('function is deprecated, use `get_group_label_prefix` instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.get_group_label_prefix() - def set_exclude(self, exclude): """Set the list of classes to exclude in the autogrouping. @@ -133,15 +121,6 @@ def set_group_label_prefix(self, label_prefix): raise exceptions.ValidationError('group label must be a string') self._group_label_prefix = label_prefix - def set_group_name(self, gname): - """Set the name of the group. - - .. deprecated:: 1.2.0 - Will be removed in `v2.0.0`, use :py:meth:`.set_group_label_prefix` instead. - """ - warnings.warn('function is deprecated, use `set_group_label_prefix` instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.set_group_label_prefix(label_prefix=gname) - @staticmethod def _matches(string, filter_string): """Check if 'string' matches the 'filter_string' (used for include and exclude filters). diff --git a/aiida/orm/computers.py b/aiida/orm/computers.py index 2320d7fccf..19b8c024f5 100644 --- a/aiida/orm/computers.py +++ b/aiida/orm/computers.py @@ -10,10 +10,8 @@ """Module for Computer entities""" import logging import os -import warnings from aiida.common import exceptions -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.manager import get_manager from aiida.orm.implementation import Backend from aiida.plugins import SchedulerFactory, TransportFactory @@ -48,9 +46,6 @@ def get(self, **filters): :return: the entry """ - if 'name' in filters: - warnings.warn('keyword `name` is deprecated, use `label` instead', AiidaDeprecationWarning) # pylint: disable=no-member - # This switch needs to be here until we fully remove `name` and replace it with `label` even on the backend # entities and database models. if 'label' in filters: @@ -78,14 +73,6 @@ def get_or_create(self, label=None, **kwargs): except exceptions.NotExistent: return True, Computer(backend=self.backend, label=label, **kwargs) - def list_names(self): - """Return a list with all the names of the computers in the DB. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use `list_labels` instead. - """ - return self._backend.computers.list_names() - def list_labels(self): """Return a list with all the labels of the computers in the DB.""" return self._backend.computers.list_names() @@ -103,26 +90,8 @@ def __init__( # pylint: disable=too-many-arguments scheduler_type: str = '', workdir: str = None, backend: Backend = None, - name: str = None ) -> 'Computer': - """Construct a new computer - - .. deprecated:: 1.4.0 - The `name` keyword will be removed in `v2.0.0`, use `label` instead. - """ - - # This needs to be here because `label` needed to get a default, since it was replacing `name` and during the - # deprecation period, it needs to be automatically set to whatever `name` is passed. As a knock-on effect, since - # a keyword argument cannot preceed a normal argument, `hostname` also needed to become a keyword argument, - # forcing us to set a default, which we set to `None`. We raise the same exception that Python would normally - # raise if a normally positional argument is not specified. - if hostname is None: - raise TypeError("missing 1 required positional argument: 'hostname'") - - if name is not None: - warnings.warn('keyword `name` is deprecated, use `label` instead', AiidaDeprecationWarning) # pylint: disable=no-member - label = name - + """Construct a new computer.""" backend = backend or get_manager().get_backend() model = backend.computers.create( name=label, @@ -141,50 +110,6 @@ def __repr__(self): def __str__(self): return f'{self.label} ({self.hostname}), pk: {self.pk}' - @property - def full_text_info(self): - """ - Return a (multiline) string with a human-readable detailed information on this computer. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`. - - :rtype: str - """ - warnings.warn('this property is deprecated', AiidaDeprecationWarning) # pylint: disable=no-member - ret_lines = [] - ret_lines.append(f'Computer name: {self.label}') - ret_lines.append(f' * PK: {self.pk}') - ret_lines.append(f' * UUID: {self.uuid}') - ret_lines.append(f' * Description: {self.description}') - ret_lines.append(f' * Hostname: {self.hostname}') - ret_lines.append(f' * Transport type: {self.transport_type}') - ret_lines.append(f' * Scheduler type: {self.scheduler_type}') - ret_lines.append(f' * Work directory: {self.get_workdir()}') - ret_lines.append(f' * Shebang: {self.get_shebang()}') - ret_lines.append(f" * mpirun command: {' '.join(self.get_mpirun_command())}") - def_cpus_machine = self.get_default_mpiprocs_per_machine() - if def_cpus_machine is not None: - ret_lines.append(f' * Default number of cpus per machine: {def_cpus_machine}') - # pylint: disable=fixme - # TODO: Put back following line when we port Node to new backend system - # ret_lines.append(" * Used by: {} nodes".format(len(self._dbcomputer.dbnodes.all()))) - - ret_lines.append(' * prepend text:') - if self.get_prepend_text().strip(): - for line in self.get_prepend_text().split('\n'): - ret_lines.append(f' {line}') - else: - ret_lines.append(' # No prepend text.') - ret_lines.append(' * append text:') - if self.get_append_text().strip(): - for line in self.get_append_text().split('\n'): - ret_lines.append(f' {line}') - else: - ret_lines.append(' # No append text.') - - return '\n'.join(ret_lines) - @property def logger(self): return self._logger @@ -746,254 +671,3 @@ def get_configuration(self, user=None): pass return config - - @property - def name(self): - """Return the computer name. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `label` property instead. - """ - warnings.warn('this property is deprecated, use the `label` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.label - - def get_name(self): - """Return the computer name. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `label` property instead. - """ - warnings.warn('this property is deprecated, use the `label` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.label - - def set_name(self, val): - """Set the computer name. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `label` property instead. - """ - warnings.warn('this method is deprecated, use the `label` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self.label = val - - def get_hostname(self): - """Get this computer hostname - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `hostname` property instead. - - :rtype: str - """ - warnings.warn('this method is deprecated, use the `hostname` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.hostname - - def set_hostname(self, val): - """ - Set the hostname of this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `hostname` property instead. - - :param val: The new hostname - :type val: str - """ - warnings.warn('this method is deprecated, use the `hostname` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self.hostname = val - - def get_description(self): - """ - Get the description for this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `description` property instead. - - :return: the description - :rtype: str - """ - warnings.warn('this method is deprecated, use the `description` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.description - - def set_description(self, val): - """ - Set the description for this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `description` property instead. - - :param val: the new description - :type val: str - """ - warnings.warn('this method is deprecated, use the `description` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self.description = val - - def get_scheduler_type(self): - """ - Get the scheduler type for this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `scheduler_type` property instead. - - :return: the scheduler type - :rtype: str - """ - warnings.warn('this method is deprecated, use the `scheduler_type` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.scheduler_type - - def set_scheduler_type(self, scheduler_type): - """ - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `scheduler_type` property instead. - - :param scheduler_type: the new scheduler type - """ - warnings.warn('this method is deprecated, use the `scheduler_type` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self._scheduler_type_validator(scheduler_type) - self.scheduler_type = scheduler_type - - def get_transport_type(self): - """ - Get the current transport type for this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `transport_type` property instead. - - :return: the transport type - :rtype: str - """ - warnings.warn('this method is deprecated, use the `transport_type` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.transport_type - - def set_transport_type(self, transport_type): - """ - Set the transport type for this computer - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `transport_type` property instead. - - :param transport_type: the new transport type - :type transport_type: str - """ - warnings.warn('this method is deprecated, use the `transport_type` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self.transport_type = transport_type - - def get_metadata(self): - """ - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `metadata` property instead. - - """ - warnings.warn('this method is deprecated, use the `metadata` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - return self.metadata - - def set_metadata(self, metadata): - """ - Set the metadata. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `metadata` property instead. - - .. note: You still need to call the .store() method to actually save - data to the database! (The store method can be called multiple - times, differently from AiiDA Node objects). - """ - warnings.warn('this method is deprecated, use the `metadata` property instead', AiidaDeprecationWarning) # pylint: disable=no-member - self.metadata = metadata - - @staticmethod - def get_schema(): - """ - Every node property contains: - - display_name: display name of the property - - help text: short help text of the property - - is_foreign_key: is the property foreign key to other type of the node - - type: type of the property. e.g. str, dict, int - - :return: get schema of the computer - - .. deprecated:: 1.0.0 - - Will be removed in `v2.0.0`. - Use :meth:`~aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead. - - """ - message = 'method is deprecated, use' \ - '`aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - - return { - 'description': { - 'display_name': 'Description', - 'help_text': 'short description of the Computer', - 'is_foreign_key': False, - 'type': 'str' - }, - 'hostname': { - 'display_name': 'Host', - 'help_text': 'Name of the host', - 'is_foreign_key': False, - 'type': 'str' - }, - 'id': { - 'display_name': 'Id', - 'help_text': 'Id of the object', - 'is_foreign_key': False, - 'type': 'int' - }, - 'name': { - 'display_name': 'Name', - 'help_text': 'Name of the object', - 'is_foreign_key': False, - 'type': 'str' - }, - 'scheduler_type': { - 'display_name': 'Scheduler', - 'help_text': 'Scheduler type', - 'is_foreign_key': False, - 'type': 'str', - 'valid_choices': { - 'direct': { - 'doc': 'Support for the direct execution bypassing schedulers.' - }, - 'pbsbaseclasses.PbsBaseClass': { - 'doc': 'Base class with support for the PBSPro scheduler' - }, - 'pbspro': { - 'doc': 'Subclass to support the PBSPro scheduler' - }, - 'sge': { - 'doc': - 'Support for the Sun Grid Engine scheduler and its variants/forks (Son of Grid Engine, ' - 'Oracle Grid Engine, ...)' - }, - 'slurm': { - 'doc': 'Support for the SLURM scheduler (http://slurm.schedmd.com/).' - }, - 'torque': { - 'doc': 'Subclass to support the Torque scheduler.' - } - } - }, - 'transport_type': { - 'display_name': 'Transport type', - 'help_text': 'Transport Type', - 'is_foreign_key': False, - 'type': 'str', - 'valid_choices': { - 'local': { - 'doc': - 'Support copy and command execution on the same host on which AiiDA is running via direct ' - 'file copy and execution commands.' - }, - 'ssh': { - 'doc': - 'Support connection, command execution and data transfer to remote computers via SSH+SFTP.' - } - } - }, - 'uuid': { - 'display_name': 'Unique ID', - 'help_text': 'Universally Unique Identifier', - 'is_foreign_key': False, - 'type': 'unicode' - } - } diff --git a/aiida/orm/groups.py b/aiida/orm/groups.py index 2313c62f0f..d1e4a00a76 100644 --- a/aiida/orm/groups.py +++ b/aiida/orm/groups.py @@ -9,19 +9,17 @@ ########################################################################### """AiiDA Group entites""" from abc import ABCMeta -from enum import Enum import warnings from aiida.common import exceptions from aiida.common.lang import type_check -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.manager import get_manager from . import convert from . import entities from . import users -__all__ = ('Group', 'GroupTypeString', 'AutoGroup', 'ImportGroup', 'UpfFamily') +__all__ = ('Group', 'AutoGroup', 'ImportGroup', 'UpfFamily') def load_group_class(type_string): @@ -65,18 +63,6 @@ def __new__(cls, name, bases, namespace, **kwargs): return newcls -class GroupTypeString(Enum): - """A simple enum of allowed group type strings. - - .. deprecated:: 1.2.0 - This enum is deprecated and will be removed in `v2.0.0`. - """ - UPFGROUP_TYPE = 'data.upf' - IMPORTGROUP_TYPE = 'auto.import' - VERDIAUTOGROUP_TYPE = 'auto.run' - USER = 'user' - - class Group(entities.Entity, entities.EntityExtrasMixin, metaclass=GroupMeta): """An AiiDA ORM implementation of group of nodes.""" @@ -122,9 +108,6 @@ def __init__(self, label=None, user=None, description='', type_string=None, back a group from the DB (and then, no further parameters are allowed), or pass the parameters for the Group creation. - .. deprecated:: 1.2.0 - The parameter `type_string` will be removed in `v2.0.0` and is now determined automatically. - :param label: The group label, required on creation :type label: str @@ -141,20 +124,10 @@ def __init__(self, label=None, user=None, description='', type_string=None, back if not label: raise ValueError('Group label must be provided') - if type_string is not None: - message = '`type_string` is deprecated because it is determined automatically' - warnings.warn(message) # pylint: disable=no-member - - # If `type_string` is explicitly defined, override automatically determined `self._type_string`. This is - # necessary for backwards compatibility. - if type_string is not None: - self._type_string = type_string - - type_string = self._type_string - backend = backend or get_manager().get_backend() user = user or users.User.objects(backend).get_default() type_check(user, users.User) + type_string = self._type_string model = backend.groups.create( label=label, user=user.backend_entity, description=description, type_string=type_string @@ -328,25 +301,6 @@ def remove_nodes(self, nodes): self._backend_entity.remove_nodes([node.backend_entity for node in nodes]) - @classmethod - def get(cls, **kwargs): - """ - Custom get for group which can be used to get a group with the given attributes - - :param kwargs: the attributes to match the group to - - :return: the group - :type nodes: :class:`aiida.orm.Node` or list - """ - from aiida.orm import QueryBuilder - - if 'type_string' in kwargs: - message = '`type_string` is deprecated because it is determined automatically' - warnings.warn(message) # pylint: disable=no-member - type_check(kwargs['type_string'], str) - - return QueryBuilder().append(cls, filters=kwargs).one()[0] - def is_user_defined(self): """ :return: True if the group is user defined, False otherwise @@ -354,69 +308,6 @@ def is_user_defined(self): """ return not self.type_string - @staticmethod - def get_schema(): - """ - Every node property contains: - - display_name: display name of the property - - help text: short help text of the property - - is_foreign_key: is the property foreign key to other type of the node - - type: type of the property. e.g. str, dict, int - - :return: schema of the group - :rtype: dict - - .. deprecated:: 1.0.0 - - Will be removed in `v2.0.0`. - Use :meth:`~aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead. - - """ - message = 'method is deprecated, use' \ - '`aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - - return { - 'description': { - 'display_name': 'Description', - 'help_text': 'Short description of the group', - 'is_foreign_key': False, - 'type': 'str' - }, - 'id': { - 'display_name': 'Id', - 'help_text': 'Id of the object', - 'is_foreign_key': False, - 'type': 'int' - }, - 'label': { - 'display_name': 'Label', - 'help_text': 'Name of the object', - 'is_foreign_key': False, - 'type': 'str' - }, - 'type_string': { - 'display_name': 'Type_string', - 'help_text': 'Type of the group', - 'is_foreign_key': False, - 'type': 'str' - }, - 'user_id': { - 'display_name': 'Id of creator', - 'help_text': 'Id of the user that created the node', - 'is_foreign_key': True, - 'related_column': 'id', - 'related_resource': '_dbusers', - 'type': 'int' - }, - 'uuid': { - 'display_name': 'Unique ID', - 'help_text': 'Universally Unique Identifier', - 'is_foreign_key': False, - 'type': 'unicode' - } - } - class AutoGroup(Group): """Group to be used to contain selected nodes generated while `aiida.orm.autogroup.CURRENT_AUTOGROUP` is set.""" diff --git a/aiida/orm/nodes/data/code.py b/aiida/orm/nodes/data/code.py index b3bade861e..cb356eeacf 100644 --- a/aiida/orm/nodes/data/code.py +++ b/aiida/orm/nodes/data/code.py @@ -9,10 +9,8 @@ ########################################################################### """Data plugin represeting an executable code to be wrapped and called through a `CalcJob` plugin.""" import os -import warnings from aiida.common import exceptions -from aiida.common.warnings import AiidaDeprecationWarning from .data import Data __all__ = ('Code',) @@ -100,14 +98,6 @@ def __str__(self): computer_str = self.computer.label return f"{local_str} code '{self.label}' on {computer_str}, pk: {self.pk}, uuid: {self.uuid}" - def get_computer_name(self): - """Get label of this code's computer. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `self.get_computer_label()` method instead. - """ - return self.get_computer_label() - def get_computer_label(self): """Get label of this code's computer.""" return 'repository' if self.is_local() else self.computer.label @@ -140,15 +130,10 @@ def label(self, value): super(Code, self.__class__).label.fset(self, value) # pylint: disable=no-member - def relabel(self, new_label, raise_error=True): + def relabel(self, new_label): """Relabel this code. :param new_label: new code label - :param raise_error: Set to False in order to return a list of errors - instead of raising them. - - .. deprecated:: 1.2.0 - Will remove raise_error in `v2.0.0`. Use `try/except` instead. """ # pylint: disable=unused-argument suffix = f'@{self.computer.label}' @@ -495,54 +480,3 @@ def get_builder(self): builder.code = self return builder - - def get_full_text_info(self, verbose=False): - """Return a list of lists with a human-readable detailed information on this code. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`. - - :return: list of lists where each entry consists of two elements: a key and a value - """ - warnings.warn('this property is deprecated', AiidaDeprecationWarning) # pylint: disable=no-member - from aiida.repository import FileType - - result = [] - result.append(['PK', self.pk]) - result.append(['UUID', self.uuid]) - result.append(['Label', self.label]) - result.append(['Description', self.description]) - result.append(['Default plugin', self.get_input_plugin_name()]) - - if verbose: - result.append(['Calculations', len(self.get_outgoing().all())]) - - if self.is_local(): - result.append(['Type', 'local']) - result.append(['Exec name', self.get_execname()]) - result.append(['List of files/folders:', '']) - for obj in self.list_objects(): - if obj.file_type == FileType.DIRECTORY: - result.append(['directory', obj.name]) - else: - result.append(['file', obj.name]) - else: - result.append(['Type', 'remote']) - result.append(['Remote machine', self.get_remote_computer().label]) - result.append(['Remote absolute path', self.get_remote_exec_path()]) - - if self.get_prepend_text().strip(): - result.append(['Prepend text', '']) - for line in self.get_prepend_text().split('\n'): - result.append(['', line]) - else: - result.append(['Prepend text', 'No prepend text']) - - if self.get_append_text().strip(): - result.append(['Append text', '']) - for line in self.get_append_text().split('\n'): - result.append(['', line]) - else: - result.append(['Append text', 'No append text']) - - return result diff --git a/aiida/orm/nodes/data/remote/base.py b/aiida/orm/nodes/data/remote/base.py index b293e2e6b9..48a0aed832 100644 --- a/aiida/orm/nodes/data/remote/base.py +++ b/aiida/orm/nodes/data/remote/base.py @@ -28,14 +28,6 @@ def __init__(self, remote_path=None, **kwargs): if remote_path is not None: self.set_remote_path(remote_path) - def get_computer_name(self): - """Get label of this node's computer. - - .. deprecated:: 1.4.0 - Will be removed in `v2.0.0`, use the `self.computer.label` property instead. - """ - return self.computer.label # pylint: disable=no-member - def get_remote_path(self): return self.get_attribute('remote_path') diff --git a/aiida/orm/nodes/data/singlefile.py b/aiida/orm/nodes/data/singlefile.py index c647ca93c5..f924c6a81e 100644 --- a/aiida/orm/nodes/data/singlefile.py +++ b/aiida/orm/nodes/data/singlefile.py @@ -9,13 +9,10 @@ ########################################################################### """Data class that can be used to store a single file in its repository.""" import contextlib -import inspect import os -import warnings import pathlib from aiida.common import exceptions -from aiida.common.warnings import AiidaDeprecationWarning from .data import Data __all__ = ('SinglefileData',) @@ -36,19 +33,8 @@ def __init__(self, file, filename=None, **kwargs): # pylint: disable=redefined-builtin super().__init__(**kwargs) - # 'filename' argument was added to 'set_file' after 1.0.0. - if 'filename' not in inspect.getfullargspec(self.set_file)[0]: - warnings.warn( # pylint: disable=no-member - f"Method '{type(self).__name__}.set_file' does not support the 'filename' argument. " + - 'This will raise an exception in AiiDA 2.0.', AiidaDeprecationWarning - ) - if file is not None: - if filename is None: - # don't assume that set_file has a 'filename' argument (remove guard in 2.0.0) - self.set_file(file) - else: - self.set_file(file, filename=filename) + self.set_file(file, filename=filename) @property def filename(self): diff --git a/aiida/orm/nodes/node.py b/aiida/orm/nodes/node.py index 67ffb749f9..d8a3ad52c4 100644 --- a/aiida/orm/nodes/node.py +++ b/aiida/orm/nodes/node.py @@ -14,7 +14,6 @@ import importlib from logging import Logger import typing -import warnings from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union from typing import TYPE_CHECKING from uuid import UUID @@ -24,7 +23,6 @@ from aiida.common.hashing import make_hash, _HASH_EXTRA_KEY from aiida.common.lang import classproperty, type_check from aiida.common.links import LinkType -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.manager import get_manager from aiida.orm.utils.links import LinkManager, LinkTriple from aiida.orm.utils.node import AbstractNodeMeta @@ -623,7 +621,7 @@ def has_cached_links(self) -> bool: assert self._incoming_cache is not None, 'incoming_cache not initialised' return bool(self._incoming_cache) - def store_all(self, with_transaction: bool = True, use_cache=None) -> 'Node': + def store_all(self, with_transaction: bool = True) -> 'Node': """Store the node, together with all input links. Unstored nodes from cached incoming linkswill also be stored. @@ -632,11 +630,6 @@ def store_all(self, with_transaction: bool = True, use_cache=None) -> 'Node': """ assert self._incoming_cache is not None, 'incoming_cache not initialised' - if use_cache is not None: - warnings.warn( # pylint: disable=no-member - 'the `use_cache` argument is deprecated and will be removed in `v2.0.0`', AiidaDeprecationWarning - ) - if self.is_stored: raise exceptions.ModificationNotAllowed(f'Node<{self.id}> is already stored') @@ -650,7 +643,7 @@ def store_all(self, with_transaction: bool = True, use_cache=None) -> 'Node': return self.store(with_transaction) - def store(self, with_transaction: bool = True, use_cache=None) -> 'Node': # pylint: disable=arguments-differ + def store(self, with_transaction: bool = True) -> 'Node': # pylint: disable=arguments-differ """Store the node in the database while saving its attributes and repository directory. After being called attributes cannot be changed anymore! Instead, extras can be changed only AFTER calling @@ -663,11 +656,6 @@ def store(self, with_transaction: bool = True, use_cache=None) -> 'Node': # pyl """ from aiida.manage.caching import get_use_cache - if use_cache is not None: - warnings.warn( # pylint: disable=no-member - 'the `use_cache` argument is deprecated and will be removed in `v2.0.0`', AiidaDeprecationWarning - ) - if not self.is_stored: # Call `validate_storability` directly and not in `_validate` in case sub class forgets to call the super. @@ -911,95 +899,3 @@ def get_description(self) -> str: """ # pylint: disable=no-self-use return '' - - @staticmethod - def get_schema() -> Dict[str, Any]: - """ - Every node property contains: - - display_name: display name of the property - - help text: short help text of the property - - is_foreign_key: is the property foreign key to other type of the node - - type: type of the property. e.g. str, dict, int - - :return: get schema of the node - - .. deprecated:: 1.0.0 - - Will be removed in `v2.0.0`. - Use :meth:`~aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead. - - """ - message = 'method is deprecated, use' \ - '`aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - - return { - 'attributes': { - 'display_name': 'Attributes', - 'help_text': 'Attributes of the node', - 'is_foreign_key': False, - 'type': 'dict' - }, - 'attributes.state': { - 'display_name': 'State', - 'help_text': 'AiiDA state of the calculation', - 'is_foreign_key': False, - 'type': '' - }, - 'ctime': { - 'display_name': 'Creation time', - 'help_text': 'Creation time of the node', - 'is_foreign_key': False, - 'type': 'datetime.datetime' - }, - 'extras': { - 'display_name': 'Extras', - 'help_text': 'Extras of the node', - 'is_foreign_key': False, - 'type': 'dict' - }, - 'id': { - 'display_name': 'Id', - 'help_text': 'Id of the object', - 'is_foreign_key': False, - 'type': 'int' - }, - 'label': { - 'display_name': 'Label', - 'help_text': 'User-assigned label', - 'is_foreign_key': False, - 'type': 'str' - }, - 'mtime': { - 'display_name': 'Last Modification time', - 'help_text': 'Last modification time', - 'is_foreign_key': False, - 'type': 'datetime.datetime' - }, - 'node_type': { - 'display_name': 'Type', - 'help_text': 'Node type', - 'is_foreign_key': False, - 'type': 'str' - }, - 'user_id': { - 'display_name': 'Id of creator', - 'help_text': 'Id of the user that created the node', - 'is_foreign_key': True, - 'related_column': 'id', - 'related_resource': '_dbusers', - 'type': 'int' - }, - 'uuid': { - 'display_name': 'Unique ID', - 'help_text': 'Universally Unique Identifier', - 'is_foreign_key': False, - 'type': 'unicode' - }, - 'process_type': { - 'display_name': 'Process type', - 'help_text': 'Process type', - 'is_foreign_key': False, - 'type': 'str' - } - } diff --git a/aiida/orm/nodes/process/calculation/calcjob.py b/aiida/orm/nodes/process/calculation/calcjob.py index 85bcb3020b..1ffe1d8fa8 100644 --- a/aiida/orm/nodes/process/calculation/calcjob.py +++ b/aiida/orm/nodes/process/calculation/calcjob.py @@ -11,13 +11,11 @@ import datetime from typing import Any, AnyStr, Dict, List, Optional, Sequence, Tuple, Type, Union from typing import TYPE_CHECKING -import warnings from aiida.common import exceptions from aiida.common.datastructures import CalcJobState from aiida.common.lang import classproperty from aiida.common.links import LinkType -from aiida.common.warnings import AiidaDeprecationWarning from .calculation import CalculationNode @@ -43,7 +41,6 @@ class CalcJobNode(CalculationNode): REMOTE_WORKDIR_KEY = 'remote_workdir' RETRIEVE_LIST_KEY = 'retrieve_list' RETRIEVE_TEMPORARY_LIST_KEY = 'retrieve_temporary_list' - RETRIEVE_SINGLE_FILE_LIST_KEY = 'retrieve_singlefile_list' SCHEDULER_JOB_ID_KEY = 'job_id' SCHEDULER_STATE_KEY = 'scheduler_state' SCHEDULER_LAST_CHECK_TIME_KEY = 'scheduler_lastchecktime' @@ -91,7 +88,6 @@ def _updatable_attributes(cls) -> Tuple[str, ...]: # pylint: disable=no-self-ar cls.REMOTE_WORKDIR_KEY, cls.RETRIEVE_LIST_KEY, cls.RETRIEVE_TEMPORARY_LIST_KEY, - cls.RETRIEVE_SINGLE_FILE_LIST_KEY, cls.SCHEDULER_JOB_ID_KEY, cls.SCHEDULER_STATE_KEY, cls.SCHEDULER_LAST_CHECK_TIME_KEY, @@ -149,7 +145,6 @@ def get_builder_restart(self) -> 'ProcessBuilder': """ builder = super().get_builder_restart() builder.metadata.options = self.get_options() # type: ignore[attr-defined] - return builder def get_option(self, name: str) -> Optional[Any]: @@ -311,46 +306,6 @@ def get_retrieve_temporary_list(self) -> Optional[Sequence[Union[str, Tuple[str, """ return self.get_attribute(self.RETRIEVE_TEMPORARY_LIST_KEY, None) - def set_retrieve_singlefile_list(self, retrieve_singlefile_list): - """Set the retrieve singlefile list. - - The files will be stored as `SinglefileData` instances and added as output nodes to this calculation node. - The format of a single file directive is a tuple or list of length 3 with the following entries: - - 1. the link label under which the file should be added - 2. the `SinglefileData` class or sub class to use to store - 3. the filepath relative to the remote working directory of the calculation - - :param retrieve_singlefile_list: list or tuple of single file directives - - .. deprecated:: 1.0.0 - - Will be removed in `v2.0.0`. - Use :meth:`~aiida.orm.nodes.process.calculation.calcjob.CalcJobNode.set_retrieve_temporary_list` instead. - - """ - warnings.warn('method is deprecated, use `set_retrieve_temporary_list` instead', AiidaDeprecationWarning) # pylint: disable=no-member - - if not isinstance(retrieve_singlefile_list, (tuple, list)): - raise TypeError('retrieve_singlefile_list has to be a list or tuple') - - for j in retrieve_singlefile_list: - if not isinstance(j, (tuple, list)) or not all(isinstance(i, str) for i in j): - raise ValueError('You have to pass a list (or tuple) of lists of strings as retrieve_singlefile_list') - - self.set_attribute(self.RETRIEVE_SINGLE_FILE_LIST_KEY, retrieve_singlefile_list) - - def get_retrieve_singlefile_list(self): - """Return the list of files to be retrieved on the cluster after the calculation has completed. - - :return: list of single file retrieval directives - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use - :meth:`aiida.orm.nodes.process.calculation.calcjob.CalcJobNode.get_retrieve_temporary_list` instead. - """ - return self.get_attribute(self.RETRIEVE_SINGLE_FILE_LIST_KEY, None) - def set_job_id(self, job_id: Union[int, str]) -> None: """Set the job id that was assigned to the calculation by the scheduler. diff --git a/aiida/orm/querybuilder.py b/aiida/orm/querybuilder.py index dab51feee5..4a75827f4e 100644 --- a/aiida/orm/querybuilder.py +++ b/aiida/orm/querybuilder.py @@ -34,7 +34,6 @@ from aiida.common.links import LinkType from aiida.manage.manager import get_manager from aiida.common.exceptions import ConfigurationError -from aiida.common.warnings import AiidaDeprecationWarning from . import authinfos from . import comments @@ -1812,33 +1811,6 @@ def _get_connecting_node(self, index, joining_keyword=None, joining_value=None, ) return returnval - def get_json_compatible_queryhelp(self): - """ - Makes the queryhelp a json-compatible dictionary. - - In this way,the queryhelp can be stored - in the database or a json-object, retrieved or shared and used later. - See this usage:: - - qb = QueryBuilder(limit=3).append(StructureData, project='id').order_by({StructureData:'id'}) - queryhelp = qb.get_json_compatible_queryhelp() - - # Now I could save this dictionary somewhere and use it later: - - qb2=QueryBuilder(**queryhelp) - - # This is True if no change has been made to the database. - # Note that such a comparison can only be True if the order of results is enforced - qb.all()==qb2.all() - - :returns: the json-compatible queryhelp - - .. deprecated:: 1.0.0 - Will be removed in `v2.0.0`, use the :meth:`aiida.orm.querybuilder.QueryBuilder.queryhelp` property instead. - """ - warnings.warn('method is deprecated, use the `queryhelp` property instead', AiidaDeprecationWarning) - return self.queryhelp - @property def queryhelp(self): """queryhelp dictionary correspondig to QueryBuilder instance. diff --git a/aiida/orm/users.py b/aiida/orm/users.py index c7c3b3565c..4c55bcad6f 100644 --- a/aiida/orm/users.py +++ b/aiida/orm/users.py @@ -8,11 +8,7 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Module for the ORM user class.""" - -import warnings - from aiida.common import exceptions -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.manager import get_manager from . import entities @@ -156,58 +152,3 @@ def get_short_name(self): :return: The short name """ return self.email - - @staticmethod - def get_schema(): - """ - Every node property contains: - - - display_name: display name of the property - - help text: short help text of the property - - is_foreign_key: is the property foreign key to other type of the node - - type: type of the property. e.g. str, dict, int - - :return: schema of the user - - .. deprecated:: 1.0.0 - - Will be removed in `v2.0.0`. - Use :meth:`~aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead. - - """ - message = 'method is deprecated, use' \ - '`aiida.restapi.translator.base.BaseTranslator.get_projectable_properties` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - - return { - 'id': { - 'display_name': 'Id', - 'help_text': 'Id of the object', - 'is_foreign_key': False, - 'type': 'int' - }, - 'email': { - 'display_name': 'email', - 'help_text': 'e-mail of the user', - 'is_foreign_key': False, - 'type': 'str' - }, - 'first_name': { - 'display_name': 'First name', - 'help_text': 'First name of the user', - 'is_foreign_key': False, - 'type': 'str' - }, - 'institution': { - 'display_name': 'Institution', - 'help_text': 'Affiliation of the user', - 'is_foreign_key': False, - 'type': 'str' - }, - 'last_name': { - 'display_name': 'Last name', - 'help_text': 'Last name of the user', - 'is_foreign_key': False, - 'type': 'str' - } - } diff --git a/aiida/orm/utils/managers.py b/aiida/orm/utils/managers.py index ad53db290c..f35f3344eb 100644 --- a/aiida/orm/utils/managers.py +++ b/aiida/orm/utils/managers.py @@ -95,7 +95,7 @@ def _get_node_by_link_label(self, label): 'dereferencing nodes with links containing double underscores is deprecated, simply replace ' 'the double underscores with a single dot instead. For example: \n' '`self.inputs.some__label` can be written as `self.inputs.some.label` instead.\n' - 'Support for double underscores will be removed in the future.', AiidaDeprecationWarning + 'Support for double underscores will be removed in `v3.0`.', AiidaDeprecationWarning ) # pylint: disable=no-member namespaces = label.split('__') return functools.reduce(lambda d, namespace: d.get(namespace), namespaces, attribute_dict) diff --git a/aiida/restapi/run_api.py b/aiida/restapi/run_api.py index dde845de70..dd90d8b540 100755 --- a/aiida/restapi/run_api.py +++ b/aiida/restapi/run_api.py @@ -13,10 +13,8 @@ """ import importlib import os -import warnings from flask_cors import CORS -from aiida.common.warnings import AiidaDeprecationWarning from .common.config import CLI_DEFAULTS, APP_CONFIG, API_CONFIG from . import api as api_classes @@ -43,15 +41,7 @@ def run_api(flask_app=api_classes.App, flask_api=api_classes.AiidaApi, **kwargs) :returns: tuple (app, api) if hookup==False or runs app if hookup==True """ - hookup = kwargs.pop('hookup', None) - if hookup is None: - hookup = CLI_DEFAULTS['HOOKUP_APP'] - else: - warnings.warn( # pylint: disable=no-member - 'Using the `hookup` parameter is deprecated since `v1.2.1` and will stop working in `v2.0.0`. ' - 'To configure the app without running it, use `configure_api` instead.', AiidaDeprecationWarning - ) - + hookup = kwargs.pop('hookup', CLI_DEFAULTS['HOOKUP_APP']) hostname = kwargs.pop('hostname', CLI_DEFAULTS['HOST_NAME']) port = kwargs.pop('port', CLI_DEFAULTS['PORT']) debug = kwargs.pop('debug', APP_CONFIG['DEBUG']) diff --git a/aiida/schedulers/scheduler.py b/aiida/schedulers/scheduler.py index b8e0e278b9..a152aaddd3 100644 --- a/aiida/schedulers/scheduler.py +++ b/aiida/schedulers/scheduler.py @@ -78,21 +78,6 @@ def __init__(self): if not issubclass(self._job_resource_class, JobResource): raise RuntimeError('the class attribute `_job_resource_class` is not a subclass of `JobResource`.') - @classmethod - def get_valid_schedulers(cls): - """Return all available scheduler plugins. - - .. deprecated:: 1.3.0 - - Will be removed in `2.0.0`, use `aiida.plugins.entry_point.get_entry_point_names` instead - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - from aiida.plugins.entry_point import get_entry_point_names - message = 'method is deprecated, use `aiida.plugins.entry_point.get_entry_point_names` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - return get_entry_point_names('aiida.schedulers') - @classmethod def get_short_doc(cls): """Return the first non-empty line of the class docstring, if available.""" @@ -290,35 +275,6 @@ def get_detailed_job_info(self, job_id): return detailed_job_info - def get_detailed_jobinfo(self, jobid): - """ - Return a string with the output of the detailed_jobinfo command. - - .. deprecated:: 1.1.0 - Will be removed in `v2.0.0`, use :meth:`aiida.schedulers.scheduler.Scheduler.get_detailed_job_info` instead. - - At the moment, the output text is just retrieved - and stored for logging purposes, but no parsing is performed. - - :raises: :class:`aiida.common.exceptions.FeatureNotAvailable` - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - warnings.warn('function is deprecated, use `get_detailed_job_info` instead', AiidaDeprecationWarning) # pylint: disable=no-member - - command = self._get_detailed_job_info_command(job_id=jobid) # pylint: disable=assignment-from-no-return - with self.transport: - retval, stdout, stderr = self.transport.exec_command_wait(command) - - return f"""Detailed jobinfo obtained with command '{command}' -Return Code: {retval} -------------------------------------------------------------- -stdout: -{stdout} -stderr: -{stderr} -""" - @abc.abstractmethod def _parse_joblist_output(self, retval, stdout, stderr): """Parse the joblist output as returned by executing the command returned by `_get_joblist_command` method. diff --git a/aiida/tools/graph/deletions.py b/aiida/tools/graph/deletions.py index 26b6bd81a2..5334413d54 100644 --- a/aiida/tools/graph/deletions.py +++ b/aiida/tools/graph/deletions.py @@ -9,12 +9,10 @@ ########################################################################### """Functions to delete entities from the database, preserving provenance integrity.""" import logging -from typing import Callable, Iterable, Optional, Set, Tuple, Union -import warnings +from typing import Callable, Iterable, Set, Tuple, Union from aiida.backends.utils import delete_nodes_and_connections from aiida.common.log import AIIDA_LOGGER -from aiida.common.warnings import AiidaDeprecationWarning from aiida.orm import Group, Node, QueryBuilder from aiida.tools.graph.graph_traversers import get_nodes_delete @@ -23,13 +21,9 @@ DELETE_LOGGER = AIIDA_LOGGER.getChild('delete') -def delete_nodes( - pks: Iterable[int], - verbosity: Optional[int] = None, - dry_run: Union[bool, Callable[[Set[int]], bool]] = True, - force: Optional[bool] = None, - **traversal_rules: bool -) -> Tuple[Set[int], bool]: +def delete_nodes(pks: Iterable[int], + dry_run: Union[bool, Callable[[Set[int]], bool]] = True, + **traversal_rules: bool) -> Tuple[Set[int], bool]: """Delete nodes given a list of "starting" PKs. This command will delete not only the specified nodes, but also the ones that are @@ -51,12 +45,6 @@ def delete_nodes( nodes will be deleted as well, and then any CALC node that may have those as inputs, and so on. - .. deprecated:: 1.6.0 - The `verbosity` keyword will be removed in `v2.0.0`, set the level of `DELETE_LOGGER` instead. - - .. deprecated:: 1.6.0 - The `force` keyword will be removed in `v2.0.0`, use the `dry_run` option instead. - :param pks: a list of starting PKs of the nodes to delete (the full set will be based on the traversal rules) @@ -72,21 +60,8 @@ def delete_nodes( :returns: (pks to delete, whether they were deleted) """ - # pylint: disable=too-many-arguments,too-many-branches,too-many-locals,too-many-statements - if verbosity is not None: - warnings.warn( - 'The verbosity option is deprecated and will be removed in `aiida-core==2.0.0`. ' - 'Set the level of DELETE_LOGGER instead', AiidaDeprecationWarning - ) # pylint: disable=no-member - - if force is not None: - warnings.warn( - 'The force option is deprecated and will be removed in `aiida-core==2.0.0`. ' - 'Use dry_run instead', AiidaDeprecationWarning - ) # pylint: disable=no-member - if force is True: - dry_run = False + # pylint: disable=too-many-arguments,too-many-branches,too-many-locals,too-many-statements def _missing_callback(_pks: Iterable[int]): for _pk in _pks: diff --git a/aiida/tools/importexport/dbexport/__init__.py b/aiida/tools/importexport/dbexport/__init__.py index c8d2134428..b0a1271b2b 100644 --- a/aiida/tools/importexport/dbexport/__init__.py +++ b/aiida/tools/importexport/dbexport/__init__.py @@ -26,14 +26,11 @@ Union, cast, ) -import warnings from aiida import get_version, orm -from aiida.common.folders import Folder from aiida.common.links import GraphTraversalRules from aiida.common.lang import type_check from aiida.common.progress_reporter import get_progress_reporter, create_callback -from aiida.common.warnings import AiidaDeprecationWarning from aiida.tools.importexport.common import exceptions from aiida.tools.importexport.common.config import ( COMMENT_ENTITY_NAME, @@ -53,7 +50,6 @@ from aiida.tools.importexport.dbexport.utils import ( EXPORT_LOGGER, check_licenses, - deprecated_parameters, fill_in_query, serialize_dict, summary, @@ -67,8 +63,6 @@ def export( filename: Optional[str] = None, file_format: Union[str, Type[ArchiveWriterAbstract]] = ExportFileFormat.ZIP, overwrite: bool = False, - silent: Optional[bool] = None, - use_compression: Optional[bool] = None, include_comments: bool = True, include_logs: bool = True, allowed_licenses: Optional[Union[list, Callable]] = None, @@ -87,18 +81,6 @@ def export( set_progress_bar_tqdm(leave=True) export(...) - .. deprecated:: 1.5.0 - Support for the parameter `silent` will be removed in `v2.0.0`. - Please set the log level and progress bar implementation independently. - - .. deprecated:: 1.5.0 - Support for the parameter `use_compression` will be removed in `v2.0.0`. - Please use `writer_init={'use_compression': True}`. - - .. deprecated:: 1.2.1 - Support for the parameters `what` and `outfile` will be removed in `v2.0.0`. - Please use `entities` and `filename` instead, respectively. - :param entities: a list of entity instances; they can belong to different models/entities. @@ -145,37 +127,8 @@ def export( # pylint: disable=too-many-locals,too-many-branches,too-many-statements # Backwards-compatibility - entities = cast( - Iterable[Any], - deprecated_parameters( - old={ - 'name': 'what', - 'value': traversal_rules.pop('what', None) - }, - new={ - 'name': 'entities', - 'value': entities - }, - ), - ) - filename = cast( - str, - deprecated_parameters( - old={ - 'name': 'outfile', - 'value': traversal_rules.pop('outfile', None) - }, - new={ - 'name': 'filename', - 'value': filename - }, - ), - ) - if silent is not None: - warnings.warn( - 'silent keyword is deprecated and will be removed in AiiDA v2.0.0, set the logger level explicitly instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member + entities = cast(Iterable[Any], entities) + filename = cast(str, filename) type_check( entities, @@ -197,12 +150,6 @@ def export( # setup the archive writer writer_init = writer_init or {} - if use_compression is not None: - warnings.warn( - 'use_compression argument is deprecated and will be removed in AiiDA v2.0.0 (which will always compress)', - AiidaDeprecationWarning - ) # pylint: disable=no-member - writer_init['use_compression'] = use_compression if isinstance(file_format, str): writer = get_writer(file_format)(filepath=filename, **writer_init) elif issubclass(file_format, ArchiveWriterAbstract): @@ -664,133 +611,3 @@ def collect_hashkeys(objects): callback = create_callback(progress) container_profile.export(set(hashkeys), container_export, compress=False, callback=callback) writer.write_repository_container(container_export) - - -# THESE FUNCTIONS ARE ONLY ADDED FOR BACK-COMPATIBILITY - - -def export_tree( - entities: Optional[Iterable[Any]] = None, - folder: Optional[Folder] = None, - allowed_licenses: Optional[Union[list, Callable]] = None, - forbidden_licenses: Optional[Union[list, Callable]] = None, - silent: Optional[bool] = None, - include_comments: bool = True, - include_logs: bool = True, - **traversal_rules: bool, -) -> None: - """Export the entries passed in the 'entities' list to a file tree. - .. deprecated:: 1.2.1 - Support for the parameter `what` will be removed in `v2.0.0`. Please use `entities` instead. - :param entities: a list of entity instances; they can belong to different models/entities. - - :param folder: a temporary folder to build the archive in. - - :param allowed_licenses: List or function. If a list, then checks whether all licenses of Data nodes are in the - list. If a function, then calls function for licenses of Data nodes expecting True if license is allowed, False - otherwise. - - :param forbidden_licenses: List or function. If a list, then checks whether all licenses of Data nodes are in the - list. If a function, then calls function for licenses of Data nodes expecting True if license is allowed, False - otherwise. - - :param silent: suppress console prints and progress bar. - - :param include_comments: In-/exclude export of comments for given node(s) in ``entities``. - Default: True, *include* comments in export (as well as relevant users). - - :param include_logs: In-/exclude export of logs for given node(s) in ``entities``. - Default: True, *include* logs in export. - - :param traversal_rules: graph traversal rules. See :const:`aiida.common.links.GraphTraversalRules` what rule names - are toggleable and what the defaults are. - - :raises `~aiida.tools.importexport.common.exceptions.ArchiveExportError`: if there are any internal errors when - exporting. - :raises `~aiida.common.exceptions.LicensingException`: if any node is licensed under forbidden license. - """ - warnings.warn( - 'export_tree function is deprecated and will be removed in AiiDA v2.0.0, use `export` instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member - export( - entities=entities, - filename='none', - overwrite=True, - file_format='folder', - allowed_licenses=allowed_licenses, - forbidden_licenses=forbidden_licenses, - silent=silent, - include_comments=include_comments, - include_logs=include_logs, - writer_init={'folder': folder}, - **traversal_rules, - ) - - -def export_zip( - entities: Optional[Iterable[Any]] = None, - filename: Optional[str] = None, - use_compression: bool = True, - **kwargs: Any, -) -> Tuple[float, float]: - """Export in a zipped folder - - .. deprecated:: 1.2.1 - Support for the parameters `what` and `outfile` will be removed in `v2.0.0`. - Please use `entities` and `filename` instead, respectively. - - :param entities: a list of entity instances; they can belong to different models/entities. - - :param filename: the filename - (possibly including the absolute path) of the file on which to export. - - :param use_compression: Whether or not to compress the zip file. - - """ - warnings.warn( - 'export_zip function is deprecated and will be removed in AiiDA v2.0.0, use `export` instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member - writer = export( - entities=entities, - filename=filename, - file_format=ExportFileFormat.ZIP, - use_compression=use_compression, - **kwargs, - ) - return writer.export_info['writer_entered'], writer.export_info['writer_exited'] - - -def export_tar( - entities: Optional[Iterable[Any]] = None, - filename: Optional[str] = None, - **kwargs: Any, -) -> Tuple[float, float, float, float]: - """Export the entries passed in the 'entities' list to a gzipped tar file. - - .. deprecated:: 1.2.1 - Support for the parameters `what` and `outfile` will be removed in `v2.0.0`. - Please use `entities` and `filename` instead, respectively. - - :param entities: a list of entity instances; they can belong to different models/entities. - - :param filename: the filename (possibly including the absolute path) - of the file on which to export. - """ - warnings.warn( - 'export_tar function is deprecated and will be removed in AiiDA v2.0.0, use `export` instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member - writer = export( - entities=entities, - filename=filename, - file_format=ExportFileFormat.TAR_GZIPPED, - **kwargs, - ) - - # the tar is now directly written to, so no compression start/stop time! - return ( - writer.export_info['writer_entered'], writer.export_info['writer_exited'], writer.export_info['writer_exited'], - writer.export_info['writer_exited'] - ) diff --git a/aiida/tools/importexport/dbexport/utils.py b/aiida/tools/importexport/dbexport/utils.py index 770c9354dd..9fe94ab657 100644 --- a/aiida/tools/importexport/dbexport/utils.py +++ b/aiida/tools/importexport/dbexport/utils.py @@ -9,11 +9,8 @@ ########################################################################### """ Utility functions for export of AiiDA entities """ # pylint: disable=too-many-locals,too-many-branches,too-many-nested-blocks -import warnings - from aiida.orm import QueryBuilder, ProcessNode from aiida.common.log import AIIDA_LOGGER, LOG_LEVEL_REPORT -from aiida.common.warnings import AiidaDeprecationWarning from aiida.tools.importexport.common import exceptions from aiida.tools.importexport.common.config import ( @@ -287,25 +284,3 @@ def summary(*, file_format, export_version, outfile, include_comments, include_l result += f"\n\n{tabulate(traversal_rules, headers=['Traversal rules', ''])}\n" EXPORT_LOGGER.log(msg=result, level=LOG_LEVEL_REPORT) - - -def deprecated_parameters(old, new): - """Handle deprecated parameter (where it is replaced with another) - - :param old: The old, deprecated parameter as a dict with keys "name" and "value" - :type old: dict - - :param new: The new parameter as a dict with keys "name" and "value" - :type new: dict - - :return: New parameter's value (if not defined, then old parameter's value) - """ - if old.get('value', None) is not None: - if new.get('value', None) is not None: - message = f"`{old['name']}` is deprecated, the supplied `{new['name']}` input will be used" - else: - message = f"`{old['name']}` is deprecated, please use `{new['name']}` instead" - new['value'] = old['value'] - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - - return new['value'] diff --git a/aiida/tools/importexport/dbimport/__init__.py b/aiida/tools/importexport/dbimport/__init__.py index 0f06491122..fa90faa5cc 100644 --- a/aiida/tools/importexport/dbimport/__init__.py +++ b/aiida/tools/importexport/dbimport/__init__.py @@ -28,10 +28,6 @@ def import_data(in_path, group=None, **kwargs): set_progress_bar_tqdm(leave=True) import_data(...) - .. deprecated:: 1.5.0 - Support for the parameter `silent` will be removed in `v2.0.0`. - Please set the log level and progress bar implementation independently. - :param in_path: the path to a file or folder that can be imported in AiiDA. :type in_path: str diff --git a/aiida/tools/importexport/dbimport/backends/django.py b/aiida/tools/importexport/dbimport/backends/django.py index 9eea6d158b..70417faf4b 100644 --- a/aiida/tools/importexport/dbimport/backends/django.py +++ b/aiida/tools/importexport/dbimport/backends/django.py @@ -11,12 +11,10 @@ """ Django-specific import of AiiDA entities """ from itertools import chain from typing import Any, Dict, Iterable, List, Optional, Set, Tuple -import warnings from aiida.common.links import LinkType, validate_link_label from aiida.common.progress_reporter import get_progress_reporter from aiida.common.utils import get_object_from_string, validate_uuid -from aiida.common.warnings import AiidaDeprecationWarning from aiida.manage.configuration import get_config_option from aiida.orm import Group @@ -45,7 +43,6 @@ def import_data_dj( extras_mode_existing: str = 'kcl', extras_mode_new: str = 'import', comment_mode: str = 'newest', - silent: Optional[bool] = None, **kwargs: Any ): # pylint: disable=unused-argument """Import exported AiiDA archive to the AiiDA database and repository. @@ -101,12 +98,6 @@ def import_data_dj( created. """ # Initial check(s) - if silent is not None: - warnings.warn( - 'silent keyword is deprecated and will be removed in AiiDA v2.0.0, set the logger level explicitly instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member - if extras_mode_new not in ['import', 'none']: raise exceptions.ImportValidationError( f"Unknown extras_mode_new value: {extras_mode_new}, should be either 'import' or 'none'" diff --git a/aiida/tools/importexport/dbimport/backends/sqla.py b/aiida/tools/importexport/dbimport/backends/sqla.py index 361db8be71..190a623c83 100644 --- a/aiida/tools/importexport/dbimport/backends/sqla.py +++ b/aiida/tools/importexport/dbimport/backends/sqla.py @@ -12,7 +12,6 @@ from contextlib import contextmanager from itertools import chain from typing import Any, Dict, Iterable, List, Optional, Set, Tuple -import warnings from sqlalchemy.orm import Session @@ -20,7 +19,6 @@ from aiida.common.links import LinkType from aiida.common.progress_reporter import get_progress_reporter from aiida.common.utils import get_object_from_string, validate_uuid -from aiida.common.warnings import AiidaDeprecationWarning from aiida.orm import QueryBuilder, Node, Group from aiida.orm.utils.links import link_triple_exists, validate_link @@ -51,7 +49,6 @@ def import_data_sqla( extras_mode_existing: str = 'kcl', extras_mode_new: str = 'import', comment_mode: str = 'newest', - silent: Optional[bool] = None, **kwargs: Any ): # pylint: disable=unused-argument """Import exported AiiDA archive to the AiiDA database and repository. @@ -110,12 +107,6 @@ def import_data_sqla( created. """ # Initial check(s) - if silent is not None: - warnings.warn( - 'silent keyword is deprecated and will be removed in AiiDA v2.0.0, set the logger level explicitly instead', - AiidaDeprecationWarning - ) # pylint: disable=no-member - if extras_mode_new not in ['import', 'none']: raise exceptions.ImportValidationError( f"Unknown extras_mode_new value: {extras_mode_new}, should be either 'import' or 'none'" diff --git a/aiida/tools/visualization/graph.py b/aiida/tools/visualization/graph.py index 648ea9cf11..776c0c7342 100644 --- a/aiida/tools/visualization/graph.py +++ b/aiida/tools/visualization/graph.py @@ -634,7 +634,6 @@ def recurse_descendants( origin_style=MappingProxyType(_OVERRIDE_STYLES_DICT['origin_node']), include_process_inputs=False, highlight_classes=None, - print_func=None ): """add nodes and edges from an origin recursively, following outgoing links @@ -654,19 +653,8 @@ def recurse_descendants( :param highlight_classes: target class in exported graph expected to be highlight and other nodes are decolorized (Default value = None) :typle highlight_classes: tuple of class or class - :param print_func: - a function to stream information to, i.e. print_func(str) - (this feature is deprecated since `v1.1.0` and will be removed in `v2.0.0`) - """ # pylint: disable=too-many-arguments,too-many-locals - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - if print_func: - warnings.warn( # pylint: disable=no-member - '`print_func` is deprecated because graph traversal has been refactored', AiidaDeprecationWarning - ) - # Get graph traversal rules where the given link types and direction are all set to True, # and all others are set to False origin_pk = self._load_node(origin).pk @@ -737,7 +725,6 @@ def recurse_ancestors( origin_style=MappingProxyType(_OVERRIDE_STYLES_DICT['origin_node']), include_process_outputs=False, highlight_classes=None, - print_func=None ): """add nodes and edges from an origin recursively, following incoming links @@ -757,19 +744,8 @@ def recurse_ancestors( :param highlight_classes: class label (as displayed in the graph, e.g. 'StructureData', 'FolderData', etc.) to be highlight and other nodes are decolorized (Default value = None) :typle highlight_classes: list or tuple of str - :param print_func: a function to stream information to, i.e. print_func(str) - - .. deprecated:: 1.1.0 - `print_func` will be removed in `v2.0.0` """ # pylint: disable=too-many-arguments,too-many-locals - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - if print_func: - warnings.warn( # pylint: disable=no-member - '`print_func` is deprecated because graph traversal has been refactored', AiidaDeprecationWarning - ) - # Get graph traversal rules where the given link types and direction are all set to True, # and all others are set to False origin_pk = self._load_node(origin).pk diff --git a/aiida/transports/transport.py b/aiida/transports/transport.py index 54bcf7f9d1..9b8ad0a51a 100644 --- a/aiida/transports/transport.py +++ b/aiida/transports/transport.py @@ -186,21 +186,6 @@ def get_short_doc(cls): return doclines[0].strip() return 'No documentation available' - @classmethod - def get_valid_transports(cls): - """Return the list of registered transport entry points. - - .. deprecated:: 1.4.0 - - Will be removed in `2.0.0`, use `aiida.plugins.entry_point.get_entry_point_names` instead - """ - import warnings - from aiida.common.warnings import AiidaDeprecationWarning - from aiida.plugins.entry_point import get_entry_point_names - message = 'method is deprecated, use `aiida.plugins.entry_point.get_entry_point_names` instead' - warnings.warn(message, AiidaDeprecationWarning) # pylint: disable=no-member - return get_entry_point_names('aiida.transports') - @classmethod def get_valid_auth_params(cls): """ diff --git a/docs/source/howto/data.rst b/docs/source/howto/data.rst index f0bfdd18eb..acd5654e67 100644 --- a/docs/source/howto/data.rst +++ b/docs/source/howto/data.rst @@ -11,7 +11,7 @@ Importing data ============== AiiDA allows users to export data from their database into an export archive file, which can be imported into any other AiiDA database. -If you have an AiiDA export archive that you would like to import, you can use the ``verdi archive import`` command (see :ref:`the reference section` for details). +If you have an AiiDA export archive that you would like to import, you can use the ``verdi archive import`` command (see :ref:`the reference section` for details). .. note:: For information on exporting and importing data via AiiDA archives, see :ref:`"How to share data"`. diff --git a/docs/source/internals/includes/data.json b/docs/source/internals/includes/data.json index 76aeb2147e..0b0c27ebbc 100644 --- a/docs/source/internals/includes/data.json +++ b/docs/source/internals/includes/data.json @@ -111,7 +111,6 @@ "remote_workdir": "/scratch/aiida/aiida_run/10/24/e35e-166b-4104-95f6-c1706df4ce15", "process_state": "finished", "max_wallclock_seconds": 900, - "retrieve_singlefile_list": [], "scheduler_lastchecktime": "2015-10-02T20:30:36.481951+00:00", "job_id": "13489", "exit_status": 0, diff --git a/docs/source/reference/command_line.rst b/docs/source/reference/command_line.rst index 4714943104..241ad1a04a 100644 --- a/docs/source/reference/command_line.rst +++ b/docs/source/reference/command_line.rst @@ -248,48 +248,9 @@ Below is a list with all available subcommands. check-load-time Check for common indicators that slowdown `verdi`. check-undesired-imports Check that verdi does not import python modules it shouldn't. run_daemon Run a daemon instance in the current interpreter. - tests Run the unittest suite or parts of it. validate-plugins Validate all plugins by checking they can be loaded. -.. _reference:command-line:verdi-export: - -``verdi export`` ----------------- - -.. code:: console - - Usage: [OPTIONS] COMMAND [ARGS]... - - Deprecated, use `verdi archive`. - - Options: - --help Show this message and exit. - - Commands: - create Export subsets of the provenance graph to file for sharing. - inspect Inspect contents of an exported archive without importing it. - migrate Migrate an export archive to a more recent format version. - - -.. _reference:command-line:verdi-graph: - -``verdi graph`` ---------------- - -.. code:: console - - Usage: [OPTIONS] COMMAND [ARGS]... - - Create visual representations of the provenance graph. - - Options: - --help Show this message and exit. - - Commands: - generate Generate a graph from a ROOT_NODE (specified by pk or uuid). - - .. _reference:command-line:verdi-group: ``verdi group`` @@ -332,59 +293,6 @@ Below is a list with all available subcommands. --help Show this message and exit. -.. _reference:command-line:verdi-import: - -``verdi import`` ----------------- - -.. code:: console - - Usage: [OPTIONS] [--] [ARCHIVES]... - - Deprecated, use `verdi archive import`. - - Options: - -w, --webpages TEXT... Discover all URL targets pointing to files with the - .aiida extension for these HTTP addresses. Automatically - discovered archive URLs will be downloaded and added to - ARCHIVES for importing - - -G, --group GROUP Specify group to which all the import nodes will be - added. If such a group does not exist, it will be - created automatically. - - -e, --extras-mode-existing [keep_existing|update_existing|mirror|none|ask] - Specify which extras from the export archive should be - imported for nodes that are already contained in the - database: ask: import all extras and prompt what to do - for existing extras. keep_existing: import all extras - and keep original value of existing extras. - update_existing: import all extras and overwrite value - of existing extras. mirror: import all extras and remove - any existing extras that are not present in the archive. - none: do not import any extras. - - -n, --extras-mode-new [import|none] - Specify whether to import extras of new nodes: import: - import extras. none: do not import extras. - - --comment-mode [newest|overwrite] - Specify the way to import Comments with identical UUIDs: - newest: Only the newest Comments (based on mtime) - (default).overwrite: Replace existing Comments with - those from the import file. - - --migration / --no-migration Force migration of archive file archives, if needed. - [default: True] - - -v, --verbosity [DEBUG|INFO|WARNING|CRITICAL] - Control the verbosity of console logging - -n, --non-interactive In non-interactive mode, the CLI never prompts but - simply uses default values for options that define one. - - --help Show this message and exit. - - .. _reference:command-line:verdi-node: ``verdi node`` @@ -410,7 +318,6 @@ Below is a list with all available subcommands. rehash Recompute the hash for nodes in the database. repo Inspect the content of a node repository folder. show Show generic information on one or more nodes. - tree Show a tree of nodes starting from a given node. .. _reference:command-line:verdi-plugin: @@ -604,10 +511,6 @@ Below is a list with all available subcommands. (numbers might be automatically appended to generate unique names per run). - -n, --group-name TEXT Specify the name of the auto group [DEPRECATED, USE - --auto-group-label-prefix instead]. This also enables - auto-grouping. - -e, --exclude TEXT Exclude these classes from auto grouping (use full entrypoint strings). diff --git a/tests/cmdline/commands/test_archive_export.py b/tests/cmdline/commands/test_archive_export.py index 3f0e9bdb6a..f099ac318e 100644 --- a/tests/cmdline/commands/test_archive_export.py +++ b/tests/cmdline/commands/test_archive_export.py @@ -40,14 +40,6 @@ def delete_temporary_file(filepath): pass -def test_cmd_export_deprecation(): - """Test that the deprecated `verdi export` commands can still be called.""" - from aiida.cmdline.commands import cmd_export - for command in [cmd_export.inspect, cmd_export.create, cmd_export.migrate]: - result = CliRunner().invoke(command, '--help') - assert result.exit_code == 0 - - class TestVerdiExport(AiidaTestCase): """Tests for `verdi export`.""" @@ -285,11 +277,10 @@ def test_inspect(self): filename_input = get_archive_file(archive, filepath=self.fixture_archive) - # Testing the options that will print the meta data and data respectively - for option in ['-m', '-d']: - options = [option, filename_input] - result = self.cli_runner.invoke(cmd_archive.inspect, options) - self.assertIsNone(result.exception, result.output) + # Test the options that will print the meta data + options = ['-m', filename_input] + result = self.cli_runner.invoke(cmd_archive.inspect, options) + self.assertIsNone(result.exception, result.output) # Test the --version option which should print the archive format version options = ['--version', filename_input] diff --git a/tests/cmdline/commands/test_archive_import.py b/tests/cmdline/commands/test_archive_import.py index 7523a0cacf..60a530c992 100644 --- a/tests/cmdline/commands/test_archive_import.py +++ b/tests/cmdline/commands/test_archive_import.py @@ -21,13 +21,6 @@ from tests.utils.archives import get_archive_file -def test_cmd_import_deprecation(): - """Test that the deprecated `verdi import` command can still be called.""" - from aiida.cmdline.commands import cmd_import - result = CliRunner().invoke(cmd_import.cmd_import, '--help') - assert result.exit_code == 0 - - class TestVerdiImport(AiidaTestCase): """Tests for `verdi import`.""" diff --git a/tests/cmdline/commands/test_graph.py b/tests/cmdline/commands/test_graph.py deleted file mode 100644 index f9054943e3..0000000000 --- a/tests/cmdline/commands/test_graph.py +++ /dev/null @@ -1,209 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Tests for verdi graph""" - -import errno -import os -import tempfile - -from click.testing import CliRunner - -from aiida.backends.testbase import AiidaTestCase -from aiida.cmdline.commands import cmd_graph - - -def delete_temporary_file(filepath): - """ - Attempt to delete a file, given an absolute path. If the deletion fails because the file does not exist - the exception will be caught and passed. Any other exceptions will raise. - - :param filepath: the absolute file path - """ - try: - os.remove(filepath) - except OSError as exception: - if exception.errno != errno.ENOENT: - raise - else: - pass - - -class TestVerdiGraph(AiidaTestCase): - """Tests for verdi graph""" - - @classmethod - def setUpClass(cls): - super().setUpClass() - from aiida.orm import Data - - cls.node = Data().store() - - # some of the export tests write in the current directory, - # make sure it is writeable and we don't pollute the current one - cls.old_cwd = os.getcwd() - cls.cwd = tempfile.mkdtemp(__name__) - os.chdir(cls.cwd) - - @classmethod - def tearDownClass(cls): - os.chdir(cls.old_cwd) - os.rmdir(cls.cwd) - - def setUp(self): - self.cli_runner = CliRunner() - - def test_generate_graph(self): - """ - Test that the default graph can be generated - The command should run without error and should produce the .dot file - """ - # Get a PK of a node which exists - root_node = str(self.node.pk) - filename = f'{root_node}.dot.pdf' - options = [root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - def test_catch_bad_pk(self): - """ - Test that an invalid root_node pk (non-numeric, negative, or decimal), - or non-existent pk will produce an error - """ - from aiida.orm import load_node - from aiida.common.exceptions import NotExistent - - # Forbidden pk - for root_node in ['xyz', '-5', '3.14']: - options = [root_node] - filename = f'{root_node}.dot.pdf' - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNotNone(result.exception) - self.assertFalse(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - # Non-existant pk - - # Check that an arbitrary pk definately can't be loaded - root_node = 123456789 - try: - node = load_node(pk=root_node) - self.assertIsNone(node) - except NotExistent: - pass - # Make sure verdi graph rejects this non-existant pk - try: - filename = f'{str(root_node)}.dot.pdf' - options = [str(root_node)] - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNotNone(result.exception) - self.assertFalse(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - def test_check_recursion_flags(self): - """ - Test the ancestor-depth and descendent-depth options. - Test that they don't fail and that, if specified, they only accept - positive ints - """ - root_node = str(self.node.pk) - filename = f'{root_node}.dot.pdf' - - # Test that the options don't fail - for opt in ['-a', '--ancestor-depth', '-d', '--descendant-depth']: - options = [opt, None, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - # Test that the options accept zero or a positive int - for opt in ['-a', '--ancestor-depth', '-d', '--descendant-depth']: - for value in ['0', '1']: - options = [opt, value, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - # Check the options reject any values that are not positive ints - for flag in ['-a', '--ancestor-depth', '-d', '--descendant-depth']: - for badvalue in ['xyz', '3.14', '-5']: - options = [flag, badvalue, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNotNone(result.exception) - self.assertFalse(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - def test_check_io_flags(self): - """ - Test the input and output flags work. - """ - root_node = str(self.node.pk) - filename = f'{root_node}.dot.pdf' - - for flag in ['-i', '--process-in', '-o', '--process-out']: - options = [flag, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - def test_output_format(self): - """ - Test that the output file format can be specified - """ - root_node = str(self.node.pk) - - for option in ['-f', '--output-format']: - - # Test different formats. Could exhaustively test the formats - # supported on a given OS (printed by '$ dot -T?') but here - # we just use the built-ins dot and canon as a minimal check that - # the option works. After all, this test is for the cmdline. - for fileformat in ['pdf', 'png']: - filename = f'{root_node}.dot.{fileformat}' - options = [option, fileformat, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) - - def test_node_id_label_format(self): - """ - Test that the node id label format can be specified - """ - root_node = str(self.node.pk) - filename = f'{root_node}.dot.pdf' - - for id_label_type in ['uuid', 'pk', 'label']: - options = ['--identifier', id_label_type, root_node] - try: - result = self.cli_runner.invoke(cmd_graph.generate, options) - self.assertIsNone(result.exception, result.output) - self.assertTrue(os.path.isfile(filename)) - finally: - delete_temporary_file(filename) diff --git a/tests/cmdline/commands/test_node.py b/tests/cmdline/commands/test_node.py index b843e19178..f651f603b7 100644 --- a/tests/cmdline/commands/test_node.py +++ b/tests/cmdline/commands/test_node.py @@ -8,22 +8,18 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Tests for verdi node""" - import os import io import errno import pathlib import tempfile import gzip -import warnings from click.testing import CliRunner from aiida import orm from aiida.backends.testbase import AiidaTestCase from aiida.cmdline.commands import cmd_node -from aiida.common.utils import Capturing -from aiida.common.warnings import AiidaDeprecationWarning def get_result_lines(result): @@ -75,30 +71,6 @@ def get_unstored_folder_node(cls): folder_node.put_object_from_filelike(io.StringIO(cls.content_file2), cls.key_file2) return folder_node - def test_node_tree(self): - """Test `verdi node tree`""" - options = [str(self.node.pk)] - - # This command (and so the test as well) will go away in 2.0 - # Note: I cannot use simply pytest.mark.filterwarnings as below, as the warning is issued in an invoked command - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', category=AiidaDeprecationWarning) - result = self.cli_runner.invoke(cmd_node.tree, options) - self.assertClickResultNoException(result) - - # This command (and so this test as well) will go away in 2.0 - def test_node_tree_printer(self): - """Test the `NodeTreePrinter` utility.""" - from aiida.cmdline.utils.ascii_vis import NodeTreePrinter - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', category=AiidaDeprecationWarning) - - with Capturing(): - NodeTreePrinter.print_node_tree(self.node, max_depth=1) - - with Capturing(): - NodeTreePrinter.print_node_tree(self.node, max_depth=1, follow_links=()) - def test_node_show(self): """Test `verdi node show`""" node = orm.Data().store() @@ -111,7 +83,7 @@ def test_node_show(self): self.assertIn(node.label, result.output) self.assertIn(node.uuid, result.output) - ## Let's now test the '--print-groups' option + # Let's now test the '--print-groups' option options.append('--print-groups') result = self.cli_runner.invoke(cmd_node.node_show, options) self.assertClickResultNoException(result) diff --git a/tests/cmdline/commands/test_run.py b/tests/cmdline/commands/test_run.py index 5e1c49e867..2d71f821cb 100644 --- a/tests/cmdline/commands/test_run.py +++ b/tests/cmdline/commands/test_run.py @@ -10,7 +10,6 @@ """Tests for `verdi run`.""" import tempfile import textwrap -import warnings from click.testing import CliRunner import pytest @@ -401,44 +400,3 @@ def test_autogroup_clashing_label(self): len(all_auto_groups), 1, 'There should be only one autogroup associated with the node just created' ) self.assertTrue(all_auto_groups[0][0].label.startswith(autogroup_label)) - - def test_legacy_autogroup_name(self): - """Check if the autogroup is properly generated when using the legacy --group-name flag.""" - from aiida.orm import QueryBuilder, Node, AutoGroup, load_node - - script_content = textwrap.dedent( - """\ - from aiida.orm import Data - node = Data().store() - print(node.pk) - """ - ) - group_label = 'legacy-group-name' - - with tempfile.NamedTemporaryFile(mode='w+') as fhandle: - fhandle.write(script_content) - fhandle.flush() - - options = ['--group-name', group_label, fhandle.name] - with warnings.catch_warnings(record=True) as warns: # pylint: disable=no-member - result = self.cli_runner.invoke(cmd_run.run, options) - self.assertTrue( - any(['use `--auto-group-label-prefix` instead' in str(warn.message) for warn in warns]), - "No warning for '--group-name' was raised" - ) - - self.assertClickResultNoException(result) - - pk = int(result.output) - _ = load_node(pk) # Check if the node can be loaded - - queryb = QueryBuilder().append(Node, filters={'id': pk}, tag='node') - queryb.append(AutoGroup, with_node='node', project='*') - all_auto_groups = queryb.all() - self.assertEqual( - len(all_auto_groups), 1, 'There should be only one autogroup associated with the node just created' - ) - self.assertEqual( - all_auto_groups[0][0].label, group_label, - f'The auto group label is "{all_auto_groups[0][0].label}" instead of "{group_label}"' - ) diff --git a/tests/orm/data/test_code.py b/tests/orm/data/test_code.py deleted file mode 100644 index 515f7eaa8d..0000000000 --- a/tests/orm/data/test_code.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Tests for the `Code` class.""" -# pylint: disable=redefined-outer-name -import warnings - -import pytest - -from aiida.common.warnings import AiidaDeprecationWarning -from aiida.orm import Code - - -@pytest.fixture -def create_codes(tmpdir, aiida_localhost): - """Create a local and remote `Code` instance.""" - filename = 'add.sh' - filepath = tmpdir / filename - - with open(filepath, 'w'): - pass - - code_local = Code(local_executable=filename, files=[filepath]).store() - code_remote = Code(remote_computer_exec=(aiida_localhost, '/bin/true')).store() - - return code_local, code_remote - - -@pytest.mark.usefixtures('clear_database_before_test') -def test_get_full_text_info(create_codes): - """Test the `Code.get_full_text_info` method.""" - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', category=AiidaDeprecationWarning) - - for code in create_codes: - full_text_info = code.get_full_text_info() - - assert isinstance(full_text_info, list) - assert ['PK', code.pk] in full_text_info - assert ['UUID', code.uuid] in full_text_info - assert ['Label', code.label] in full_text_info - assert ['Description', code.description] in full_text_info - - if code.is_local(): - assert ['Type', 'local'] in full_text_info - assert ['Exec name', code.get_execname()] in full_text_info - assert ['List of files/folders:', ''] in full_text_info - else: - assert ['Type', 'remote'] in full_text_info - assert ['Remote machine', code.computer.label] in full_text_info - assert ['Remote absolute path', code.get_remote_exec_path()] in full_text_info - - for code in create_codes: - full_text_info = code.get_full_text_info(verbose=True) - assert ['Calculations', 0] in full_text_info diff --git a/tests/orm/test_groups.py b/tests/orm/test_groups.py index 342806331a..5c349ced9a 100644 --- a/tests/orm/test_groups.py +++ b/tests/orm/test_groups.py @@ -347,39 +347,6 @@ def test_loading_unregistered(): del group orm.Group.objects.delete(id=group_pk) - @staticmethod - @pytest.mark.filterwarnings('ignore::UserWarning') - def test_explicit_type_string(): - """Test that passing explicit `type_string` to `Group` constructor is still possible despite being deprecated. - - Both constructing a group while passing explicit `type_string` as well as loading a group with unregistered - type string should emit a warning, but it should be possible. - """ - type_string = 'data.potcar' # An unregistered custom type string - - with pytest.warns(UserWarning): - group = orm.Group(label='group', type_string=type_string) - - group.store() - assert group.type_string == type_string - - with pytest.warns(UserWarning): - loaded = orm.Group.get(label=group.label, type_string=type_string) - - assert isinstance(loaded, orm.Group) - assert loaded.pk == group.pk - assert loaded.type_string == group.type_string - - queried = orm.QueryBuilder().append(orm.Group, filters={'id': group.pk, 'type_string': type_string}).one()[0] - assert isinstance(queried, orm.Group) - assert queried.pk == group.pk - assert queried.type_string == group.type_string - - # Removing it as other methods might get a warning instead - group_pk = group.pk - del group - orm.Group.objects.delete(id=group_pk) - @staticmethod def test_querying(): """Test querying for groups with and without subclassing.""" diff --git a/tests/tools/importexport/test_deprecation.py b/tests/tools/importexport/test_deprecation.py deleted file mode 100644 index 05bbeed68b..0000000000 --- a/tests/tools/importexport/test_deprecation.py +++ /dev/null @@ -1,89 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -"""Test deprecated parts still work and emit deprecations warnings""" -# pylint: disable=invalid-name -import os -import warnings - -import pytest - -from aiida.common.warnings import AiidaDeprecationWarning -from aiida.tools.importexport import dbexport - -pytestmark = pytest.mark.usefixtures('clear_database_before_test') - - -def test_export_functions(temp_dir): - """Check `what` and `outfile` in export(), export_tar() and export_zip()""" - with warnings.catch_warnings(): # To avoid printing them in output (pytest.mark.filterwarnings does not work) - warnings.filterwarnings('ignore', category=AiidaDeprecationWarning) - what = [] - outfile = os.path.join(temp_dir, 'deprecated.aiida') - - for export_function in (dbexport.export, dbexport.export_tar, dbexport.export_zip): - if os.path.exists(outfile): - os.remove(outfile) - with pytest.warns(AiidaDeprecationWarning, match='`what` is deprecated, please use `entities` instead'): - export_function(what=what, filename=outfile) - - if os.path.exists(outfile): - os.remove(outfile) - with pytest.warns( - AiidaDeprecationWarning, match='`what` is deprecated, the supplied `entities` input will be used' - ): - export_function(entities=what, what=what, filename=outfile) - - if os.path.exists(outfile): - os.remove(outfile) - with pytest.warns( - AiidaDeprecationWarning, - match='`outfile` is deprecated, please use `filename` instead', - ): - export_function(what, outfile=outfile) - - if os.path.exists(outfile): - os.remove(outfile) - with pytest.warns( - AiidaDeprecationWarning, match='`outfile` is deprecated, the supplied `filename` input will be used' - ): - export_function(what, filename=outfile, outfile=outfile) - - if os.path.exists(outfile): - os.remove(outfile) - with pytest.raises(TypeError, match='`entities` must be specified'): - export_function(filename=outfile) - - -def test_export_tree(): - """Check `what` in export_tree()""" - from aiida.common.folders import SandboxFolder - - with warnings.catch_warnings(): # To avoid printing them in output (pytest.mark.filterwarnings does not work) - warnings.filterwarnings('ignore', category=AiidaDeprecationWarning) - - what = [] - - with SandboxFolder() as folder: - with pytest.warns(AiidaDeprecationWarning, match='`what` is deprecated, please use `entities` instead'): - dbexport.export_tree(what=what, folder=folder) - - folder.erase(create_empty_folder=True) - with pytest.warns( - AiidaDeprecationWarning, match='`what` is deprecated, the supplied `entities` input will be used' - ): - dbexport.export_tree(entities=what, what=what, folder=folder) - - folder.erase(create_empty_folder=True) - with pytest.raises(TypeError, match='`entities` must be specified'): - dbexport.export_tree(folder=folder) - - folder.erase(create_empty_folder=True) - with pytest.raises(TypeError, match='`folder` must be specified'): - dbexport.export_tree(entities=what)