flytekit
flytekit copied to clipboard
update markdown renderer to create tables
Why are the changes needed?
It would be nice to render pandas dataframes as tables in decks using markdown (df.to_markdown()). To do this we need to the table plugin of markdown-it-py enabled.
What changes were proposed in this pull request?
Enable table plugin for markdown-it-py.
How was this patch tested?
data = {
'id': np.arange(1, 11),
'name': [f'Item {i}' for i in range(1, 11)],
'value': np.random.rand(10) * 100,
'category': np.random.choice(['A', 'B', 'C'], size=10),
'timestamp': pd.date_range('2023-01-01', periods=10, freq='D')
}
df = pd.DataFrame(data)
md_df = df.to_markdown()
flytekit.current_context().default_deck.append(
MarkdownRenderer().to_html(md_df)
)
html before change:
html after change:
Check all the applicable boxes
- [ ] I updated the documentation accordingly.
- [ ] All new and existing tests passed.
- [ ] All commits are signed-off.
Docs link
Link to the markdown-it-py docs: https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser