diff --git a/aiida_kkr/parsers/kkrimp.py b/aiida_kkr/parsers/kkrimp.py index 45f9d0c7..9e78d855 100644 --- a/aiida_kkr/parsers/kkrimp.py +++ b/aiida_kkr/parsers/kkrimp.py @@ -9,7 +9,7 @@ import os from aiida import __version__ as aiida_core_version from aiida.orm import Dict, CalcJobNode -from aiida.common.exceptions import InputValidationError, NotExistent +from aiida.common.exceptions import InputValidationError, NotExistent, NotExistentAttributeError from aiida.parsers.parser import Parser from aiida_kkr.calculations.kkrimp import KkrimpCalculation from aiida_kkr.tools.context import open_files_in_context @@ -21,7 +21,7 @@ __copyright__ = (u'Copyright (c), 2018, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.') __license__ = 'MIT license, see LICENSE.txt file' -__version__ = '0.6.1' +__version__ = '0.6.2' __contributors__ = (u'Philipp Rüßmann', u'Raffaele Aliberti') @@ -42,7 +42,7 @@ def __init__(self, calc): # pylint: disable=protected-access # pylint: disable=unexpected-keyword-arg - def parse(self, debug=False, ignore_nan=True, **kwargs): + def parse(self, debug=False, ignore_nan=True, doscalc=None, **kwargs): """ Parse output data folder, store results in database. @@ -67,12 +67,12 @@ def parse(self, debug=False, ignore_nan=True, **kwargs): # Get the node of the parent calculation (useful for the imp calculations) calc = out_folder.get_incoming(node_class=CalcJobNode).first().node - # figure out if this is a DOS calculation - parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node - npol = parent_host_calc.inputs.parameters.get_dict().get( - 'NPOL', 1 - ) # This parameter discriminates if it is a DOS calc or not - doscalc = (npol == 0) + # figure out if this is a DOS calculation (if not specified in the input already) + if doscalc is None: + parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node + # This parameter discriminates if it is a DOS calc or not + npol = parent_host_calc.inputs.parameters.get_dict().get('NPOL', 1) + doscalc = (npol == 0) if debug: print('doscalc = ', doscalc) diff --git a/tests/files/export_kkrimp_calc.aiida b/tests/files/export_kkrimp_calc.aiida new file mode 100644 index 00000000..6d1eff8d Binary files /dev/null and b/tests/files/export_kkrimp_calc.aiida differ diff --git a/tests/files/export_kkrimp_calc.tar.gz b/tests/files/export_kkrimp_calc.tar.gz deleted file mode 100644 index c49364a2..00000000 Binary files a/tests/files/export_kkrimp_calc.tar.gz and /dev/null differ diff --git a/tests/parsers/test_kkrimp_parser.py b/tests/parsers/test_kkrimp_parser.py index 44f21985..77cdbd9e 100755 --- a/tests/parsers/test_kkrimp_parser.py +++ b/tests/parsers/test_kkrimp_parser.py @@ -2,7 +2,7 @@ from builtins import object import pytest -from aiida.manage.tests.pytest_fixtures import clear_database, clear_database_after_test, aiida_profile +from aiida import orm from ..conftest import import_with_migration # tests @@ -12,10 +12,13 @@ def test_parse_kkrimp_calc(aiida_profile): """ simple Cu noSOC, FP, lmax2 """ - from aiida.orm import load_node from aiida_kkr.parsers.kkrimp import KkrimpParser - import_with_migration('files/db_dump_kkrimp_out.tar.gz') - kkrimp_calc = load_node('eab8db1b-2cc7-4b85-a524-0df4ff2b7da6') + group_pk = import_with_migration('data_dir/kkrimp_full_wc.aiida') + kkrimp_calc = [ + i for i in orm.load_group(group_pk).nodes if i.label == 'KKRimp calculation step 2 (IMIX=0, Zimp: [30.0])' + ][0] + print(kkrimp_calc, kkrimp_calc.label) + print(kkrimp_calc.outputs.retrieved.list_object_names()) parser = KkrimpParser(kkrimp_calc) out = parser.parse(debug=False) @@ -29,12 +32,11 @@ def test_parse_kkrimp_calc_complex(aiida_profile): """ complex magnetic impurity with SOC """ - from aiida.orm import load_node from aiida_kkr.parsers.kkrimp import KkrimpParser - import_with_migration('files/export_kkrimp_calc.tar.gz') - kkrimp_calc = load_node('7547303b-69b7-4380-b0c0-7440e6c4f2a1') + import_with_migration('files/export_kkrimp_calc.aiida') + kkrimp_calc = orm.load_node('b9a2b29a-e250-4992-ae6a-579b733ad1f8') parser = KkrimpParser(kkrimp_calc) - out = parser.parse(debug=False) + out = parser.parse(debug=False, doscalc=False) assert out is None out_dict = parser.outputs.output_parameters.get_dict() assert out_dict['parser_errors'] == []