From 091f6253725ae9a2370135237e42c5b3666b6138 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 10 Oct 2016 13:44:53 -0800 Subject: [PATCH] Made the logdir argument used to start up Tensorboard appear under the TOGGLE ALL RUNS button. As part of this effort, made the handler respond with a JSON object with a single key 'logdir' containing the value. It seems like the request manager parses JSON. Previously, the endpoint returned a raw string that was the logdir argument. Updated screen diff integration tests. Change: 135722994 --- tensorflow/tensorboard/backend/handler.py | 2 +- tensorflow/tensorboard/backend/server_test.py | 7 ++-- .../components/tf-backend/backend.ts | 15 +++++++-- .../components/tf-backend/router.ts | 2 ++ .../tf-dashboard-common/tf-run-selector.html | 32 +++++++++++++++++-- .../tf-sidebar-helper.html | 9 +++++- .../tf-distribution-dashboard.html | 2 ++ .../tf-event-dashboard.html | 2 ++ .../tf-histogram-dashboard.html | 2 ++ .../tf-image-dashboard.html | 2 ++ tensorflow/tensorboard/http_api.md | 7 ++-- 11 files changed, 69 insertions(+), 13 deletions(-) diff --git a/tensorflow/tensorboard/backend/handler.py b/tensorflow/tensorboard/backend/handler.py index d829ea9a07d..ef484e36d59 100644 --- a/tensorflow/tensorboard/backend/handler.py +++ b/tensorflow/tensorboard/backend/handler.py @@ -177,7 +177,7 @@ class TensorboardHandler(BaseHTTPServer.BaseHTTPRequestHandler): def _serve_logdir(self, unused_query_params): """Writes out the logdir argument with which this tensorboard was started. """ - self.respond(self._logdir, 'text/plain') + self.respond({'logdir': self._logdir}, 'application/json') def _serve_scalars(self, query_params): """Given a tag and single run, return array of ScalarEvents. diff --git a/tensorflow/tensorboard/backend/server_test.py b/tensorflow/tensorboard/backend/server_test.py index b055ea03edd..6877fe0b31f 100644 --- a/tensorflow/tensorboard/backend/server_test.py +++ b/tensorflow/tensorboard/backend/server_test.py @@ -102,10 +102,9 @@ class TensorboardServerTest(tf.test.TestCase): self.assertEqual(response.status, 400) def testLogdir(self): - """Test the status code and content of the data/logdir endpoint.""" - response = self._get('/data/logdir') - self.assertEqual(response.status, 200) - self.assertEqual(response.read().decode('utf-8'), '/foo/logdir/argument') + """Test the format of the data/logdir endpoint.""" + parsed_object = self._getJson('/data/logdir') + self.assertEqual(parsed_object, {'logdir': '/foo/logdir/argument'}) def testRuns(self): """Test the format of the /data/runs endpoint.""" diff --git a/tensorflow/tensorboard/components/tf-backend/backend.ts b/tensorflow/tensorboard/components/tf-backend/backend.ts index 49e82c3221b..a4f7ed545ea 100644 --- a/tensorflow/tensorboard/components/tf-backend/backend.ts +++ b/tensorflow/tensorboard/components/tf-backend/backend.ts @@ -24,9 +24,11 @@ module TF.Backend { run_metadata: string[]; } + export interface LogdirResponse { logdir: string; } + export interface RunsResponse { [runName: string]: RunEnumeration; } - export type RunToTag = {[run: string]: string[]}; + export type RunToTag = {[run: string]: string[];}; export interface Datum { wall_time: Date; @@ -90,11 +92,18 @@ module TF.Backend { * @param requestManager The RequestManager, overwritable so you may * manually clear request queue, etc. Defaults to a new RequestManager. */ - constructor(r: Router, requestManager?: RequestManager) { - this.router = r; + constructor(router: Router, requestManager?: RequestManager) { + this.router = router; this.requestManager = requestManager || new RequestManager(); } + /** + * Returns a promise for requesting the logdir string. + */ + public logdir(): Promise { + return this.requestManager.request(this.router.logdir()); + } + /** * Returns a listing of all the available data in the TensorBoard backend. */ diff --git a/tensorflow/tensorboard/components/tf-backend/router.ts b/tensorflow/tensorboard/components/tf-backend/router.ts index c296f9fc637..27addbfde27 100644 --- a/tensorflow/tensorboard/components/tf-backend/router.ts +++ b/tensorflow/tensorboard/components/tf-backend/router.ts @@ -16,6 +16,7 @@ module TF.Backend { export type RunTagUrlFn = (tag: string, run: string) => string; export interface Router { + logdir: () => string; runs: () => string; scalars: RunTagUrlFn; histograms: RunTagUrlFn; @@ -86,6 +87,7 @@ module TF.Backend { return url; } return { + logdir: () => dataDir + '/logdir', runs: () => dataDir + '/runs' + (demoMode ? '.json' : ''), individualImage: individualImageUrl, individualAudio: individualAudioUrl, diff --git a/tensorflow/tensorboard/components/tf-dashboard-common/tf-run-selector.html b/tensorflow/tensorboard/components/tf-dashboard-common/tf-run-selector.html index 5981a51a375..fb30a07d70a 100644 --- a/tensorflow/tensorboard/components/tf-dashboard-common/tf-run-selector.html +++ b/tensorflow/tensorboard/components/tf-dashboard-common/tf-run-selector.html @@ -53,6 +53,11 @@ Properties out: > Toggle All Runs + diff --git a/tensorflow/tensorboard/components/tf-dashboard-common/tf-sidebar-helper.html b/tensorflow/tensorboard/components/tf-dashboard-common/tf-sidebar-helper.html index 45f9932b446..f2b94a981af 100644 --- a/tensorflow/tensorboard/components/tf-dashboard-common/tf-sidebar-helper.html +++ b/tensorflow/tensorboard/components/tf-dashboard-common/tf-sidebar-helper.html @@ -28,6 +28,7 @@ To use it, create the tf-sidebar-helper with the required properties. To extend it with extra configuration components, add them to the element's component: