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)))
def main(self): routes = [ html.link(html.chain(html.span(name), ':', html.code(spec)), spec) for spec, name in self.dash.routes ] page = self.env.get_template('routes.html') return page.render(routes=html.div(html.header('Routes', level=4), html.ul(routes)), state=self.app.state)
def generic_display(self, uid, state, keys=tuple()): types = state.get('types', dict()) def get_types(k, v): return types.get(k, type(v)) items = [] for key, value in state.items(): items.append(self.field_display(uid, key, value, get_types(key, value), *keys)) return html.ul(items)
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())
def list_uids(self): self.meta = self.storage.meta.load(self.storage.folder) # find all the states including best and init all_uid = defaultdict(list) for i in glob.glob(f'{self.storage.folder}/*.state'): filename = i.split('/')[-1][:-6] uid = filename.split('_')[-1] all_uid[uid].append(filename) data = defaultdict(set) for uid, args in self.meta.items(): task = args.pop('task', 'undefined') others = all_uid.get(uid, set()) data[task] = data[task].union(others) data[task].add(uid) items = [] for task, uids in data.items(): items.append(''.join([task, html.ul([html.link(uid, self.subroute(uid)) for uid in uids])])) return html.ul(items)
def list_namespaces(self, queue): return html.div( html.header(queue, level=4), html.ul( html.link(n, f'/{self.base_path}/{queue}/{n}') for n in self.client.namespaces(queue)))
def list_queues(self): return html.ul( html.link(q, f'/{self.base_path}/{q}') for q in self.client.queues())
def list_agents(self, queue, namespace): return html.div( html.header('Agents', level=4), html.ul( html.link(q, f'/{self.base_path}/{queue}/{namespace}/{q.uid}') for q in self.client.agents(namespace)))
def main(self): routes = [ html.link(html.chain(html.span(name), ':', html.code(spec)), spec) for spec, name in self.dash.routes ] return html.div(html.header('Routes', level=4), html.ul(routes))
def list_namespaces(self, queue=WORK_QUEUE): return html.div( html.header('Experiments', level=4), html.ul( html.link(n, f'/{self.base_path}/{n}') for n in self.client.namespaces(queue)))