提交 b286628d 编写于 作者: D Dandelion Mané 提交者: TensorFlower Gardener

Automated rollback of change 148478960

Change: 150139549
上级 b083c1b6
......@@ -22,6 +22,7 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import csv
import imghdr
import mimetypes
import os
......@@ -30,7 +31,9 @@ import threading
import time
import six
from six import StringIO
from six.moves import urllib
from six.moves import xrange # pylint: disable=redefined-builtin
from six.moves.urllib import parse as urlparse
from werkzeug import wrappers
......@@ -89,6 +92,7 @@ class _OutputFormat(object):
compressed histograms support CSV).
"""
JSON = 'json'
CSV = 'csv'
def standard_tensorboard_wsgi(logdir, purge_orphaned_data, reload_interval):
......@@ -266,7 +270,14 @@ class TensorBoardWSGIApp(object):
run = request.args.get('run')
values = self._multiplexer.Scalars(run, tag)
return http_util.Respond(request, values, 'application/json')
if request.args.get('format') == _OutputFormat.CSV:
string_io = StringIO()
writer = csv.writer(string_io)
writer.writerow(['Wall time', 'Step', 'Value'])
writer.writerows(values)
return http_util.Respond(request, string_io.getvalue(), 'text/csv')
else:
return http_util.Respond(request, values, 'application/json')
@wrappers.Request.application
def _serve_graph(self, request):
......@@ -331,7 +342,28 @@ class TensorBoardWSGIApp(object):
tag = request.args.get('tag')
run = request.args.get('run')
compressed_histograms = self._multiplexer.CompressedHistograms(run, tag)
return http_util.Respond(request, compressed_histograms, 'application/json')
if request.args.get('format') == _OutputFormat.CSV:
string_io = StringIO()
writer = csv.writer(string_io)
# Build the headers; we have two columns for timing and two columns for
# each compressed histogram bucket.
headers = ['Wall time', 'Step']
if compressed_histograms:
bucket_count = len(compressed_histograms[0].compressed_histogram_values)
for i in xrange(bucket_count):
headers += ['Edge %d basis points' % i, 'Edge %d value' % i]
writer.writerow(headers)
for compressed_histogram in compressed_histograms:
row = [compressed_histogram.wall_time, compressed_histogram.step]
for value in compressed_histogram.compressed_histogram_values:
row += [value.rank_in_bps, value.value]
writer.writerow(row)
return http_util.Respond(request, string_io.getvalue(), 'text/csv')
else:
return http_util.Respond(
request, compressed_histograms, 'application/json')
@wrappers.Request.application
def _serve_images(self, request):
......
......@@ -49,6 +49,7 @@ categories are exclusive.
<style>
:host {
display: block;
padding-bottom: 15px;
}
paper-checkbox {
--paper-checkbox-checked-color: var(--paper-grey-600);
......
......@@ -19,6 +19,7 @@ limitations under the License.
<link rel="import" href="tf-dashboard-layout.html">
<link rel="import" href="tensorboard-color.html">
<link rel="import" href="dashboard-style.html">
<link rel="import" href="tf-downloader.html">
<link rel="import" href="tf-no-data-warning.html">
<script src="reload-behavior.js"></script>
<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-menu/paper-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<dom-module id="tf-downloader">
<template>
<paper-dropdown-menu
no-label-float="true"
label="run to download"
selected-item-label="{{_run}}"
>
<paper-menu class="dropdown-content">
<template is="dom-repeat" items="[[runs]]">
<paper-item no-label-float=true>[[item]]</paper-item>
</template>
</paper-menu>
</paper-dropdown-menu>
<div class="center">
<span>
<a
download="[[_csvName(_run)]]"
href="[[_csvUrl(_run, urlFn)]]"
>CSV</a>
<a
download="[[_jsonName(_run)]]"
href="[[_jsonUrl(_run, urlFn)]]"
>JSON</a>
</span>
</div>
<style>
:host {
display: flex;
height: 32px;
}
.center {
display: flex;
align-self: center;
}
paper-dropdown-menu {
width: 100px;
--paper-input-container-label: {
font-size: 10px;
}
--paper-input-container-input: {
font-size: 10px;
}
}
a {
font-size: 10px;
border-radius: 3px;
border: 1px solid #EEE;
}
paper-input {
font-size: 22px;
}
</style>
</template>
<script>
Polymer({
is: "tf-downloader",
properties: {
_run: String,
runs: Array,
tag: String,
urlFn: Function,
},
_csvUrl: function(_run, urlFn) {
return urlFn(this.tag, _run) + "&format=csv";
},
_jsonUrl: function(_run, urlFn) {
return urlFn(this.tag, _run);
},
_csvName: function(_run) {
return "run_" + _run + ",tag_" + this.tag + ".csv";
},
_jsonName: function(_run) {
return "run-" + _run + "-tag-" + this.tag + ".json";
},
});
</script>
</dom-module>
......@@ -26,7 +26,7 @@ It renders a tf-collapsable-pane for each category. Inside each category, the
provided content template is rendered repeatedly for each tag within that
category.
This helper also incorporates an expand button for
This helper also incorporates an expand button and data download utility for
each card.
To use it, just specify a template inside tf-panes-helper that contains the
......@@ -47,6 +47,10 @@ code that will be replicated for each tag.
If you want for the template to be replicated for each tag and run, not only for
each tag, you can set the repeatForRuns property to true.
You can also set the showDownloadLinks property, which will show a menu with
options to download JSON and CSV data. For this, you must also set the
downloadLinkUrlFunction property to an appropriate value.
@element tf-panes-helper
-->
<dom-module id="tf-panes-helper">
......@@ -87,6 +91,14 @@ each tag, you can set the repeatForRuns property to true.
icon="fullscreen"
on-tap="_toggleExpanded"
></paper-icon-button>
<template is="dom-if" if="[[showDownloadLinks]]">
<tf-downloader
runs="[[item.runs]]"
tag="[[item.tag]]"
url-fn="[[downloadLinkUrlFunction]]"
>
</tf-downloader>
</template>
</div>
</div>
</template>
......@@ -159,6 +171,12 @@ each tag, you can set the repeatForRuns property to true.
.card-expanded .expand-button {
background: var(--tb-ui-light-accent);
}
tf-downloader {
margin-right: 30px;
pointer-events: auto;
}
</style>
</template>
<script>
......@@ -211,6 +229,22 @@ each tag, you can set the repeatForRuns property to true.
* displayed).
*/
selectedRuns: Array,
/**
* If true, shows a menu with download links for the template data.
* If this is set to true, urlFn must also be provided.
*/
showDownloadLinks: Boolean,
/**
* Function that returns the route to get data to download. Must be
* provided if showDownloadLinks is enabled.
*/
downloadLinkUrlFunction: Function,
_contentTemplate: {
type: Object,
value: null
},
_stampedTemplates: {
type: Array,
value: function() { return [] }
......
......@@ -63,6 +63,7 @@ contains vz-histogram-timeseries embedded inside tf-panes-helper's.
run2tag="[[run2tag]]"
runs="[[runs]]"
selected-runs="{{_selectedRuns}}"
show-download-links="{{_showDownloadLinks}}"
>
<div class="sidebar-section">
<tf-option-selector
......
......@@ -67,6 +67,10 @@ contains vz-line-charts embedded inside tf-panes-helper's.
selected-runs="{{_selectedRuns}}"
>
<div class="extend-first-section">
<paper-checkbox
id="download-option"
checked="{{_showDownloadLinks}}"
>Data download links</paper-checkbox>
<div id="tooltip-sorting">
<div id="tooltip-sorting-label">Tooltip sorting method:</div>
<paper-dropdown-menu
......@@ -111,6 +115,8 @@ contains vz-line-charts embedded inside tf-panes-helper's.
data-provider="[[dataProvider]]"
run2tag="[[run2tag]]"
selected-runs="[[_selectedRuns]]"
show-download-links="[[_showDownloadLinks]]"
download-link-url-function="[[scalarUrl]]"
>
<template>
<vz-line-chart
......@@ -183,6 +189,17 @@ contains vz-line-charts embedded inside tf-panes-helper's.
value: "scalar"
},
router: Object,
scalarUrl: {
type: Function,
computed: "_getScalarUrl(router)"
},
_showDownloadLinks: {
type: Boolean,
notify: true,
value: TF.URIStorage.getBooleanInitializer('_showDownloadLinks',
false),
observer: '_showDownloadLinksObserver'
},
_smoothingWeight: {
type: Number,
notify: true,
......@@ -203,6 +220,9 @@ contains vz-line-charts embedded inside tf-panes-helper's.
this.fire("rendered");
});
},
_getScalarUrl: function() {
return this.router.scalars;
},
_showDownloadLinksObserver: TF.URIStorage.getBooleanObserver(
'_showDownloadLinks', false),
_smoothingWeightObserver: TF.URIStorage.getNumberObserver(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册