How to visualize HTML run in Kubeflow Pipeline?

Hello,

We use Pytorch Lightning for training and we use Kubeflow Pipelines and are thinking about using wandb to track and visualize the training and test metrics.

Kubeflow pipelines offers the possibility to view a static html page (see this link ).
I was wondering if it would be possible via the wandb python sdk to get a read-only embeded code (iframe) that I could then simply pass to Kubeflow pipeline sdk to show the html ?

Thanks

UPDATE :
After checking the doc further I came across wandb_logger.experiment.to_html() which seems to do exactly what I wanted but I still need to find a way to authenticate for read only anonymous viewer.
Is it possible to generate an html iframe with the API token built-into the url? Something like wandb_logger.experiment.to_html(api_key=$API_KEY)

Or is it possible to set environment variables so that when we visit the url in the iframe we get authentication automatically? The Kubeflow ml-pipeline-ui pod can have secrets/env variables.

After some tests it looks like the auth part works out-of-the-box in Kubeflow.
But there is one issue, Kubeflow HTML output creates an iframe with a srcdoc that contains our html.
Therefore if we pass an iframe to kubeflow, then we’ll end up with an iframe (from the viewer) with a nested iframe (from wandb .to_html()) and the nested iframe is not displayed ( I think the iframe’s srcdoc expects raw static html).

Is there a way I could export a wandb run to STATIC html or perhaps there is a way to make the inner iframe display?

Ok I found the solution.
Kubeflow Pipelines also support markdown visualization therefore instead of using kubeflow HTML output I used markdown and since markdown supports html inline I was able to directly use the wandb run html.

Here is the code if someone is interested :

import kfp
from kfp.v2.dsl import component, Output, Markdown, pipeline

@component(packages_to_install=['wandb'])
def wandb_visualization(markdown_artifact: Output[Markdown]):
    import wandb
    wandb.login(key="you_key")

    run = wandb.init(project="your-project", entity="your-entity")

    wandb.log({"train/loss" : 5.0})
    wandb.log({"train/loss" : 4.0})
    wandb.log({"train/loss" : 3.0})
    wandb.log({"train/loss" : 2.0})
    wandb.log({"train/loss" : 1.0})

    wandb.finish()
    with open(markdown_artifact.path, 'w') as f:
        f.write(f"<iframe src=\"{run.get_url()}\" width=\"100%\" height=\"700\"/>")

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.