def test_as_html(self): # given from bokeh.plotting import figure # given p = figure(plot_width=400, plot_height=400) p.circle(size=20, color="navy", alpha=0.5) # when file = File.as_html(p) # then self.assertEqual(file.extension, "html") self.assertTrue( file.content.startswith( '\n\n\n\n<!DOCTYPE html>\n<html lang="en">'.encode("utf-8")))
def on_epoch_end(self, trainer, pl_module): if self.run is None: return all_datasets = [] for sentence in self.sentences: datasets = get_datasets_from_sentence(pl_module, self.tokenizer, sentence) all_datasets.append('|'.join(datasets)) df = pd.DataFrame({ 'sentence': self.sentences, 'datasets': all_datasets }) self.run[f'display_{pl_module.current_epoch}'].upload(File.as_html(df))
def on_epoch_end(self, trainer, pl_module): if self.run is None: return all_datasets = [] ids = [] for doc in self.docs: ids.append(doc.document_id) sentences = SentenceExtractor.get_all_valid_sentences(doc) datasets = [] for sentence in sentences: datasets.append( get_datasets_from_sentence(pl_module, self.tokenizer, sentence)) datasets = reduce(lambda a, b: a + b, datasets) datasets = list(set(datasets)) all_datasets.append('|'.join(datasets)) df = pd.DataFrame({'document_id': ids, 'datasets': all_datasets}) self.run[f'submission_{pl_module.current_epoch}'].upload( File.as_html(df))