nomad-coe / nomad

NOMAD lets you manage and share your materials science data in a way that makes it truly useful to you, your group, and the community.
https://nomad-lab.eu
Apache License 2.0
77 stars 19 forks source link

ORCA parser failing on v5.0.2 file #76

Closed Andrew-S-Rosen closed 1 year ago

Andrew-S-Rosen commented 1 year ago

I received the following error with nomad-lab 1.2.0 on Ubuntu. Here is the file: orca.out.txt

import sys
from nomad.client import parse, normalize_all

# match and run the parser
archives = parse('orca.out')
# run all normalizers
for archive in archives:
    normalize_all(archive)

    # get the 'main section' section_run as a metainfo object
    section_run = archive.run[0]

    # get the same data as JSON serializable Python dict
    python_dict = section_run.m_to_dict()

This yields the following traceback:

AttributeError                            Traceback (most recent call last)
Cell In[1], line 6
      3 from nomad.client import parse, normalize_all
      5 # match and run the parser
----> 6 archives = parse('orca.out')
      7 # run all normalizers
      8 for archive in archives:

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/nomad/client/processing.py:62, in parse(mainfile_path, parser_name, backend_factory, strict, logger, server_context, username, password)
     59 if hasattr(parser, 'backend_factory'):
     60     setattr(parser, 'backend_factory', backend_factory)
---> 62 entry_archives = parsers.run_parser(
     63     mainfile_path, parser, mainfile_keys, logger, server_context, username, password)
     65 logger.info('ran parser')
     66 return entry_archives

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/nomad/parsing/parsers.py:195, in run_parser(mainfile_path, parser, mainfile_keys, logger, server_context, username, password)
    193     if logger:
    194         logger.error('parsing was not successful', exc_info=e)
--> 195     raise e
    196 finally:
    197     os.chdir(cwd)

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/nomad/parsing/parsers.py:191, in run_parser(mainfile_path, parser, mainfile_keys, logger, server_context, username, password)
    189     mainfile_path = os.path.abspath(mainfile_path)
    190     os.chdir(os.path.abspath(os.path.dirname(mainfile_path)))
--> 191     parser.parse(mainfile_path, entry_archive, logger=logger, **kwargs)
    192 except Exception as e:
    193     if logger:

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/nomad/parsing/parser.py:398, in MatchingParserInterface.parse(self, mainfile, archive, logger, child_archives)
    396 if child_archives:
    397     self.mainfile_parser._child_archives = child_archives
--> 398 self.mainfile_parser.parse(mainfile, archive, logger)

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/electronicparsers/orca/parser.py:922, in OrcaParser.parse(self, filepath, archive, logger)
    919 sec_run.program.version = ' '.join(version)
    920 sec_run.program.compilation_date = self.out_parser.get('program_compilation_date')
--> 922 self.parse_configurations()

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/electronicparsers/orca/parser.py:871, in OrcaParser.parse_configurations(self)
    869 if geometry_optimization is not None:
    870     for cycle in geometry_optimization.get('cycle', []):
--> 871         parse_configuration(cycle)
    873     parse_configuration(geometry_optimization.get('final_energy_evaluation'))
    875     workflow = GeometryOptimization(method=GeometryOptimizationMethod())

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/electronicparsers/orca/parser.py:860, in OrcaParser.parse_configurations.<locals>.parse_configuration(section)
    858 sec_method = self.parse_method(section)
    859 sec_system = self.parse_system(section)
--> 860 sec_scc = self.parse_scc(section)
    861 sec_scc.method_ref = sec_method
    862 sec_scc.system_ref = sec_system

File ~/software/miniconda/envs/nomad/lib/python3.10/site-packages/electronicparsers/orca/parser.py:826, in OrcaParser.parse_scc(self, section)
    824 sec_charges.value = atomic_charges.charge
    825 for atom in range(len(atomic_charges.get('species', []))):
--> 826     for orbital, orbital_charge in orbital_charges.atom[atom].get('charge', []):
    827         sec_charges_value = sec_charges.m_create(ChargesValue, Charges.orbital_projected)
    828         sec_charges_value.atom_index = atom

AttributeError: 'NoneType' object has no attribute 'atom'
lauri-codes commented 1 year ago

@arosen93 Thanks for the report! Looks like a typical parsing issue.

@ladinesa could you take a look and report back here when fixed? If you are busy then I can also take a look.

ladinesa commented 1 year ago

@lauri-codes sorry just came back from holiday, sure I can have a look

ladinesa commented 1 year ago

A fix has been implemented.

Andrew-S-Rosen commented 1 year ago

Fantastic, thanks!