From 46eb344419e6ca690640f873fe1f64ab22b6fef1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Thu, 9 Jul 2020 16:15:36 +0200 Subject: [PATCH 1/4] PP plugin, add back 'settings' input --- aiida_quantumespresso/calculations/pp.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aiida_quantumespresso/calculations/pp.py b/aiida_quantumespresso/calculations/pp.py index 317c714b9..d351a1dd2 100644 --- a/aiida_quantumespresso/calculations/pp.py +++ b/aiida_quantumespresso/calculations/pp.py @@ -75,6 +75,8 @@ def define(cls, spec): help='Output folder of a completed `PwCalculation`') spec.input('parameters', valid_type=orm.Dict, required=True, validator=validate_parameters, help='Use a node that specifies the input parameters for the namelists') + spec.input('settings', valid_type=orm.Dict, required=False, + help='Optional parameters to affect the way the calculation job is performed.') spec.input('metadata.options.input_filename', valid_type=str, default=cls._DEFAULT_INPUT_FILE) spec.input('metadata.options.output_filename', valid_type=str, default=cls._DEFAULT_OUTPUT_FILE) spec.input('metadata.options.parser_name', valid_type=str, default='quantumespresso.pp') @@ -130,6 +132,12 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-branches,t parameters = _uppercase_dict(self.inputs.parameters.get_dict(), dict_name='parameters') parameters = {k: _lowercase_dict(v, dict_name=k) for k, v in parameters.items()} + # Same for settings. + if 'settings' in self.inputs: + settings = _uppercase_dict(self.inputs.settings.get_dict(), dict_name='settings') + else: + settings = {} + # Set default values. NOTE: this is different from PW/CP for blocked in self._blocked_keywords: namelist = blocked[0].upper() @@ -204,6 +212,7 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-branches,t )) codeinfo = datastructures.CodeInfo() + codeinfo.cmdline_params = settings.pop('CMDLINE', []) codeinfo.stdin_name = self.inputs.metadata.options.input_filename codeinfo.stdout_name = self.inputs.metadata.options.output_filename codeinfo.code_uuid = self.inputs.code.uuid From fa22b7ef9f3bf9f63cb5225e0633838d90256996 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 13 Jul 2020 17:02:15 +0200 Subject: [PATCH 2/4] Test a `PpCalculation` with user-defined cmdline setting --- tests/calculations/test_pp.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/calculations/test_pp.py b/tests/calculations/test_pp.py index 80e0a6826..9a413d667 100644 --- a/tests/calculations/test_pp.py +++ b/tests/calculations/test_pp.py @@ -11,7 +11,7 @@ def generate_inputs(fixture_localhost, fixture_sandbox, fixture_code, generate_remote_data): """Return only those inputs that the parser will expect to be there.""" - def _generate_inputs(parameters=None): + def _generate_inputs(parameters=None, settings=None): from aiida_quantumespresso.utils.resources import get_default_options if parameters is None: @@ -24,6 +24,8 @@ def _generate_inputs(parameters=None): generate_remote_data(fixture_localhost, fixture_sandbox.abspath, 'quantumespresso.pw'), 'parameters': orm.Dict(dict=parameters), + 'settings': + orm.Dict(dict=settings) or orm.Dict(), 'metadata': { 'options': get_default_options() } @@ -79,6 +81,14 @@ def test_pp_keep_plot_file(aiida_profile, fixture_sandbox, generate_calc_job, ge assert element in calc_info.retrieve_list +def test_pp_cmdline_setting(aiida_profile, fixture_sandbox, generate_calc_job, generate_inputs): + """Test a `PpCalculation` with user-defined cmdline setting.""" + entry_point_name = 'quantumespresso.pp' + inputs = generate_inputs(settings={'cmdline': ['-npools', '2']}) + calc_info = generate_calc_job(fixture_sandbox, entry_point_name, inputs) + assert ['-npools', '2'] == calc_info.codes_info[0].cmdline_params + + @pytest.mark.parametrize( ('parameters', 'message'), ( From fcd0f8bb9c45765672cc00968dd5b351f17e11cb Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Tue, 14 Jul 2020 10:07:32 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Sebastiaan Huber --- tests/calculations/test_pp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/calculations/test_pp.py b/tests/calculations/test_pp.py index 9a413d667..7a72e842e 100644 --- a/tests/calculations/test_pp.py +++ b/tests/calculations/test_pp.py @@ -82,11 +82,11 @@ def test_pp_keep_plot_file(aiida_profile, fixture_sandbox, generate_calc_job, ge def test_pp_cmdline_setting(aiida_profile, fixture_sandbox, generate_calc_job, generate_inputs): - """Test a `PpCalculation` with user-defined cmdline setting.""" + """Test a `PpCalculation` with user-defined cmdline settings.""" entry_point_name = 'quantumespresso.pp' inputs = generate_inputs(settings={'cmdline': ['-npools', '2']}) calc_info = generate_calc_job(fixture_sandbox, entry_point_name, inputs) - assert ['-npools', '2'] == calc_info.codes_info[0].cmdline_params + assert calc_info.codes_info[0].cmdline_params == ['-npools', '2'] @pytest.mark.parametrize( From 95db603d8a9fe5737bee0994646d7cd23e362589 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Tue, 14 Jul 2020 10:13:46 +0200 Subject: [PATCH 4/4] Apply suggestions from the code review. --- tests/calculations/test_pp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/calculations/test_pp.py b/tests/calculations/test_pp.py index 7a72e842e..1e4bdfad8 100644 --- a/tests/calculations/test_pp.py +++ b/tests/calculations/test_pp.py @@ -25,7 +25,7 @@ def _generate_inputs(parameters=None, settings=None): 'parameters': orm.Dict(dict=parameters), 'settings': - orm.Dict(dict=settings) or orm.Dict(), + orm.Dict(dict=settings), 'metadata': { 'options': get_default_options() }