I have a plot saved as an image in my `catalog.yml...
# questions
g
I have a plot saved as an image in my
catalog.yml
and the file in the file path exists b/c I ran the pipeline.
Copy code
scatter_fte_vs_volume:
  type: matplotlib.MatplotlibWriter
  filepath: data/08_reporting/scatter_fte_vs_volume.png
  save_args:
    format: png
    dpi: 300
When I try to load the image in a Jupyter notebook using the catalog using
catalog.datasets.scatter_fte_vs_volume.load()
I get what is probably a hexadecimal number representing the file in some way. Is there a clean Kedro way to load these sorts of images using the catalog, or should I write an explicit
plt.imread
to the
png
file containing the plot?
g
@Erwin That makes sense. Thank you for looking into my question. I'll just load the images directly using matplotlib.
πŸ‘ 1
e
pillow.ImageDataSet or plotly.PlotlyDataSet can be useful
g
@Erwin Thanks!
n
Should it support loading?
πŸ‘€ 1
g
@Nok Lam Chan I had assumed it should. But I wouldn't claim to know whether it just has not been implemented yet or if there was a design reason why it was not implemented. πŸ€·β€β™‚οΈ
n
Copy code
def _save(
        self, data: Union[plt.figure, List[plt.figure], Dict[str, plt.figure]]
    )
so should the
_load
method return a
plt.figure
? Feel free to open an issue to discuss this and better if you want to patch this with a PR
πŸ‘ 1
Or maybe this is why it’s
MatplotlibWriter
but not Dataset. kedro-datasets: Rename MatplotlibWriter to MatplotlibDataset
πŸ‘ 1
j
yeah this one is tricky, because I would expect a
MatplotlibDataset
to save/load figures , rather than the raw PNG files
πŸ‘πŸΌ 1
πŸ‘ 1
but proper serialization of figures has been an ongoing theme in matplotlib for 14+ years
πŸ‘€ 1
these days you can
pickle
the figure, at least
πŸ’― 1