def dump_data(logdir):
"""Dumps plugin data to the log directory."""
plugin_logdir = plugin_asset_util.PluginDirectory(
logdir, profile_plugin.ProfilePlugin.plugin_name)
_maybe_create_directory(plugin_logdir)
for run in profile_demo_data.RUNS:
run_dir = os.path.join(plugin_logdir, run)
_maybe_create_directory(run_dir)
if run in profile_demo_data.TRACES:
with open(os.path.join(run_dir, 'trace'), 'w') as f:
proto = trace_events_pb2.Trace()
text_format.Merge(profile_demo_data.TRACES[run], proto)
f.write(proto.SerializeToString())
shutil.copyfile('tensorboard/plugins/profile/profile_demo.op_profile.json',
os.path.join(run_dir, 'op_profile.json'))
# Unsupported tool data should not be displayed.
run_dir = os.path.join(plugin_logdir, 'empty')
_maybe_create_directory(run_dir)
with open(os.path.join(run_dir, 'unsupported'), 'w') as f:
f.write('unsupported data')
评论列表
文章目录