Ejemplo n.º 1
0
    def _get_warnings_text_and_table(self):
        """
        Return a :py:class:`Table <lab.reports.Table>` containing one line for
        each run where an unexplained error occured.
        """
        if not self.ERROR_ATTRIBUTES:
            logging.critical("The list of error attributes must not be empty.")

        table = reports.Table(title="Unexplained errors")
        table.set_column_order(self.ERROR_ATTRIBUTES)

        wrote_to_slurm_err = any(
            "output-to-slurm.err" in run.get("unexplained_errors", [])
            for run in self.runs.values())

        for run in self.runs.values():
            error_message = tools.get_unexplained_errors_message(run)
            if error_message:
                logging.error(error_message)
                run_dir = run["run_dir"]
                for attr in self.ERROR_ATTRIBUTES:
                    value = run.get(attr, "?")
                    if attr == "unexplained_errors":
                        value = self._format_unexplained_errors(value)
                        # Use formatted value as-is.
                        table.cell_formatters[run_dir][
                            attr] = reports.CellFormatter()
                    table.add_cell(run_dir, attr, value)

        errors = []

        if wrote_to_slurm_err:
            src_dir = self.eval_dir.rstrip("/")[:-len("-eval")]
            slurm_err_file = src_dir + "-grid-steps/slurm.err"
            try:
                slurm_err_content = tools.get_slurm_err_content(src_dir)
            except FileNotFoundError:
                slurm_err_file = "*-grid-steps/slurm.err"
                errors.append(
                    f"There was output to {slurm_err_file}, but the file was missing "
                    f"when this report was made.")
            else:
                slurm_err_content = tools.filter_slurm_err_content(
                    slurm_err_content)
                errors.append(
                    f"There was output to {slurm_err_file}. Below is the output without"
                    f'"memory cg" errors:\n```\n{slurm_err_content}\n```')
            logging.error(f"There was output to {slurm_err_file}.")

        if table:
            errors.append(str(table))

        infai_1_nodes = {f"ase{i:02d}.cluster.bc2.ch" for i in range(1, 25)}
        infai_2_nodes = {f"ase{i:02d}.cluster.bc2.ch" for i in range(31, 55)}
        nodes = self._get_node_names()
        if nodes & infai_1_nodes and nodes & infai_2_nodes:
            errors.append(
                "Report combines runs from infai_1 and infai_2 partitions.")

        return "\n".join(errors)
Ejemplo n.º 2
0
    def _get_empty_table(self, attribute=None, title=None, columns=None):
        """Return an empty table."""
        if title is None:
            assert attribute is not None
            title = attribute
            if self.output_format == 'tex':
                title = title.capitalize().replace('_', ' ')
        if columns is None:
            columns = self.algorithms

        if attribute is not None and self.attribute_is_numeric(attribute):
            # Decide whether we want to highlight minima or maxima.
            kwargs = {
                'min_wins': attribute.min_wins,
                'colored': self.colored and attribute.min_wins is not None,
                'digits': attribute.digits,
            }
        else:
            # Do not highlight anything.
            kwargs = {}
        table = reports.Table(title=title, **kwargs)
        table.set_column_order(columns)
        link = '#%s' % title
        formatter = reports.CellFormatter(link=link)
        table.cell_formatters[table.header_row][
            table.header_column] = formatter
        return table
Ejemplo n.º 3
0
 def _get_general_info(self):
     table = reports.Table(title='algorithm')
     for config, info in self.config_info.items():
         for attr in self.INFO_ATTRIBUTES:
             table.add_cell(config, attr, info[attr])
     table.set_column_order(self.INFO_ATTRIBUTES)
     return str(table)
Ejemplo n.º 4
0
 def _get_warnings_table(self):
     """
     Returns a :py:class:`Table <lab.reports.Table>` containing one line for
     each run where an unexpected error occured.
     """
     columns = ['domain', 'problem', 'config', 'error',
                'search_wall_clock_time', 'memory']
     table = reports.Table(title='Unexplained errors')
     table.set_column_order(columns)
     for run in self.props.values():
         if run.get('error', '').startswith('unexplained'):
             for column in columns:
                 table.add_cell(run['run_dir'], column, run.get(column, '?'))
     return table
Ejemplo n.º 5
0
    def _get_general_info(self):
        table = reports.Table(title='algorithm')
        for algo, info in self.algorithm_info.items():
            for attr in self.INFO_ATTRIBUTES:
                if info[attr]:
                    table.add_cell(algo, attr, info[attr])
        table.set_column_order(self.INFO_ATTRIBUTES)

        node_info = "Used nodes: {{{}}}".format(", ".join(
            _abbreviate_node_names(self._get_node_names())))

        if table:
            return str(table) + "\n" + node_info
        else:
            logging.warning('Table containing algorithm information is empty.')
            return node_info
Ejemplo n.º 6
0
 def _get_empty_table(self, attribute=None, title=None, columns=None):
     """Return an empty table."""
     if title is None:
         assert attribute is not None
         title = attribute
     if columns is None:
         columns = self.configs
     if attribute is not None and self.attribute_is_numeric(attribute):
         # Decide whether we want to highlight minima or maxima.
         min_wins = attribute.min_wins
         colored = self.colored and min_wins is not None
     else:
         # Do not highlight anything.
         min_wins = None
         colored = False
     table = reports.Table(title=title, min_wins=min_wins, colored=colored)
     table.set_column_order(columns)
     if self.resolution == 'combined':
         link = '#%s' % title
         formatter = reports.CellFormatter(link=link)
         table.cell_formatters[table.header_row][table.header_column] = formatter
     return table
Ejemplo n.º 7
0
    def _get_commulative_table(self, domain):
        #init new table
        title = 'Commulative'
        columns = {'Percentage', 'h*/h(s)'}
        min_wins = False
        colored = True
        table = reports.Table(title=title, min_wins=min_wins, colored=colored)
        table.set_column_order(columns)
        link = '#%s' % title
        formatter = reports.CellFormatter(link=link)
        table.cell_formatters[table.header_row][
            table.header_column] = formatter
        domain_dir = self.outFile + '/' + domain
        tools.makedirs(domain_dir)
        domain_file = domain_dir + '/' + 'PAC_Commulative_ratio.csv'
        file = open(domain_file, "w")

        #get relevant value from original table
        ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True)
        ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain)
        #define arrays to work
        ratios = [
            0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3,
            1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9,
            1.95, 2, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5,
            2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3.0, 3.05, 3.1,
            3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45, 3.5, 3.55, 3.6, 3.65, 3.7,
            3.75, 3.80, 3.85, 3.9, 3.95, 4.0, 4.05, 4.1, 4.15, 4.2, 2.25, 4.3,
            4.35, 4.4, 4.45, 4.5
        ]
        names = [
            'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
            'za', 'zb', 'zc', 'zd', 'ze', 'zf', 'zg', 'zh', 'zi', 'zj', 'zk',
            'zl', 'zm', 'zn', 'zo', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag',
            'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar',
            'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ba', 'bb', 'bc',
            'bd', 'be', 'bf', 'bg', 'bh', 'bi'
        ]
        counter = 0

        #calculate number of solved problems
        total_solved = 0
        for row in ratio_table.row_names:
            curr_val = ratio_table.get(row)
            val = curr_val[self.nick]
            if val > 0:
                total_solved = total_solved + 1

        #for each ratio (1,1.05...), find the number of problems with this ratio, calc percentage and add row
        for ratio in ratios:
            _sum = 0
            for row in ratio_table.row_names:
                curr_val = ratio_table.get(row)
                val = curr_val[self.nick]
                if val <= ratio and val > 0:
                    _sum = _sum + 1

            if total_solved == 0:
                _sum_percent = 0
            else:
                _sum_percent = _sum * 100 / total_solved

            #add new row
            row_to_add = {}
            row_to_add['Percentage'] = _sum_percent
            row_to_add['h*/h(s)'] = ratio
            table.add_row(names[counter], row_to_add)
            counter = counter + 1
            #TODO - save only one ratio per percentage
            toWrite = str(ratio) + ',' + str(_sum_percent) + '\n'
            file.write(toWrite)

        file.close()

        self.create_commulative_h_star_table(domain)

        return table
Ejemplo n.º 8
0
    def _get_warnings_text_and_table(self):
        """
        Return a :py:class:`Table <lab.reports.Table>` containing one line for
        each run where an unexplained error occured.
        """
        if not self.ERROR_ATTRIBUTES:
            logging.critical('The list of error attributes must not be empty.')

        table = reports.Table(title='Unexplained errors')
        table.set_column_order(self.ERROR_ATTRIBUTES)

        wrote_to_slurm_err = any(
            'output-to-slurm.err' in run.get('unexplained_errors', [])
            for run in self.runs.values())

        num_unexplained_errors = 0
        for run in self.runs.values():
            error_message = tools.get_unexplained_errors_message(run)
            if error_message:
                logging.error(error_message)
                num_unexplained_errors += 1
                for attr in self.ERROR_ATTRIBUTES:
                    table.add_cell(run['run_dir'], attr, run.get(attr, '?'))

        if num_unexplained_errors:
            logging.error(
                'There were {num_unexplained_errors} runs with unexplained'
                ' errors.'.format(**locals()))

        errors = []

        if wrote_to_slurm_err:
            src_dir = self.eval_dir.rstrip('/')[:-len('-eval')]
            slurm_err_file = src_dir + '-grid-steps/slurm.err'
            try:
                slurm_err_content = tools.get_slurm_err_content(src_dir)
            except IOError:
                slurm_err_content = (
                    'The slurm.err file was missing while creating the report.'
                )
            else:
                slurm_err_content = tools.filter_slurm_err_content(
                    slurm_err_content)

            logging.error(
                'There was output to {slurm_err_file}.'.format(**locals()))

            errors.append(
                ' Contents of {slurm_err_file} without "memory cg"'
                ' errors:\n```\n{slurm_err_content}\n```'.format(**locals()))

        if table:
            errors.append(str(table))

        infai_1_nodes = set('ase{:02d}.cluster.bc2.ch'.format(i)
                            for i in range(1, 25))
        infai_2_nodes = set('ase{:02d}.cluster.bc2.ch'.format(i)
                            for i in range(31, 55))
        nodes = self._get_node_names()
        if nodes & infai_1_nodes and nodes & infai_2_nodes:
            errors.append(
                'Report combines runs from infai_1 and infai_2 partitions.')

        return '\n'.join(errors)