|
14 | 14 | # ============================================================================== |
15 | 15 | """TensorBoard Plugin asset abstract class. |
16 | 16 |
|
17 | | -TensorBoard plugins may need to write arbitrary assets to disk, such as |
| 17 | +TensorBoard plugins may need to provide arbitrary assets, such as |
18 | 18 | configuration information for specific outputs, or vocabulary files, or sprite |
19 | 19 | images, etc. |
20 | 20 |
|
21 | 21 | This module contains methods that allow plugin assets to be specified at graph |
22 | 22 | construction time. Plugin authors define a PluginAsset which is treated as a |
23 | | -singleton on a per-graph basis. The PluginAsset has a serialize_to_directory |
24 | | -method which writes its assets to disk within a special plugin directory |
25 | | -that the tf.summary.FileWriter creates. |
| 23 | +singleton on a per-graph basis. The PluginAsset has an assets method which |
| 24 | +returns a dictionary of asset contents. The tf.summary.FileWriter |
| 25 | +(or any other Summary writer) will serialize these assets in such a way that |
| 26 | +TensorBoard can retrieve them. |
26 | 27 | """ |
27 | 28 |
|
28 | 29 | from __future__ import absolute_import |
@@ -111,30 +112,30 @@ class PluginAsset(object): |
111 | 112 |
|
112 | 113 | Plugin authors are expected to extend the PluginAsset class, so that it: |
113 | 114 | - has a unique plugin_name |
114 | | - - provides a serialize_to_directory method that dumps its assets in that dir |
115 | | - - takes no constructor arguments |
| 115 | + - provides an assets method that returns an {asset_name: asset_contents} |
| 116 | + dictionary. For now, asset_contents are strings, although we may add |
| 117 | + StringIO support later. |
116 | 118 |
|
117 | 119 | LifeCycle of a PluginAsset instance: |
118 | 120 | - It is constructed when get_plugin_asset is called on the class for |
119 | | - the first time. |
| 121 | + the first time. |
120 | 122 | - It is configured by code that follows the calls to get_plugin_asset |
121 | 123 | - When the containing graph is serialized by the tf.summary.FileWriter, the |
122 | | - writer calls serialize_to_directory and the PluginAsset instance dumps its |
123 | | - contents to disk. |
| 124 | + writer calls assets and the PluginAsset instance provides its contents to be |
| 125 | + written to disk. |
124 | 126 | """ |
125 | 127 | __metaclass__ = abc.ABCMeta |
126 | 128 |
|
127 | 129 | plugin_name = None |
128 | 130 |
|
129 | 131 | @abc.abstractmethod |
130 | | - def serialize_to_directory(self, directory): |
131 | | - """Serialize the assets in this PluginAsset to given directory. |
| 132 | + def assets(self): |
| 133 | + """Provide all of the assets contained by the PluginAsset instance. |
132 | 134 |
|
133 | | - The directory will be specific to this plugin (as determined by the |
134 | | - plugin_key property on the class). This method will be called when the graph |
135 | | - containing this PluginAsset is given to a tf.summary.FileWriter. |
| 135 | + The assets method should return a dictionary structured as |
| 136 | + {asset_name: asset_contents}. asset_contents is a string. |
136 | 137 |
|
137 | | - Args: |
138 | | - directory: The directory path (as string) that serialize should write to. |
| 138 | + This method will be called by the tf.summary.FileWriter when it is time to |
| 139 | + write the assets out to disk. |
139 | 140 | """ |
140 | 141 | raise NotImplementedError() |
0 commit comments