Skip to content

Conversation

@wchargin
Copy link
Contributor

Summary:
This patch reverts the backward-incompatible changes to program made
in #4588, while retaining the new functionality in that change.
Specifically, we restore the calling convention of TensorBoard
(reordering the parameters was a breaking change, as was removing the
default value). For clarity, the data dependency to webfiles.zip lives
in a new Python module, //tensorboard:assets_lib. The program module
late-imports this only if no assets zip provider is given, in which case
the caller is expected to have a build dep on :assets_lib. The main
//tensorboard binary does so; //tensorboard:dev does not.

Test Plan:
Tested //tensorboard, //tensorboard:dev, and the Pip package in a
new virtualenv. There is no build path from :dev to the prod assets:

$ bazel query 'somepath(//tensorboard:dev, //tensorboard:webfiles.zip)'
INFO: Empty results

wchargin-branch: program-default-assets

Summary:
This patch reverts the backward-incompatible changes to `program` made
in #4588, while retaining the new functionality in that change.
Specifically, we restore the calling convention of `TensorBoard`
(reordering the parameters was a breaking change, as was removing the
default value). For clarity, the data dependency to `webfiles.zip` lives
in a new Python module, `//tensorboard:assets_lib`. The `program` module
late-imports this only if no assets zip provider is given, in which case
the caller is expected to have a build dep on `:assets_lib`. The main
`//tensorboard` binary does so; `//tensorboard:dev` does not.

Test Plan:
Tested `//tensorboard`, `//tensorboard:dev`, and the Pip package in a
new virtualenv.

wchargin-branch: program-default-assets
wchargin-source: b7dada87af060dc3ffbc5dd2ffee63652f1c1a23
wchargin-branch: program-default-assets
wchargin-source: bdd62bf3774460c084ef2c9176a2570d939d69b8
@wchargin wchargin requested review from nfelt and removed request for stephanwlee January 29, 2021 08:45
@wchargin
Copy link
Contributor Author

(Oops; meant to send to @nfelt since we’d talked about this.
@stephanwlee: feel free to review, but no obligation.)

Comment on lines +108 to +114
try:
from tensorboard import assets
except ImportError as e:
# `tensorboard.assets` is not a strict Bazel dep; clients are
# required to either depend on `//tensorboard:assets_lib` or
# pass a valid assets provider.
raise ImportError(
Copy link
Contributor

Choose a reason for hiding this comment

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

No action required (or just relief):

I was a bit worried program.py would have hard dep on webfiles.zip but this of course make it better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah—it took a bit of thinking to come up with a build/import structure
that I liked, but I think that it turned out okay.

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!

TBLoader instances or classes. If not specified, defaults to first-party
plugins.
assets_zip_provider: A function that provides a zip file containing assets to
the application.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe mention what happens if this is omitted/None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

wchargin-branch: program-default-assets
wchargin-source: 7fa0230e73ba7d31194f53a124ebdd5ba4808622
@wchargin wchargin merged commit 6f23269 into master Jan 29, 2021
@wchargin wchargin deleted the wchargin-program-default-assets branch January 29, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants