Beispiel #1
0
    def _from_config(cls, executor: dict, config: Config,
                     additional_info: dict):
        args = Args()
        for k, v in executor['args'].items():
            v = str(v)
            if v in ['False', 'True']:
                v = v == 'True'
            elif v.isnumeric():
                v = int(v)

            setattr(args, k, v)

        assert 'report_config' in additional_info, 'layout was not filled'
        report_config = additional_info['report_config']
        grid_cell = additional_info.get('grid_cell')
        report = ReportLayoutInfo(report_config)
        if len(args.configs) == 0:
            args.configs = [args.config]

        grid_config = {}
        if grid_cell is not None:
            grid_config = grid_cells(executor['grid'])[grid_cell][0]

        distr_info = additional_info.get('distr_info', {})
        resume = additional_info.get('resume')
        params = executor.get('params', {})

        return cls(args=args,
                   report=report,
                   grid_config=grid_config,
                   distr_info=distr_info,
                   resume=resume,
                   trace=executor.get('trace'),
                   params=params)
Beispiel #2
0
    def detail(self, id: int):
        report_obj = self.by_id(id)
        tasks = self.query(ReportTasks.task).filter(ReportTasks.report == id
                                                    ).all()
        tasks = [t[0] for t in tasks]
        config = yaml_load(report_obj.config)
        report = ReportLayoutInfo(config)

        series = self.query(ReportSeries). \
            filter(ReportSeries.task.in_(tasks)). \
            order_by(ReportSeries.epoch). \
            options(joinedload(ReportSeries.task_rel, innerjoin=True)).all()

        items = dict()
        for s in report.series:
            items[s.name] = self._detail_series(series, s)

        for element in report.precision_recall + report.f1:
            items[element.name] = self._detail_single_img(id, element)

        for element in report.img_classify:
            items[element.name] = self.detail_img_classify_descr(id, element)

        for element in report.img_segment:
            items[element.name] = self.detail_img_segment_descr(id, element)

        return {
            'data': items,
            'layout': report.layout,
            'metric': report.metric.serialize()
        }
Beispiel #3
0
    def all(self):
        res = {
            s.name: yaml_load(s.content)
            for s in self.query(ReportLayout).all()
        }

        for k, v in res.items():
            res[k] = ReportLayoutInfo.union_layouts(k, res)
        return res
Beispiel #4
0
def report_layout_edit():
    data = request_data()

    provider = ReportLayoutProvider(_write_session)
    layout = provider.by_name(data['name'])
    layout.last_modified = now()
    if 'content' in data and data['content'] is not None:
        data_loaded = yaml_load(data['content'])
        ReportLayoutInfo(data_loaded)
        layout.content = data['content']
    if 'new_name' in data and data['new_name'] is not None:
        layout.name = data['new_name']

    provider.commit()