Exemple #1
0
    def show_param(self, model, module_name, param_name, model2, uid2):
        if model2 is not None:
            layers = dict(list_layers(model2))
            layer = layers[module_name]
            params = dict(layer.named_parameters())
            param2 = params[param_name]

        layers = dict(list_layers(model))
        layer = layers[module_name]
        params = dict(layer.named_parameters())
        param = params[param_name]

        if model2 is not None:
            param = param - param2

        title = param_name
        if model2 is not None:
            title = f'{param_name} - {uid2}'

        return html.div_row(
            html.div_col(
                html.header(f'Module {module_name}', level=4),
                html.pre(str(layer)), html.header('Parameters', level=4),
                html.ul([
                    self.parameter_link(k, v, uid2) for k, v in params.items()
                ])),
            html.div_col(html.header(title, level=4),
                         self.vizualize_param(param)))
Exemple #2
0
    def show_overview(self, queue, group=None, delimiter=None):
        # Try to show an overview of the entire system
        if self.aggregate is None:
            try:
                self.aggregate = self.client.aggregate_monitor()
            except Exception as  e:
                print(e)
                return self.list_namespaces(queue)

        data = defaultdict(lambda: dict(unread=0, unactioned=0, actioned=0, lost=0, failed=0, agent=0, runtime=0))
        insert(data, self.aggregate.unread_count(queue, group, delimiter=delimiter), 'unread')
        insert(data, self.aggregate.unactioned_count(queue, group, delimiter=delimiter), 'unactioned')
        insert(data, self.aggregate.actioned_count(queue, group, delimiter=delimiter), 'actioned')
        insert(data, self.aggregate.lost_count(queue, group, delimiter=delimiter), 'lost')
        insert(data, self.aggregate.failed_count(queue, group, delimiter=delimiter), 'failed')

        for group, info in data.items():
            print(group, info)

        name = 'experiment'
        if delimiter is not None:
            name = 'study'

        status, agents = prepare_overview_altair(data)
        chart = aggregate_overview_altair(status, name)

        return html.div(
            html.header('Status', level=3),
            html.div_row(
                html.div_col(html.altair_plot(chart), style='height:100vh;', size=5),
                html.div_col(list_experiment_stats(self.base_path, queue, data.keys(), data, nolink=delimiter is not None))
            )
        )
Exemple #3
0
    def parameter_selection(self, model, module_name):
        layers = dict(list_layers(model))
        layer = layers[module_name]
        params = layer.named_parameters()

        return html.div_row(
            html.div_col(html.header(f'Module {module_name}', level=4),
                         html.pre(str(layer)),
                         html.header('Parameters', level=4),
                         html.ul(
                             [self.parameter_link(k, v) for k, v in params]),
                         style="height: 100vh;"), html.div_col())
Exemple #4
0
    def show_queue(self, queue, namespace):
        # unread_messages = self.client.unread_messages(queue, namespace)
        # unactioned = self.client.unactioned_messages(queue, namespace)

        unread = self.client.unread_count(queue, namespace)
        unactioned = self.client.unactioned_count(queue, namespace)
        finished = self.client.actioned_count(queue, namespace)

        lost = self.client.lost_messages(queue, namespace)
        failed = self.client.failed_messages(queue, namespace)

        agents = self.get_unique_agents(queue, namespace)

        data = {
            'pending': unread,
            'running': unactioned,
            'finished': finished,
            'lost': len(lost),
            'failed': len(failed)
        }

        fig = work_status(data)
        fig.update_layout(template='plotly_dark')

        return html.div(
            html.header(f'Status', level=3),
            html.div_row(
                html.div_col(
                    html.header('Tasks', level=5),
                    html.plotly_plot(fig), size=4),
                html.div_col(
                    html.header('Agents', level=5),
                    html.show_agent(agents))),
            html.div_row(
                html.div_col(
                    html.header('Lost', level=5),
                    html.show_messages(lost[:10])),
                html.div_col(
                    html.header('Failed', level=5),
                    html.show_messages(failed[:10]))))
Exemple #5
0
    def main(self, study=None, section=None):
        if study is None:
            return self.select_study()

        self.title = f'Study {study.capitalize()}'
        section_html = self.sections.get(section, self.no_section)(study,
                                                                   section)

        return html.div_col(html.header(f'Study: {study.capitalize()}'),
                            html.div_row(
                                self.sidebar(study),
                                html.div_col(section_html,
                                             classes='col py-2')),
                            classes="container-fluid")
Exemple #6
0
    def main(self, experiment=None, section=None):
        if experiment is None:
            return self.list_namespaces()

        # call the section render function
        section_html = self.sections.get(section, self.no_section)(experiment,
                                                                   section)

        return html.div_col(html.header(experiment),
                            html.div_row(
                                self.sidebar(experiment),
                                html.div_col(section_html,
                                             classes='col py-2')),
                            classes="container-fluid")
Exemple #7
0
    def show_queue(self, queue, namespace, delimiter=None):
        args = (queue, namespace)
        kwargs = {}
        if delimiter:
            kwargs['delimiter'] = delimiter

        messages = self.client.messages(*args, **kwargs)
        data = list(objective_array(messages))

        if len(data) == 0:
            return "No Metric"

        self.sample = data[-1]
        self.columns = list(data[-1].keys())
        self.data = alt.Data(values=data)
        form = self.form(self.columns, self.sample)
        return html.div_row(
            html.div_col(form, size=2, style="height: 100vh;"),
            html.div_col(html.iframe("", id=self.graph_id), id='graph_container', style='width: 100vh; height: 100vh;'))
Exemple #8
0
    def vizualize_param(self, param):
        param = param.squeeze()
        shape = param.shape

        # Simple Heatmap/bar will done
        if len(shape) <= 2:
            fig = vizualize_param(param)
            return html.pyplot_plot(fig)

        # Need to select dimensions to analyze
        self.data = param
        html_forms = []
        self.inputs = []

        for s in shape[:-2]:
            v, html_input = js.number_input(min=0,
                                            max=s - 1,
                                            callback=self.update_plot)
            self.inputs.append(v)
            html_forms.append(html_input)

        return html.div_row(html.div_col(html.chain(*html_forms)),
                            html.iframe("", id='weight_plot'),
                            style="height: 100vh;")