def set_worksheet_values(worksheet: Worksheet, values: List[list]):
    _log.debug("clearing worksheet: %s ...", worksheet)
    worksheet.clear()
    cells = convert_values_to_cells(values)
    _log.debug("updating worksheet values...")
    worksheet.update_cells(cells)
    _log.debug("worksheet values has been set!")
def append_worksheet_values(worksheet: Worksheet, values: List[list]):
    _log.debug("appending %s rows values to worksheet...", len(values))

    cells = convert_values_to_cells(values,
                                    start_row=len(worksheet.col_values(1)) + 1)
    worksheet.add_rows(len(values))
    worksheet.update_cells(cells)
Exemple #3
0
    def done(self,
             ws: Worksheet,
             env: Env,
             results: Optional[Dict[str, int]] = None,
             prefix_metrics: Optional[str] = None):
        self.update_state(ws, State.done, env)

        if env != Env.eval:
            self.update_date(ws, env, TestProgress.end, datetime.now())

        metrics = [
            Metrics.loss, Metrics.accuracy, Metrics.f1_score, Metrics.miou,
            Metrics.precision, Metrics.recall
        ]

        cells = []

        prefix_col = '' if env == Env.train else f'{env.value}_'
        for m in metrics:
            cell = ws.cell(self.id + 1,
                           self.columns.index(prefix_col + m.value) + 1)
            value = results[(prefix_metrics or '') + m.value]
            cell.value = "{:.6f}".format(value).replace('.', ',')
            cells.append(cell)

        if env != env.test:
            for m in metrics:
                name_key_best_val = f'best_{prefix_col}{m.value}'
                cell = ws.cell(self.id + 1,
                               self.columns.index(name_key_best_val) + 1)
                value = results['best_' + (prefix_metrics or '') + m.value]
                cell.value = "{:.6f}".format(value).replace('.', ',')
                cells.append(cell)
        cell = ws.cell(self.id + 1, self.columns.index('machine') + 1)
        cell.value = socket.gethostname()
        ws.update_cells([*cells, cell])