Skip to content

Commit

Permalink
Merge branch 'develop' into add/dockerignore
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Jan 27, 2021
2 parents 60ebfaa + 3cf1d2e commit e267508
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 21 deletions.
6 changes: 3 additions & 3 deletions aiida/cmdline/commands/cmd_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ def computer_disable(computer, user):

@verdi_computer.command('list')
@options.ALL(help='Show also disabled or unconfigured computers.')
@options.RAW(help='Show only the computer names, one per line.')
@options.RAW(help='Show only the computer labels, one per line.')
@with_dbenv()
def computer_list(all_entries, raw):
"""List all available computers."""
from aiida.orm import Computer, User

if not raw:
echo.echo_info('List of configured computers')
echo.echo_info("Use 'verdi computer show COMPUTERNAME' to display more detailed information")
echo.echo_info("Use 'verdi computer show COMPUTERLABEL' to display more detailed information")

computers = Computer.objects.all()
user = User.objects.get_default()
Expand All @@ -357,7 +357,7 @@ def computer_list(all_entries, raw):
sort = lambda computer: computer.label
highlight = lambda comp: comp.is_user_configured(user) and comp.is_user_enabled(user)
hide = lambda comp: not (comp.is_user_configured(user) and comp.is_user_enabled(user)) and not all_entries
echo.echo_formatted_list(computers, ['name'], sort=sort, highlight=highlight, hide=hide)
echo.echo_formatted_list(computers, ['label'], sort=sort, highlight=highlight, hide=hide)


@verdi_computer.command('show')
Expand Down
2 changes: 1 addition & 1 deletion aiida/engine/processes/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def _setup_db_record(self) -> None:

def _setup_metadata(self) -> None:
"""Store the metadata on the ProcessNode."""
version_info = self.runner.plugin_version_provider.get_version_info(self)
version_info = self.runner.plugin_version_provider.get_version_info(self.__class__)
self.node.set_attribute_many(version_info)

for name, metadata in self.metadata.items():
Expand Down
13 changes: 10 additions & 3 deletions aiida/engine/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,17 @@ def kill_process(_num, _frame):
LOGGER.critical('runner received interrupt, killing process %s', process_inited.pid)
process_inited.kill(msg='Process was killed because the runner received an interrupt')

signal.signal(signal.SIGINT, kill_process)
signal.signal(signal.SIGTERM, kill_process)
original_handler_int = signal.getsignal(signal.SIGINT)
original_handler_term = signal.getsignal(signal.SIGTERM)

try:
signal.signal(signal.SIGINT, kill_process)
signal.signal(signal.SIGTERM, kill_process)
process_inited.execute()
finally:
signal.signal(signal.SIGINT, original_handler_int)
signal.signal(signal.SIGTERM, original_handler_term)

process_inited.execute()
return process_inited.outputs, process_inited.node

def run(self, process: TYPE_RUN_PROCESS, *args: Any, **inputs: Any) -> Dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions aiida/orm/nodes/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""Module with `Node` sub classes for data structures."""

from .array import ArrayData, BandsData, KpointsData, ProjectionData, TrajectoryData, XyData
from .base import BaseType
from .base import BaseType, to_aiida_type
from .bool import Bool
from .cif import CifData
from .code import Code
Expand All @@ -31,5 +31,5 @@
__all__ = (
'Data', 'BaseType', 'ArrayData', 'BandsData', 'KpointsData', 'ProjectionData', 'TrajectoryData', 'XyData', 'Bool',
'CifData', 'Code', 'Float', 'FolderData', 'Int', 'List', 'OrbitalData', 'Dict', 'RemoteData', 'SinglefileData',
'Str', 'StructureData', 'UpfData', 'NumericType'
'Str', 'StructureData', 'UpfData', 'NumericType', 'to_aiida_type'
)
1 change: 1 addition & 0 deletions docs/source/reference/api/public.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ If a module is mentioned, then all the resources defined in its ``__all__`` are
load_code
load_computer
load_group
to_aiida_type


``aiida.parsers``
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
from aiida.engine import WorkChain
from aiida.orm.nodes.data import to_aiida_type
# The basic types need to be loaded such that they are registered with
# the 'to_aiida_type' function.
from aiida.orm.nodes.data.base import *
from aiida.orm import to_aiida_type


class SerializeWorkChain(WorkChain):
Expand Down
6 changes: 4 additions & 2 deletions docs/source/topics/processes/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ This function, passed as ``serializer`` parameter to ``spec.input``, is invoked
For inputs which are stored in the database (``non_db=False``), the serialization function should return an AiiDA data type.
For ``non_db`` inputs, the function must be idempotent because it might be applied more than once.

The following example work chain takes three inputs ``a``, ``b``, ``c``, and simply returns the given inputs. The :func:`aiida.orm.nodes.data.base.to_aiida_type` function is used as serialization function.
The following example work chain takes three inputs ``a``, ``b``, ``c``, and simply returns the given inputs.
The :func:`~aiida.orm.nodes.data.base.to_aiida_type` function is used as serialization function.

.. include:: include/snippets/serialize/workchain_serialize.py
:code: python

This work chain can now be called with native Python types, which will automatically be converted to AiiDA types by the :func:`aiida.orm.nodes.data.base.to_aiida_type` function. Note that the module which defines the corresponding AiiDA type must be loaded for it to be recognized by :func:`aiida.orm.nodes.data.base.to_aiida_type`.
This work chain can now be called with native Python types, which will automatically be converted to AiiDA types by the :func:`~aiida.orm.nodes.data.base.to_aiida_type` function.
Note that the module which defines the corresponding AiiDA type must be loaded for it to be recognized by :func:`~aiida.orm.nodes.data.base.to_aiida_type`.

.. include:: include/snippets/serialize/run_workchain_serialize.py
:code: python
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- click-completion~=0.5.1
- click-config-file~=0.6.0
- click-spinner~=0.1.8
- click~=7.0
- click~=7.1
- dataclasses~=0.7
- django~=2.2
- ete3~=3.1
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
circus==0.17.1
Click==7.0
Click==7.1.2
click-completion==0.5.2
click-config-file==0.6.0
click-spinner==0.1.8
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
circus==0.17.1
Click==7.0
Click==7.1.2
click-completion==0.5.2
click-config-file==0.6.0
click-spinner==0.1.8
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-py-3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
circus==0.17.1
Click==7.0
Click==7.1.2
click-completion==0.5.2
click-config-file==0.6.0
click-spinner==0.1.8
Expand Down
2 changes: 1 addition & 1 deletion setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"click-completion~=0.5.1",
"click-config-file~=0.6.0",
"click-spinner~=0.1.8",
"click~=7.0",
"click~=7.1",
"dataclasses~=0.7; python_version < '3.7.0'",
"django~=2.2",
"ete3~=3.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/orm/data/test_to_aiida_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
This module contains tests for the to_aiida_type serializer
"""
from aiida.orm.nodes.data.base import to_aiida_type
from aiida.orm import to_aiida_type
from aiida.orm import Dict, Int, Float, Bool, Str

from aiida.backends.testbase import AiidaTestCase
Expand Down

0 comments on commit e267508

Please sign in to comment.