Tensorboard Plugins: Using Plugin Names

The Issue

I am unable to figure out how to make a custom plugin with a custom summary writer.

I have coded up a custom plugin which just stores some strings, which is essentially equivalent to the text plugin. The frontend works great, but now looking at the backend, if I give a custom name to the plugin, the tags and values don’t show up.

What works and what doesn’t?

These two variables, if set to the value text, then the function works.

  • PLUGIN_NAME = "text" in the Summary Writer
  • loader_name = "text" in Molecular Graph Plugin

However if we try to set both to the value molecular_graph, so that these strings only show up in my plugin and not in the text plugin, the tags and the data just stop showing. Even my plugin is unable to get these.

The tensorboard example to show custom log writer is not working for me, which I have reported: `context.multiplexer` is None, `example_basic` plugin doesn't work · Issue #5355 · tensorflow/tensorboard · GitHub

My core question!

How to make a summary writer and a plugin which have a custom name so that the data send to them is not seen by other default plugins.

Code for The Plugin

Summary Writer

This is the function to write the logs in the tfevents files.

PLUGIN_NAME = "molecular_graph"

def _create_summary_metadata(display_name, description):
    content = plugin_data_pb2.TextPluginData(version=0)
    metadata = summary_pb2.SummaryMetadata(
        display_name=display_name,
        summary_description=description,
        plugin_data=summary_pb2.SummaryMetadata.PluginData(
            plugin_name=PLUGIN_NAME, content=content.SerializeToString()
        ),
    )
    return metadata

def molecule_smiles(name, data, step=None, description=None):
    summary_metadata = _create_summary_metadata(
        display_name=None, description=description)
    with tf.summary.experimental.summary_scope(
            name, "molecular_graph_summary", values=[data, step]) as (tag, _):
        tf.debugging.assert_type(data, tf.string)
        return tf.summary.write(
            tag=tag, tensor=data, step=step, metadata=summary_metadata)

Graph Plugin

I have omitted the constructor which takes in the context, and stores the data provider from it. It also omits the path specifications, just shows the function which returns the tags.

class MolecularGraphPlugin(base_plugin.TBPlugin):
    plugin_name = "molecular_graph"
    plugin_path = "/data/plugin/molecular_graph/"
    loader_name = "molecular_graph"

    @wrappers.Request.application
    def tags_route(self, request):
        ctx = plugin_util.context(request.environ)
        experiment = plugin_util.experiment_id(request.environ)
        mapping = self._data_provider.list_tensors(
            ctx,
            experiment_id=experiment,
            plugin_name=self.loader_name,
        )
        result = {run: [] for run in mapping}
        for (run, tag_to_content) in mapping.items():
            for (tag, meta_datum) in tag_to_content.items():
                result[run].append(tag)                
        return http_util.Respond(request, result, "application/json")