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

Remove parser information from output_parameters #597

Merged
merged 2 commits into from
Oct 27, 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
21 changes: 0 additions & 21 deletions aiida_quantumespresso/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,3 @@
class QEOutputParsingError(OutputParsingError):
"""Exception raised when there is a parsing error in the QE parser."""
pass


def get_parser_info(parser_info_template=None):
"""Return a template dictionary with details about the parser such as the version.

:param parser_info_template: template string with single placeholder to be replaced by current version number
:returns: dictionary with parser name, version and empty list for warnings
"""
import aiida_quantumespresso

parser_version = aiida_quantumespresso.__version__
parser_info = {}
parser_info['parser_warnings'] = []
parser_info['parser_version'] = parser_version

if parser_info_template is None:
parser_info['parser_info'] = f'aiida-quantumespresso parser v{parser_version}'
else:
parser_info['parser_info'] = parser_info_template.format(parser_version)

return parser_info
3 changes: 1 addition & 2 deletions aiida_quantumespresso/parsers/parse_raw/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""A basic parser for the common format of QE."""
from aiida_quantumespresso.parsers import get_parser_info

__all__ = ('parse_output_base', 'parse_output_error', 'convert_qe_time_to_sec', 'convert_qe2aiida_structure')

Expand All @@ -21,7 +20,7 @@ def parse_output_base(filecontent, codename=None, message_map=None):
raise RuntimeError(f'invalid format `message_map`: should be dictionary with two keys {keys}')

logs = get_logging_container()
parsed_data = get_parser_info(parser_info_template='aiida-quantumespresso parser simple v{}')
parsed_data = {}

lines = filecontent if isinstance(filecontent, list) else filecontent.split('\n')

Expand Down
11 changes: 7 additions & 4 deletions aiida_quantumespresso/parsers/parse_raw/cp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from xml.dom.minidom import parseString
from aiida_quantumespresso.parsers import QEOutputParsingError, get_parser_info
from aiida_quantumespresso.parsers import QEOutputParsingError
from aiida_quantumespresso.parsers.parse_xml.pw.legacy import (
read_xml_card, parse_xml_child_integer, xml_card_header, parse_xml_child_bool, parse_xml_child_str,
parse_xml_child_float, parse_xml_child_attribute_str, xml_card_cell, xml_card_ions, xml_card_exchangecorrelation,
Expand Down Expand Up @@ -151,10 +151,10 @@ def parse_cp_xml_counter_output(data):

def parse_cp_raw_output(stdout, output_xml=None, output_xml_counter=None):

parser_info = get_parser_info(parser_info_template='aiida-quantumespresso parser cp.x v{}')
parser_warnings = []

if output_xml is None:
parser_info['parser_warnings'].append('Skipping the parsing of the xml file.')
parser_warnings.append('Skipping the parsing of the xml file.')
xml_data = {}
else:
xml_data = parse_cp_xml_output(output_xml)
Expand All @@ -179,7 +179,10 @@ def parse_cp_raw_output(stdout, output_xml=None, output_xml_counter=None):
# out_data keys take precedence and overwrite xml_data keys,
# if the same key name is shared by both (but this should not happen!)

final_data = dict(list(xml_data.items()) + list(out_data.items()) + list(xml_counter_data.items()))
final_data = dict(
list(xml_data.items()) + list(out_data.items()) + list(xml_counter_data.items()) +
[('parser_warnings', parser_warnings)]
)

# TODO: parse the trajectory and save them in a reasonable format

Expand Down
10 changes: 5 additions & 5 deletions aiida_quantumespresso/parsers/parse_raw/neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from qe_tools import CONSTANTS

from aiida_quantumespresso.parsers import QEOutputParsingError, get_parser_info
from aiida_quantumespresso.parsers import QEOutputParsingError
from aiida_quantumespresso.parsers.parse_raw import convert_qe_time_to_sec


Expand All @@ -31,7 +31,7 @@ def parse_raw_output_neb(stdout, input_dict, parser_opts=None):
import copy

job_successful = True
parser_info = get_parser_info(parser_info_template='aiida-quantumespresso parser neb.x v{}')
parser_warnings = []

if not stdout: # there is an output file, but it's empty -> crash
job_successful = False
Expand All @@ -44,15 +44,15 @@ def parse_raw_output_neb(stdout, input_dict, parser_opts=None):
break
if not finished_run: # error if the job has not finished
warning = 'QE neb run did not reach the end of the execution.'
parser_info['parser_warnings'].append(warning)
parser_warnings.append(warning)
job_successful = False

# parse the text output of the neb calculation
try:
out_data, iteration_data, critical_messages = parse_neb_text_output(stdout, input_dict)
except QEOutputParsingError as exc:
if not finished_run: # I try to parse it as much as possible
parser_info['parser_warnings'].append('Error while parsing the output file')
parser_warnings.append('Error while parsing the output file')
out_data = {'warnings': []}
iteration_data = {}
critical_messages = []
Expand All @@ -72,7 +72,7 @@ def parse_raw_output_neb(stdout, input_dict, parser_opts=None):
if any([x in out_data['warnings'] for x in critical_messages]):
job_successful = False

parameter_data = dict(list(out_data.items()) + list(parser_info.items()))
parameter_data = dict(list(out_data.items()) + [('parser_warnings', parser_warnings)])

# return various data.
# parameter data will be mapped in Dict
Expand Down
7 changes: 2 additions & 5 deletions aiida_quantumespresso/parsers/parse_raw/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from qe_tools import CONSTANTS

from aiida_quantumespresso.parsers import QEOutputParsingError, get_parser_info
from aiida_quantumespresso.parsers import QEOutputParsingError
from aiida_quantumespresso.parsers.parse_raw.base import convert_qe_time_to_sec
from aiida_quantumespresso.parsers.parse_xml.pw.legacy import parse_xml_child_bool, read_xml_card
from aiida_quantumespresso.utils.mapping import get_logging_container
Expand All @@ -24,7 +24,6 @@ def parse_raw_ph_output(stdout, tensors=None, dynamical_matrices=None):
"""
logs = get_logging_container()
data_lines = stdout.split('\n')
parser_info = get_parser_info(parser_info_template='aiida-quantumespresso parser ph.x v{}')

# First check whether the `JOB DONE` message was written, otherwise the job was interrupted
for line in data_lines:
Expand Down Expand Up @@ -78,9 +77,7 @@ def parse_raw_ph_output(stdout, tensors=None, dynamical_matrices=None):
raise AssertionError(f'{key} found in two dictionaries')

# I don't check the dynmat_data and parser_info keys
parsed_data = dict(
list(dynmat_data.items()) + list(out_data.items()) + list(tensor_data.items()) + list(parser_info.items())
)
parsed_data = dict(list(dynmat_data.items()) + list(out_data.items()) + list(tensor_data.items()))

return parsed_data, logs

Expand Down
8 changes: 2 additions & 6 deletions aiida_quantumespresso/parsers/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,8 @@ def build_output_parameters(parsed_stdout, parsed_xml):

:param parsed_stdout: the raw parsed data dictionary from the stdout output file
:param parsed_xml: the raw parsed data dictionary from the XML output file
:return: the union of the two parsed raw and information about the parser
:return: the union of the two raw parsed data dictionaries
"""
from aiida_quantumespresso.parsers import get_parser_info

parsed_info = get_parser_info(parser_info_template='aiida-quantumespresso parser pw.x v{}')

for key in list(parsed_stdout.keys()):
if key in list(parsed_xml.keys()):
if parsed_stdout[key] != parsed_xml[key]:
Expand All @@ -354,7 +350,7 @@ def build_output_parameters(parsed_stdout, parsed_xml):
)
)

parameters = dict(list(parsed_xml.items()) + list(parsed_stdout.items()) + list(parsed_info.items()))
parameters = dict(list(parsed_xml.items()) + list(parsed_stdout.items()))

return parameters

Expand Down
1 change: 1 addition & 0 deletions tests/parsers/test_cp/test_cp_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ parameters:
number_of_processors_per_taskgroup: 1
number_of_species: 1
number_of_spin_components: 1
parser_warnings: []
pp_check_flag: true
reciprocal_lattice_vectors:
- - -0.1851851851851852
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_dos/test_dos_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ dos:
- states/eV
parameters:
code_version: v.6.4.1
parser_info: aiida-quantumespresso parser simple v3.2.1
parser_version: 3.2.1
parser_warnings: []
wall_time: 0.41s
wall_time_seconds: 0.41
11 changes: 0 additions & 11 deletions tests/parsers/test_neb/test_neb_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ parameters:
nstep_path: 20
num_of_images: 3
opt_scheme: broyden
parser_info: aiida-quantumespresso parser neb.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
path_length: 2.95757141880951
path_thr: 0.05
Expand Down Expand Up @@ -132,9 +130,6 @@ parameters:
number_of_spin_components: 2
number_of_symmetries: 8
occupations: smearing
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 1360.56917253
rho_cutoff_units: eV
Expand Down Expand Up @@ -231,9 +226,6 @@ parameters:
number_of_spin_components: 2
number_of_symmetries: 16
occupations: smearing
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 1360.56917253
rho_cutoff_units: eV
Expand Down Expand Up @@ -362,9 +354,6 @@ parameters:
number_of_spin_components: 2
number_of_symmetries: 8
occupations: smearing
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 1360.56917253
rho_cutoff_units: eV
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_ph/test_ph_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ number_of_atoms: 2
number_of_irr_representations_for_each_q:
- 2
number_of_qpoints: 1
parser_info: aiida-quantumespresso parser ph.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
wall_time: ' 15.25s '
wall_time_seconds: 15.25
3 changes: 0 additions & 3 deletions tests/parsers/test_ph/test_ph_not_converged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ number_of_irr_representations_for_each_q:
- 2
- 4
number_of_qpoints: 8
parser_info: aiida-quantumespresso parser ph.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
wall_time: ' 3m21.58s '
wall_time_seconds: 201.57999999999998
3 changes: 0 additions & 3 deletions tests/parsers/test_ph/test_ph_out_of_walltime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ number_of_irr_representations_for_each_q:
- 2
- 4
number_of_qpoints: 3
parser_info: aiida-quantumespresso parser ph.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
wall_time: ' 7.13s '
wall_time_seconds: 7.13
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ output_parameters:
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: true
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_default_no_xml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ output_parameters:
number_of_bands: 4
number_of_k_points: 3
number_of_species: 1
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
scf_iterations: 5
smooth_fft_grid:
- 25
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_default_xml_190304.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ output_parameters:
number_of_spin_components: 1
number_of_symmetries: 48
occupations: fixed
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 3265.366014072
rho_cutoff_units: eV
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_default_xml_191206.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ output_parameters:
number_of_spin_components: 1
number_of_symmetries: 48
occupations: fixed
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 272.113834506
rho_cutoff_units: eV
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_default_xml_200420.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ output_parameters:
number_of_spin_components: 1
number_of_symmetries: 48
occupations: fixed
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 3265.366014072
rho_cutoff_units: eV
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_failed_interrupted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ number_of_atoms: 2
number_of_bands: 4
number_of_k_points: 3
number_of_species: 1
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
scf_iterations: 5
smooth_fft_grid:
- 25
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_failed_interrupted_stdout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ number_of_k_points: 3
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: true
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_failed_interrupted_xml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ number_of_atoms: 2
number_of_bands: 4
number_of_k_points: 3
number_of_species: 1
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
scf_iterations: 5
smooth_fft_grid:
- 25
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_failed_out_of_walltime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ output_parameters:
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: false
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
output_parameters:
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
output_parameters: {}
output_trajectory:
array|cells:
- 1
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_failed_scf_not_converged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ output_parameters:
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: false
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_initialization_xml_new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ output_parameters:
number_of_spin_components: 1
number_of_symmetries: 48
occupations: fixed
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
q_real_space: false
rho_cutoff: 3265.366014072
rho_cutoff_units: eV
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_relax_success.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ output_parameters:
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: true
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
3 changes: 0 additions & 3 deletions tests/parsers/test_pw/test_pw_vcrelax_success.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ output_parameters:
number_of_species: 1
number_of_spin_components: 1
number_of_symmetries: 48
parser_info: aiida-quantumespresso parser pw.x v3.2.1
parser_version: 3.2.1
parser_warnings: []
pp_check_flag: true
q_real_space: false
rho_cutoff: 3265.366014072
Expand Down
Loading