Ejemplo n.º 1
0
 def parse_log_file(self, compute_stress=False):
     """Parse the log file."""
     output_filename = self.node.get_option("output_filename")
     output_txt = self.retrieved.get_object_content(output_filename)
     try:
         output_data = read_log_file(output_txt, compute_stress=compute_stress)
     except Exception:
         traceback.print_exc()
         return None, self.exit_codes.ERROR_LOG_PARSING
     return output_data, None
Ejemplo n.º 2
0
    def parse_with_retrieved(self, retrieved):
        """
        Parses the datafolder, stores results.
        """

        # suppose at the start that the job is successful
        successful = True

        # select the folder object
        # Check that the retrieved folder is there
        try:
            out_folder = retrieved[self._calc._get_linkname_retrieved()]
        except KeyError:
            self.logger.error("No retrieved folder found")
            return False, ()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        # OUTPUT file should exist
        if not self._calc._OUTPUT_FILE_NAME in list_of_files:
            successful = False
            self.logger.error("Output file not found")
            return successful, ()

        # Get file and do the parsing
        outfile = out_folder.get_abs_path(self._calc._OUTPUT_FILE_NAME)
        ouput_trajectory = out_folder.get_abs_path(
            self._calc._OUTPUT_TRAJECTORY_FILE_NAME)

        outputa_data = read_log_file(outfile)
        forces = read_lammps_forces(ouput_trajectory)

        # look at warnings
        warnings = []
        with open(out_folder.get_abs_path(self._calc._SCHED_ERROR_FILE)) as f:
            errors = f.read()
        if errors:
            warnings = [errors]

        # ====================== prepare the output node ======================

        # save the outputs
        new_nodes_list = []

        # save trajectory into node

        array_data = ArrayData()
        array_data.set_array('forces', forces)
        new_nodes_list.append(('output_array', array_data))

        # add the dictionary with warnings
        outputa_data.update({'warnings': warnings})

        parameters_data = ParameterData(dict=outputa_data)
        new_nodes_list.append((self.get_linkname_outparams(), parameters_data))

        # add the dictionary with warnings
        # new_nodes_list.append((self.get_linkname_outparams(), ParameterData(dict={'warnings': warnings})))

        return successful, new_nodes_list