Skip to content

Conversation

@meyerjo
Copy link

@meyerjo meyerjo commented Jan 28, 2019

  • Motivation for features / changes

This pull requests add the option to download the raw histogram data as described in #1275

  • Technical description of changes
  • Add the checkbox "Show data download links" to the histogram page.
  • Add the download dialog to the individual histogram cards
  • Change the Query for the histograms in order to allow filtering for the individual experiment
  • Screenshots of UI changes

The button to trigger the download buttons:

image

The download selection for the data:
image

  • Detailed steps to verify changes work correctly (as executed by you)
  • Open a tensorboard with histogram data
  • Go to the histograms page
  • Select "Show data download links"
  • Select experiment in the histograms card
  • Download CSV or JSON
  • Alternate designs / implementations considered
  • Regarding the CSV Export: So far, all the BinStart, BinEnd, BinValue fields are a consecutive string which in itself is ';' separated. Thus, one has 5 comma separated columns. One could also just comma separate these values, but this could lead to an inconsistent number of columns.

@meyerjo
Copy link
Author

meyerjo commented Jan 28, 2019

image

Changed the alignment of the download bar

@meyerjo
Copy link
Author

meyerjo commented Jan 30, 2019

Don't really see the reason for build failing. The error says pandas is missing. However, this PR did not remove or add any pandas import.

Copy link
Contributor

@nfelt nfelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!


def get_plugin_apps(self):
return {
'/histograms': self.histograms_route,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the whitespace changes to indentation - continuation lines should be indented +4 spaces

class OutputFormat(object):
"""An enum used to list the valid output formats for API calls."""
JSON = 'json'
CSV = 'csv'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for the CSV output format. See e.g. the equivalent test for the scalars plugin:

def _test_scalars_csv(self, run_name, tag_name, should_work=True):
self.set_up_with_runs([self._RUN_WITH_LEGACY_SCALARS,
self._RUN_WITH_SCALARS,
self._RUN_WITH_HISTOGRAM])
if should_work:
(data, mime_type) = self.plugin.scalars_impl(
tag_name, run_name, None, scalars_plugin.OutputFormat.CSV)
self.assertEqual('text/csv', mime_type)
s = StringIO(data)
reader = csv.reader(s)
self.assertEqual(['Wall time', 'Step', 'Value'], next(reader))
self.assertEqual(len(list(reader)), self._STEPS)
else:
with self.assertRaises(KeyError):
self.plugin.scalars_impl(self._SCALAR_TAG, run_name, None,
scalars_plugin.OutputFormat.CSV)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test case. Is there a way to trigger the tests on my local machine? Didn't find anything in DEVELOPMENT.md oder CONTRIBUTING.md

Copy link
Contributor

@nfelt nfelt Feb 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can run bazel test --test_output=errors //tensorboard/... to run all tests, or bazel test --test_output=errors //tensorboard/plugins/histogram:histogram_plugin_test to run just the one you changed.

class OutputFormat(object):
"""An enum used to list the valid output formats for API calls."""
JSON = 'json'
CSV = 'csv'
Copy link
Contributor

@nfelt nfelt Feb 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can run bazel test --test_output=errors //tensorboard/... to run all tests, or bazel test --test_output=errors //tensorboard/plugins/histogram:histogram_plugin_test to run just the one you changed.

Copy link
Contributor

@wchargin wchargin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like spurious whitespace changes keep being reintroduced. We
don’t want to merge these because they mess up the blame, making it
harder to tell when a part of a file was most recently substantively
changed. Please revert these changes. If your editor is automatically
formatting files, you might want to configure it to not do that.

Once the tests pass and the diff is clean, please post a comment here to
request a re-review. Thanks!

icon="fullscreen"
on-tap="_toggleExpanded"
></paper-icon-button>
<template is="dom-if" if="[[showDownloadLinks]]">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than reimplementing this, please use the tf-downloader element.
You can see an example of its use in tf-scalar-card as of #1846.

[
e[0],
e[1],
';'.join(['{:.17f}'.format(el[0]) for el in e[2]]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why format with fixed precision as opposed to just str(el[0])?

events: A list of (wall_time, step, tensor_as_list) event tuples.
Returns:
CSV string representation of the given events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the representation. There’s no reasonable way for
someone to correctly guess the form of CSV returned by this handler
without reading its implementation. By reading this documentation (and
nothing more), I should be able to confidently write code that processes
the CSV returned by this function.

self._LEGACY_HISTOGRAM_TAG)

def test_histograms_csv_with_histogram(self):
self._test_histograms_csv(self._RUN_WITH_HISTOGRAM, self._HISTOGRAM_TAG,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    self._test_histograms_csv(self._RUN_WITH_HISTOGRAM, self._HISTOGRAM_TAG,
                              should_work=False)

This indeed fails, but not for the right reason. A histogram run with a
histogram tag should work, but you’ve specified the wrong tag: it
should be "%s/histogram_summary" % self._HISTOGRAM_TAG, as listed in
the test_histograms_with_histogram test case above.

Please add a test case that actually should fail (e.g., requesting a
scalar tag on a histograms run).

router.pluginRoute('histograms', '/histograms'),
{tag, run});
router.pluginRoute('histograms', '/histograms'),
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this reformatting change.

experiment = request.args.get('experiment')
output_format = request.args.get('format')
(body, mime_type) = self.scalars_impl(tag, run, experiment, output_format)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this newline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants