Skip to content

Commit

Permalink
Merge pull request #3821 from aiidateam/release/1.1.1
Browse files Browse the repository at this point in the history
Release `v1.1.1`
  • Loading branch information
sphuber authored Mar 3, 2020
2 parents a92c1f1 + 4307c74 commit 20fa6c2
Show file tree
Hide file tree
Showing 73 changed files with 1,244 additions and 711 deletions.
8 changes: 8 additions & 0 deletions .ci/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@ def run_base_restart_workchain():
assert node.exit_status == ArithmeticAddBaseWorkChain.exit_codes.ERROR_TOO_BIG.status, node.exit_status # pylint: disable=no-member
assert len(node.called) == 1

# Check that overriding default handler enabled status works
inputs['add']['y'] = Int(1)
inputs['handler_overrides'] = Dict(dict={'disabled_handler': True})
results, node = run.get_node(ArithmeticAddBaseWorkChain, **inputs)
assert not node.is_finished_ok, node.process_state
assert node.exit_status == ArithmeticAddBaseWorkChain.exit_codes.ERROR_ENABLED_DOOM.status, node.exit_status # pylint: disable=no-member
assert len(node.called) == 1


def main():
"""Launch a bunch of calculation jobs and workchains."""
Expand Down
45 changes: 24 additions & 21 deletions .ci/workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
###########################################################################
from aiida.common import AttributeDict
from aiida.engine import calcfunction, workfunction, WorkChain, ToContext, append_, while_, ExitCode
from aiida.engine import BaseRestartWorkChain, register_process_handler, ProcessHandlerReport
from aiida.engine import BaseRestartWorkChain, process_handler, ProcessHandlerReport
from aiida.engine.persistence import ObjectLoader
from aiida.orm import Int, List, Str
from aiida.plugins import CalculationFactory
Expand Down Expand Up @@ -38,6 +38,7 @@ def define(cls, spec):
cls.results,
)
spec.exit_code(100, 'ERROR_TOO_BIG', message='The sum was too big.')
spec.exit_code(110, 'ERROR_ENABLED_DOOM', message='You should not have done that.')

def setup(self):
"""Call the `setup` of the `BaseRestartWorkChain` and then create the inputs dictionary in `self.ctx.inputs`.
Expand All @@ -48,26 +49,28 @@ def setup(self):
super().setup()
self.ctx.inputs = AttributeDict(self.exposed_inputs(ArithmeticAddCalculation, 'add'))


@register_process_handler(ArithmeticAddBaseWorkChain, priority=500)
def sanity_check_not_too_big(self, node):
"""My puny brain cannot deal with numbers that I cannot count on my hand."""
if node.is_finished_ok and node.outputs.sum > 10:
return ProcessHandlerReport(True, self.exit_codes.ERROR_TOO_BIG)


@register_process_handler(ArithmeticAddBaseWorkChain, priority=450, exit_codes=ExitCode(1000, 'Unicorn encountered'))
def a_magic_unicorn_appeared(self, node):
"""As we all know unicorns do not exist so we should never have to deal with it."""
raise RuntimeError('this handler should never even have been called')


@register_process_handler(ArithmeticAddBaseWorkChain, priority=400, exit_codes=ArithmeticAddCalculation.exit_codes.ERROR_NEGATIVE_NUMBER)
def error_negative_sum(self, node):
"""What even is a negative number, how can I have minus three melons?!."""
self.ctx.inputs.x = Int(abs(node.inputs.x.value))
self.ctx.inputs.y = Int(abs(node.inputs.y.value))
return ProcessHandlerReport(True)
@process_handler(priority=500)
def sanity_check_not_too_big(self, node):
"""My puny brain cannot deal with numbers that I cannot count on my hand."""
if node.is_finished_ok and node.outputs.sum > 10:
return ProcessHandlerReport(True, self.exit_codes.ERROR_TOO_BIG)

@process_handler(priority=460, enabled=False)
def disabled_handler(self, node):
"""By default this is not enabled and so should never be called, irrespective of exit codes of sub process."""
return ProcessHandlerReport(True, self.exit_codes.ERROR_ENABLED_DOOM)

@process_handler(priority=450, exit_codes=ExitCode(1000, 'Unicorn encountered'))
def a_magic_unicorn_appeared(self, node):
"""As we all know unicorns do not exist so we should never have to deal with it."""
raise RuntimeError('this handler should never even have been called')

@process_handler(priority=400, exit_codes=ArithmeticAddCalculation.exit_codes.ERROR_NEGATIVE_NUMBER)
def error_negative_sum(self, node):
"""What even is a negative number, how can I have minus three melons?!."""
self.ctx.inputs.x = Int(abs(node.inputs.x.value))
self.ctx.inputs.y = Int(abs(node.inputs.y.value))
return ProcessHandlerReport(True)


class NestedWorkChain(WorkChain):
Expand Down
15 changes: 1 addition & 14 deletions .docker/opt/configure-aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,7 @@ set -x
# Environment.
export SHELL=/bin/bash

# Activate conda.
__conda_setup="$('/opt/conda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
. "/opt/conda/etc/profile.d/conda.sh"
else
export PATH="/opt/conda/bin:$PATH"
fi
fi
unset __conda_setup

# Very important to run after conda activation, otherwise AiiDA won't work.
# Update the list of installed aiida plugins.
reentry scan

# Setup AiiDA autocompletion.
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: harmon758/postgresql-action@v1
- uses: CasperWA/postgresql-action@v1.2
with:
postgresql version: '11'
postgresql version: '10'
postgresql db: test_${{ matrix.backend }}
postgresql user: 'postgres'
postgresql user: postgres
postgresql password: ''
postgresql auth: trust

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
Expand All @@ -115,7 +116,7 @@ jobs:
echo 'deb https://dl.bintray.com/rabbitmq/debian bionic main' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install postgresql postgresql-server-dev-all postgresql-client rabbitmq-server graphviz
sudo apt install postgresql-10 rabbitmq-server graphviz
sudo systemctl status rabbitmq-server.service
- name: Install python dependencies
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no

# Workaround for https://github.com/conda/conda/issues/9337
pip uninstall -y setuptools
conda install setuptools

conda update -q conda
conda info -a
conda env create -f environment.yml -n test-environment python=$PYTHON_VERSION
conda env create -f environment.yml -n test-environment
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# Changelog

## v1.1.1

### Changes
- Emit a warning when input port specifies a node instance as default [[#3466]](https://github.com/aiidateam/aiida-core/pull/3466)
- `BaseRestartWorkChain`: require process handlers to be instance methods [[#3782]](https://github.com/aiidateam/aiida-core/pull/3782)
- `BaseRestartWorkChain`: add method to enable/disable process handlers [[#3786]](https://github.com/aiidateam/aiida-core/pull/3786)
- Docker container: remove conda activation from configure-aiida.sh script [[#3791]](https://github.com/aiidateam/aiida-core/pull/3791)
- Add fixtures to clear the database before or after tests [[#3783]](https://github.com/aiidateam/aiida-core/pull/3783)
- `verdi status`: add the configuration directory path to the output [[#3587]](https://github.com/aiidateam/aiida-core/pull/3587)
- `QueryBuilder`: add support for `datetime.date` objects in filters [[#3796]](https://github.com/aiidateam/aiida-core/pull/3796)

### Bug fixes
- Fix bugs in `Node._store_from_cache` and `Node.repository.erase` that could result in calculations not being reused [[#3777]](https://github.com/aiidateam/aiida-core/pull/3777)
- Caching: fix configuration spec and validation [[#3785]](https://github.com/aiidateam/aiida-core/pull/3785)
- Write migrated config to disk in `Config.from_file` [[#3797]](https://github.com/aiidateam/aiida-core/pull/3797)
- Validate label string at code setup stage [[#3793]](https://github.com/aiidateam/aiida-core/pull/3793)
- Reuse `prepend_text` and `append_text` in `verdi computer/code duplicate` [[#3788]](https://github.com/aiidateam/aiida-core/pull/3788)
- Fix broken imports of `urllib` in various locations including `verdi import` [[#3767]](https://github.com/aiidateam/aiida-core/pull/3767)
- Match headers with actual output for `verdi data structure list` [[#3756]](https://github.com/aiidateam/aiida-core/pull/3756)
- Disable caching for the `Data` node subclass (this should not affect usual caching behavior) [[#3807]](https://github.com/aiidateam/aiida-core/pull/3807)


## v1.1.0

**Note Bene:** although this is a minor version release, the support for python 2 is dropped [(#3566)](https://github.com/aiidateam/aiida-core/pull/3566) following the reasoning outlined in the corresponding [AEP001](https://github.com/aiidateam/AEP/tree/master/001_drop_python2).
**Nota Bene:** although this is a minor version release, the support for python 2 is dropped [(#3566)](https://github.com/aiidateam/aiida-core/pull/3566) following the reasoning outlined in the corresponding [AEP001](https://github.com/aiidateam/AEP/tree/master/001_drop_python2).
Critical bug fixes for python 2 will be supported until July 1 2020 on the `v1.0.*` release series.
With the addition of python 3.8 [(#3719)](https://github.com/aiidateam/aiida-core/pull/3719), this version is now compatible with all current python versions that are not end-of-life:
* 3.5
Expand Down
2 changes: 1 addition & 1 deletion aiida/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'For further information please visit http://www.aiida.net/. All rights reserved.'
)
__license__ = 'MIT license, see LICENSE.txt file.'
__version__ = '1.1.0'
__version__ = '1.1.1'
__authors__ = 'The AiiDA team.'
__paper__ = (
'G. Pizzi, A. Cepellotti, R. Sabatini, N. Marzari, and B. Kozinsky,'
Expand Down
10 changes: 7 additions & 3 deletions aiida/cmdline/commands/cmd_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def setup_code(non_interactive, **kwargs):
kwargs['code_type'] = CodeBuilder.CodeType.STORE_AND_UPLOAD

code_builder = CodeBuilder(**kwargs)
code = code_builder.new()

try:
code = code_builder.new()
except InputValidationError as exception:
echo.echo_critical('invalid inputs: {}'.format(exception))

try:
code.store()
Expand All @@ -115,8 +119,8 @@ def setup_code(non_interactive, **kwargs):
@options_code.REMOTE_ABS_PATH(contextual_default=partial(get_default, 'remote_abs_path'))
@options_code.FOLDER(contextual_default=partial(get_default, 'code_folder'))
@options_code.REL_PATH(contextual_default=partial(get_default, 'code_rel_path'))
@options.PREPEND_TEXT()
@options.APPEND_TEXT()
@options.PREPEND_TEXT(cls=options.ContextualDefaultOption, contextual_default=partial(get_default, 'prepend_text'))
@options.APPEND_TEXT(cls=options.ContextualDefaultOption, contextual_default=partial(get_default, 'append_text'))
@options.NON_INTERACTIVE()
@click.option('--hide-original', is_flag=True, default=False, help='Hide the code being copied.')
@click.pass_context
Expand Down
8 changes: 6 additions & 2 deletions aiida/cmdline/commands/cmd_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,12 @@ def computer_setup(ctx, non_interactive, **kwargs):
@options_computer.WORKDIR(contextual_default=partial(get_parameter_default, 'work_dir'))
@options_computer.MPI_RUN_COMMAND(contextual_default=partial(get_parameter_default, 'mpirun_command'))
@options_computer.MPI_PROCS_PER_MACHINE(contextual_default=partial(get_parameter_default, 'mpiprocs_per_machine'))
@options.PREPEND_TEXT()
@options.APPEND_TEXT()
@options.PREPEND_TEXT(
cls=options.ContextualDefaultOption, contextual_default=partial(get_parameter_default, 'prepend_text')
)
@options.APPEND_TEXT(
cls=options.ContextualDefaultOption, contextual_default=partial(get_parameter_default, 'append_text')
)
@options.NON_INTERACTIVE()
@click.pass_context
@with_dbenv()
Expand Down
7 changes: 4 additions & 3 deletions aiida/cmdline/commands/cmd_data/cmd_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from aiida.cmdline.params import arguments, options, types
from aiida.cmdline.utils import decorators, echo

LIST_PROJECT_HEADERS = ['Id', 'Label', 'Kinds', 'Sites']
LIST_PROJECT_HEADERS = ['Id', 'Label', 'Formula']
EXPORT_FORMATS = ['cif', 'xsf', 'xyz']
VISUALIZATION_FORMATS = ['ase', 'jmol', 'vesta', 'vmd', 'xcrysden']

Expand Down Expand Up @@ -63,7 +63,8 @@ def structure_list(elements, raw, formula_mode, past_days, groups, all_users):

elements_only = False
lst = data_list(
StructureData, LIST_PROJECT_HEADERS, elements, elements_only, formula_mode, past_days, groups, all_users
StructureData, ['Id', 'Label', 'Kinds', 'Sites'], elements, elements_only, formula_mode, past_days, groups,
all_users
)

entry_list = []
Expand Down Expand Up @@ -99,7 +100,7 @@ def structure_list(elements, raw, formula_mode, past_days, groups, all_users):
# referenced by the site
except KeyError:
formula = '<<UNKNOWN>>'
entry_list.append([str(pid), str(formula), label])
entry_list.append([str(pid), label, str(formula)])

counter = 0
struct_list_data = list()
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/commands/cmd_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# pylint: disable=broad-except,too-many-arguments,too-many-locals,too-many-branches
from enum import Enum
import traceback
import urllib
import urllib.request
import click

from aiida.cmdline.commands.cmd_verdi import verdi
Expand Down
3 changes: 2 additions & 1 deletion aiida/cmdline/commands/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def profile_list():
@arguments.PROFILE(default=defaults.get_default_profile)
def profile_show(profile):
"""Show details for a profile."""

if profile is None:
echo.echo_critical('no profile to show')

echo.echo_info('Configuration for: {}'.format(profile.name))
echo.echo_info('Profile: {}'.format(profile.name))
data = sorted([(k.lower(), v) for k, v in profile.dictionary.items()])
echo.echo(tabulate.tabulate(data))

Expand Down
6 changes: 5 additions & 1 deletion aiida/cmdline/commands/cmd_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ def verdi_status():
from aiida.common.utils import Capturing
from aiida.manage.external.rmq import get_rmq_url
from aiida.manage.manager import get_manager
from aiida.manage.configuration.settings import AIIDA_CONFIG_FOLDER

exit_code = ExitCode.SUCCESS

# path to configuration file
print_status(ServiceStatus.UP, 'config dir', AIIDA_CONFIG_FOLDER)

manager = get_manager()
profile = manager.get_profile()

# getting the profile
try:
profile = manager.get_profile()
print_status(ServiceStatus.UP, 'profile', 'On profile {}'.format(profile.name))
Expand Down
1 change: 1 addition & 0 deletions aiida/cmdline/params/options/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .. import types
from .multivalue import MultipleValueOption
from .overridable import OverridableOption
from .contextualdefault import ContextualDefaultOption
from .config import ConfigFileOption

__all__ = (
Expand Down
32 changes: 32 additions & 0 deletions aiida/cmdline/params/options/contextualdefault.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 #
###########################################################################
"""
.. py:module::contextualdefault
:synopsis: Tools for options which allow for a default callable that needs
also the context ctx
"""

import click


class ContextualDefaultOption(click.Option):
"""A class that extends click.Option allowing to define a default callable
that also get the context ctx as a parameter.
"""

def __init__(self, *args, contextual_default=None, **kwargs):
self._contextual_default = contextual_default
super().__init__(*args, **kwargs)

def get_default(self, ctx):
"""If a contextual default is defined, use it, otherwise behave normally."""
if self._contextual_default is None:
return super().get_default(ctx)
return self._contextual_default(ctx)
9 changes: 6 additions & 3 deletions aiida/cmdline/params/types/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
###########################################################################
"""Click parameter types for paths."""
import os
import urllib
# See https://stackoverflow.com/a/41217363/1069467
import urllib.request
import urllib.error

import click

Expand Down Expand Up @@ -53,10 +55,11 @@ def __repr__(self):
class ImportPath(click.Path):
"""AiiDA extension of Click's Path-type to include URLs
An ImportPath can either be a `click.Path`-type or a URL.
:param timeout_seconds: Timeout time in seconds that a URL response is expected.
:value timeout_seconds: Must be an int in the range [0;60], extrema included.
If an int outside the range [0;60] is given, the value will be set to the respective extremum value.
If any other type than int is given a TypeError will be raised.
If an int outside the range [0;60] is given, the value will be set to the respective extremum value.
If any other type than int is given a TypeError will be raised.
"""

# pylint: disable=protected-access
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/utils/multi_line_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def edit_pre_post(pre=None, post=None, summary=None):
pre = re.sub(r'(^#=.*$\n)+', '', pre, flags=re.M).strip()
post = re.sub(r'(^#=.*$\n)+', '', post, flags=re.M).strip()
else:
pre, post = ('', '')
pre, post = (pre or '', post or '')
return pre, post


Expand Down
Loading

0 comments on commit 20fa6c2

Please sign in to comment.