Skip to content

Commit

Permalink
Merge develop into provenance_redesign and update pre-commit depe…
Browse files Browse the repository at this point in the history
…ndencies
  • Loading branch information
sphuber committed Jan 4, 2019
2 parents a4bbfd1 + 6424ba1 commit 097fa6a
Show file tree
Hide file tree
Showing 131 changed files with 386 additions and 402 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=bad-continuation,locally-disabled,useless-suppression,django-not-available
disable=bad-continuation,locally-disabled,useless-suppression,django-not-available,bad-option-value

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ install:
- pip install -U pip wheel setuptools
- pip install coveralls
# Install AiiDA with some optional dependencies
- if [ "$TEST_TYPE" == "docs" ]; then pip install . && pip install -r docs/requirements_for_rtd.txt; else pip install .[all]; fi
- if [ "$TEST_TYPE" == "docs" ]; then pip install . && pip install -r docs/requirements_for_rtd.txt; else pip install --no-cache-dir .[all]; fi

env:
## Build matrix to test both backends, and the docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def detect_unexpected_links(apps, schema_editor):

def reverse_code(apps, schema_editor):
"""Reversing the inference of the process type is not possible and not necessary."""
pass


class Migration(migrations.Migration):
Expand Down
1 change: 1 addition & 0 deletions aiida/backends/djsite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def check_schema_version(profile_name=None):
:raise ConfigurationError: if the two schema versions do not match.
Otherwise, just return.
"""
# pylint: disable=duplicate-string-formatting-argument
from django.db import connection

import aiida.backends.djsite.db.models
Expand Down
2 changes: 2 additions & 0 deletions aiida/backends/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
'cmdline.commands.profile': ['aiida.backends.tests.cmdline.commands.test_profile'],
'cmdline.commands.rehash': ['aiida.backends.tests.cmdline.commands.test_rehash'],
'cmdline.commands.run': ['aiida.backends.tests.cmdline.commands.test_run'],
'cmdline.commands.setup': ['aiida.backends.tests.cmdline.commands.test_setup'],
'cmdline.commands.user': ['aiida.backends.tests.cmdline.commands.test_user'],
'cmdline.commands.verdi': ['aiida.backends.tests.cmdline.commands.test_verdi'],
'cmdline.commands.work': ['aiida.backends.tests.cmdline.commands.test_work'],
'cmdline.commands.workflow': ['aiida.backends.tests.cmdline.commands.test_workflow'],
'cmdline.params.types.calculation': ['aiida.backends.tests.cmdline.params.types.test_calculation'],
Expand Down
13 changes: 13 additions & 0 deletions aiida/backends/tests/calculation_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class TestProcessNode(AiidaTestCase):
@classmethod
def setUpClass(cls, *args, **kwargs):
super(TestProcessNode, cls).setUpClass(*args, **kwargs)
cls.computer.configure() # pylint: disable=no-member
cls.construction_options = {'resources': {'num_machines': 1, 'num_mpiprocs_per_machine': 1}}

cls.calcjob = CalcJobNode()
Expand Down Expand Up @@ -147,3 +148,15 @@ def test_calcjob_get_options_defaults(self):

def test_get_description(self):
self.assertEqual(self.calcjob.get_desc(), self.calcjob.get_state())

def test_get_authinfo(self):
"""Test that we can get the AuthInfo object from the calculation instance."""
from aiida.orm import AuthInfo
authinfo = self.calcjob._get_authinfo() # pylint: disable=protected-access
self.assertIsInstance(authinfo, AuthInfo)

def test_get_transport(self):
"""Test that we can get the Transport object from the calculation instance."""
from aiida.transport import Transport
transport = self.calcjob._get_transport() # pylint: disable=protected-access
self.assertIsInstance(transport, Transport)
1 change: 1 addition & 0 deletions aiida/backends/tests/cmdline/commands/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TestVerdiRun(AiidaTestCase):
"""Tests for `verdi run`."""

def setUp(self):
super(TestVerdiRun, self).setUp()
self.cli_runner = CliRunner()

def test_run_workfunction(self):
Expand Down
74 changes: 74 additions & 0 deletions aiida/backends/tests/cmdline/commands/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- 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 setup`."""
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

from click.testing import CliRunner

from aiida.backends import settings
from aiida.backends.testbase import AiidaTestCase
from aiida.backends.tests.utils.configuration import with_temporary_config_instance
from aiida.cmdline.commands import cmd_setup
from aiida.manage import get_config


class TestVerdiSetup(AiidaTestCase):
"""Tests for `verdi setup`."""

def setUp(self):
"""Create runner object to run tests."""
self.cli_runner = CliRunner()

@with_temporary_config_instance
def test_non_interactive_override(self):
"""Tests that existing profile can be overridden in non-interactive mode with the `--force` option."""
config = get_config()
profile = config.current_profile

option_string = '--backend={backend} --email={email} --repository={repo} --db-host={db_host} ' \
'--db-port={db_port} --db-name={db_name} --db-username={db_user} --db-password={db_pass} ' \
'--first-name={first} --last-name={last} --institution={institution}'

profile_settings = {
'email': profile.dictionary['default_user_email'],
'backend': profile.dictionary['AIIDADB_BACKEND'],
'db_host': profile.dictionary['AIIDADB_HOST'],
'db_port': profile.dictionary['AIIDADB_PORT'],
'db_name': profile.dictionary['AIIDADB_NAME'],
'db_user': profile.dictionary['AIIDADB_USER'],
'db_pass': profile.dictionary['AIIDADB_PASS'],
'repo': '/tmp',
'first': 'nim',
'last': 'porte',
'institution': 'quoi',
}

options = ['--non-interactive'] + option_string.format(**profile_settings).split()

# Without profile name should raise exception
result = self.cli_runner.invoke(cmd_setup.setup, options)
self.assertIsNotNone(result.exception)
self.assertIn('Missing argument', result.output)
self.assertIn('profile_name', result.output)

# With existing profile name should raise exception
options.append(profile.name)
result = self.cli_runner.invoke(cmd_setup.setup, options)
self.assertIsNotNone(result.exception, result.output)

# Need to set the current profile to None again, otherwise it will complain that `verdi` is using `-p` flag
settings.AIIDADB_PROFILE = None

# Adding the `--force` option should allow it
options.append('--force')
result = self.cli_runner.invoke(cmd_setup.setup, options)
self.assertIsNone(result.exception, result.output)
32 changes: 32 additions & 0 deletions aiida/backends/tests/cmdline/commands/test_verdi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- 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`."""
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from click.testing import CliRunner

from aiida import get_version
from aiida.backends.testbase import AiidaTestCase
from aiida.cmdline.commands import cmd_verdi


class TestVerdi(AiidaTestCase):
"""Tests for `verdi run`."""

def setUp(self):
super(TestVerdi, self).setUp()
self.cli_runner = CliRunner()

def test_verdi_version(self):
"""Regression test for #2238: verify that `verdi --version` prints the current version"""
result = self.cli_runner.invoke(cmd_verdi.verdi, ['--version'])
self.assertIsNone(result.exception, result.output)
self.assertIn(get_version(), result.output)
2 changes: 1 addition & 1 deletion aiida/backends/tests/common/test_hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_numpy_arrays(self):

def test_unhashable_type(self):

class MadeupClass(object):
class MadeupClass(object): # pylint: disable=useless-object-inheritance
pass

with self.assertRaises(ValueError):
Expand Down
6 changes: 3 additions & 3 deletions aiida/backends/tests/orm/node/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_node_indegree_unique_pair(self):
called.add_incoming(data, link_type=LinkType.INPUT_CALC, link_label='call')
called.store()

uuids_incoming = set([node.uuid for node in called.get_incoming().all_nodes()])
uuids_incoming = set(node.uuid for node in called.get_incoming().all_nodes())
uuids_expected = set([caller.uuid, data.uuid])
self.assertEqual(uuids_incoming, uuids_expected)

Expand All @@ -232,7 +232,7 @@ def test_node_indegree_unique_triple(self):
data.add_incoming(return_two, link_type=LinkType.RETURN, link_label='return')
data.store()

uuids_incoming = set([node.uuid for node in data.get_incoming().all_nodes()])
uuids_incoming = set(node.uuid for node in data.get_incoming().all_nodes())
uuids_expected = set([return_one.uuid, return_two.uuid])
self.assertEqual(uuids_incoming, uuids_expected)

Expand All @@ -253,6 +253,6 @@ def test_node_outdegree_unique_triple(self):
data_one.store()
data_two.store()

uuids_outgoing = set([node.uuid for node in creator.get_outgoing().all_nodes()])
uuids_outgoing = set(node.uuid for node in creator.get_outgoing().all_nodes())
uuids_expected = set([data_one.uuid, data_two.uuid])
self.assertEqual(uuids_outgoing, uuids_expected)
2 changes: 0 additions & 2 deletions aiida/backends/tests/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ def test_computers_orderby_mixed3(self):
-hostname",
expected_list_ids=[1,0,4,3,2])
"""
pass

############### list filter combinations #######################
def test_computers_filter_mixed1(self):
Expand Down Expand Up @@ -675,7 +674,6 @@ def test_computers_unknown_param(self):
from aiida.common.exceptions import InputValidationError
RESTApiTestCase.node_exception(self, "/computers?aa=bb&id=2", InputValidationError)
"""
pass

############### single calculation ########################
def test_calculations_details(self):
Expand Down
2 changes: 1 addition & 1 deletion aiida/calculations/plugins/arithmetic/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _use_methods(cls):

def _get_input_valid_types(self, key):
"""Return the valid input types for the given key."""
return self._use_methods[key]['valid_types']
return self._use_methods[key]['valid_types'] # pylint: disable=unsubscriptable-object

def _get_input_valid_type(self, key):
"""Return the valid input type for the given key."""
Expand Down
2 changes: 1 addition & 1 deletion aiida/calculations/plugins/templatereplacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _prepare_for_submission(self, tempfolder, inputdict):
:param inputdict: a dictionary with the input nodes e.g. {label1: node1, ...} (with the Code!)
"""
# pylint: disable=too-many-locals,too-many-statements,too-many-branches
from six.moves import StringIO as StringIO
from six.moves import StringIO

from aiida.orm.data.singlefile import SinglefileData
from aiida.orm.data.remote import RemoteData
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@verdi.group('calcjob')
def verdi_calcjob():
"""Inspect and manage calcjobs."""
pass


@verdi_calcjob.command('gotocomputer')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@verdi.group('calculation')
def verdi_calculation():
"""Inspect and manage calculations."""
pass


@verdi_calculation.command('gotocomputer')
Expand Down
2 changes: 0 additions & 2 deletions aiida/cmdline/commands/cmd_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@verdi.group('code')
def verdi_code():
"""Setup and manage codes."""
pass


def get_default(key, ctx):
Expand Down Expand Up @@ -215,7 +214,6 @@ def reveal(codes):
# pylint: disable=unused-argument
def update(code):
"""Update an existing code."""
pass


@verdi_code.command()
Expand Down
3 changes: 1 addition & 2 deletions aiida/cmdline/commands/cmd_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@verdi.group('comment')
def verdi_comment():
"""Inspect, create and manage node comments."""
pass


@verdi_comment.command()
Expand Down Expand Up @@ -76,7 +75,7 @@ def show(user, nodes):
comments = [comment for comment in all_comments if comment.user.email == user.email]

if not comments:
valid_users = ', '.join(set([comment.user.email for comment in all_comments]))
valid_users = ', '.join(set(comment.user.email for comment in all_comments))
echo.echo_warning('no comments found for user {}'.format(user))
echo.echo_info('valid users found for Node<{}>: {}'.format(node.pk, valid_users))

Expand Down
10 changes: 4 additions & 6 deletions aiida/cmdline/commands/cmd_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
@verdi.group('computer')
def verdi_computer():
"""Setup and manage computers."""
pass


def get_computer_names():
Expand Down Expand Up @@ -161,8 +160,8 @@ def _computer_create_temp_file(transport, scheduler, authinfo): # pylint: disab
if not transport.path_exists(remote_file_path):
echo.echo_error("* ERROR! The file was not found!")
return False
else:
echo.echo(" [OK]")

echo.echo(" [OK]")
echo.echo(" `-> Retrieving the file and checking its content...")

handle, destfile = tempfile.mkstemp()
Expand All @@ -179,8 +178,8 @@ def _computer_create_temp_file(transport, scheduler, authinfo): # pylint: disab
echo.echo("** Found:")
echo.echo(read_string)
return False
else:
echo.echo(" [Content OK]")

echo.echo(" [Content OK]")
finally:
os.remove(destfile)

Expand Down Expand Up @@ -621,7 +620,6 @@ def computer_delete(computer):
@verdi_computer.group('configure')
def computer_configure():
"""Configure a computer with one of the available transport types."""
pass


@computer_configure.command('show')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
@verdi.group('daemon')
def verdi_daemon():
"""Inspect and manage the daemon."""
pass


@verdi_daemon.command()
Expand Down
3 changes: 1 addition & 2 deletions aiida/cmdline/commands/cmd_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

from aiida.cmdline.commands.cmd_verdi import verdi
from aiida.cmdline.commands.cmd_plugin import verdi_plugin
from aiida.cmdline.utils import decorators, echo
from aiida.cmdline.utils import decorators
from aiida.cmdline.utils.pluginable import Pluginable


@verdi.group('data', entry_point_group='aiida.cmdline.data', cls=Pluginable)
def verdi_data():
"""Inspect, create and manage data nodes."""
pass


@verdi_data.command('plugins')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@verdi_data.group('array')
def array():
"""Manipulate ArrayData objects."""
pass


@array.command('show')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@verdi_data.group('bands')
def bands():
"""Manipulate BandsData objects."""
pass


# pylint: disable=too-many-arguments
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@verdi_data.group('cif')
def cif():
"""Manipulation of CIF data objects."""
pass


@cif.command('list')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@verdi_data.group('parameter')
def parameter():
"""View and manipulate ParameterData objects."""
pass


@parameter.command('show')
Expand Down
Loading

0 comments on commit 097fa6a

Please sign in to comment.