Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP plugin, add back 'settings' input #537

Merged
merged 4 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aiida_quantumespresso/calculations/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tests/calculations/test_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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),
'metadata': {
'options': get_default_options()
}
Expand Down Expand Up @@ -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 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 calc_info.codes_info[0].cmdline_params == ['-npools', '2']


@pytest.mark.parametrize(
('parameters', 'message'),
(
Expand Down