Creating custom visualizations

Creating your own visualizations.

There are two ways how you can add custom visualizations to the dashboard:

If you are already handling HTML, Markdown, or CSV data in one of your steps, you can have them visualized in just a few lines of code by casting them to a special class inside your step.

If you want to automatically extract visualizations for all artifacts of a certain data type, you can define type-specific visualization logic by building a custom materializer.

If you want to create any other custom visualizations, you can create a custom return type class with corresponding materializer and build and return this custom return type from one of your steps.

Visualization via Special Return Types

If you already have HTML, Markdown, or CSV data available as a string inside your step, you can simply cast them to one of the following types and return them from your step:

zenml.types.HTMLString for strings in HTML format, e.g., "<h1>Header</h1>Some text",

zenml.types.MarkdownString for strings in Markdown format, e.g., "# Header\nSome text",

zenml.types.CSVString for strings in CSV format, e.g., "a,b,c\n1,2,3".

Example:

from zenml.types import CSVString

@step

def my_step() -> CSVString:

some_csv = "a,b,c\n1,2,3"

return CSVString(some_csv)

This would create the following visualization in the dashboard:

Visualization via Materializers

If you want to automatically extract visualizations for all artifacts of a certain data type, you can do so by overriding the save_visualizations() method of the corresponding materializer. See the materializer docs page for more information on how to create custom materializers that do this.

Visualization via Custom Return Type and Materializer

By combining the ideas behind the above two visualization approaches, you can visualize virtually anything you want inside your ZenML dashboard in three simple steps:

Create a custom class that will hold the data that you want to visualize.