Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tensorboard/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ def _display_colab(port, height, display_handle):

shell = """
(async () => {
const url = await google.colab.kernel.proxyPort(%PORT%, {"cache": true});
const url = new URL(await google.colab.kernel.proxyPort(%PORT%, {'cache': true}));
url.searchParams.set('tensorboardColab', 'true');
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.setAttribute('width', '100%');
Expand Down
34 changes: 34 additions & 0 deletions tensorboard/plugins/scalar/tf_scalar_dashboard/tf-scalar-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,40 @@ export class TfScalarCard extends PolymerElement {
items,
onLoad,
onFinish
) => {
const inColab =
new URLSearchParams(window.location.search).get('tensorboardColab') ===
'true';
if (inColab) {
// Google-internal Colab doesn't support HTTP POST requests, so we fall
// back to HTTP GET (even though public Colab supports POST).
return this._requestDataGet(items, onLoad, onFinish);
} else {
return this._requestDataPost(items, onLoad, onFinish);
}
};

_requestDataGet: RequestDataCallback<RunTagItem, ScalarDatum[] | null> = (
items,
onLoad,
onFinish
) => {
const router = getRouter();
const baseUrl = router.pluginRoute('scalars', '/scalars');
Promise.all(
items.map((item) => {
const url = addParams(baseUrl, {tag: item.tag, run: item.run});
return this.requestManager
.request(url)
.then((data) => void onLoad({item, data}));
})
).finally(() => void onFinish());
};

_requestDataPost: RequestDataCallback<RunTagItem, ScalarDatum[] | null> = (
items,
onLoad,
onFinish
) => {
const router = getRouter();
const url = router.pluginRoute('scalars', '/scalars_multirun');
Expand Down