Hi! I've been tinkering with an
experimental @step decorator related to this using a memory profiler called
memray. It wraps the step function, like how
this minimal example does, then adds cards and Metaflow artifacts containing the HTML files produced by memray.
Here is the current implementation.
There is some bug I've introduced so sometimes cards aren't getting rendered correctly in Metaflow GUI, but it reliably produces the HTML for a flamegraph, a table ranking the most expensive operations, and a histogram of the allocation sizes.