def parse_from_calc(self):
from aiida.common.exceptions import InvalidOperation<EOL>from aiida.common import aiidalogger<EOL>from aiida.backends.djsite.utils import get_dblogger_extra<EOL>import ase, ase.io<EOL>parserlogger = aiidalogger.getChild('<STR_LIT>')<EOL>logger_extra = get_dblogger_extra(self._calc)<EOL>successful = True<EOL>state = self._calc.get_state()<EOL>if state != calc_states.PARSING:<EOL><INDENT>raise InvalidOperation("<STR_LIT>"<EOL>.format(calc_states.PARSING) )<EOL><DEDENT>out_folder = self._calc.get_retrieved_node()<EOL>list_of_files = out_folder.get_folder_list()<EOL>if not self._calc._OUTPUT_FILE_NAME in list_of_files:<EOL><INDENT>successful = False<EOL>parserlogger.error("<STR_LIT>",extra=logger_extra)<EOL>return successful,()<EOL><DEDENT>has_out_atoms = True if self._calc._output_aseatoms in list_of_files else False<EOL>if has_out_atoms:<EOL><INDENT>out_atoms = ase.io.read( out_folder.get_abs_path( self._calc._output_aseatoms ) )<EOL>out_structure = StructureData().set_ase(out_atoms)<EOL><DEDENT>json_outfile = out_folder.get_abs_path( self._calc._OUTPUT_FILE_NAME )<EOL>with open(json_outfile,'<STR_LIT:r>') as f:<EOL><INDENT>json_params = json.load(f)<EOL><DEDENT>dictionary_array = {}<EOL>for k,v in list(json_params.iteritems()):<EOL><INDENT>if isinstance(v, (list,tuple)):<EOL><INDENT>dictionary_array[k] = json_params.pop(k)<EOL><DEDENT><DEDENT>warnings = []<EOL>with open(out_folder.get_abs_path( self._calc._SCHED_ERROR_FILE )) as f:<EOL><INDENT>errors = f.read()<EOL><DEDENT>if errors:<EOL><INDENT>warnings = [errors]<EOL><DEDENT>json_params['<STR_LIT>'] = warnings<EOL>new_nodes_list= []<EOL>if dictionary_array:<EOL><INDENT>array_data = ArrayData()<EOL>for k,v in dictionary_array.iteritems():<EOL><INDENT>array_data.set_array(k,numpy.array(v))<EOL><DEDENT>new_nodes_list.append( (self._outarray_name, array_data) )<EOL><DEDENT>if json_params:<EOL><INDENT>parameter_data = ParameterData( dict=json_params )<EOL>new_nodes_list.append( (self._outdict_name, parameter_data) )<EOL><DEDENT>if has_out_atoms:<EOL><INDENT>structure_data = StructureData()<EOL>new_nodes_list.append( (self._outstruc_name, structure_data) )<EOL><DEDENT>return successful,new_nodes_list<EOL>
Parses the datafolder, stores results.
This parser for this simple code does simply store in the DB a node
representing the file of forces in real space