-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Histogram data download #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Histogram data download #1782
Conversation
|
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. |
nfelt
left a comment
There was a problem hiding this 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, |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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:
tensorboard/tensorboard/plugins/scalar/scalars_plugin_test.py
Lines 176 to 191 in 1451220
| 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
tensorboard/plugins/histogram/tf_histogram_dashboard/tf-histogram-loader.html
Outdated
Show resolved
Hide resolved
| class OutputFormat(object): | ||
| """An enum used to list the valid output formats for API calls.""" | ||
| JSON = 'json' | ||
| CSV = 'csv' |
There was a problem hiding this comment.
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.
* change the csv writer and directly write the csv
wchargin
left a comment
There was a problem hiding this 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]]"> |
There was a problem hiding this comment.
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]]), |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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'), | ||
| { |
There was a problem hiding this comment.
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) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this newline.

This pull requests add the option to download the raw histogram data as described in #1275
The button to trigger the download buttons:
The download selection for the data:
