import io
from metaflow import FlowSpec, step, card, current
from metaflow.cards import Image

class PlotlyFlow(FlowSpec):

    def make_plot(self):
        import plotly.express as px
        fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
        with io.BytesIO() as buf:
            fig.write_image(buf)
            current.card.append(Image(buf.getvalue()))

    @card(type='blank')
    @step
    def start(self):
        self.make_plot()
        self.next(self.end)

    @step
    def end(self):
        pass

if __name__ == '__main__':
    PlotlyFlow()