-
Notifications
You must be signed in to change notification settings - Fork 1.7k
program: restore default assets zip provider #4628
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
Conversation
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
|
(Oops; meant to send to @nfelt since we’d talked about this. |
| 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( |
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.
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.
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.
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.
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!
tensorboard/program.py
Outdated
| 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. |
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.
Maybe mention what happens if this is omitted/None?
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.
Done.
wchargin-branch: program-default-assets wchargin-source: 7fa0230e73ba7d31194f53a124ebdd5ba4808622
Summary:
This patch reverts the backward-incompatible changes to
programmadein #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.ziplivesin a new Python module,
//tensorboard:assets_lib. Theprogrammodulelate-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//tensorboardbinary does so;//tensorboard:devdoes not.Test Plan:
Tested
//tensorboard,//tensorboard:dev, and the Pip package in anew virtualenv. There is no build path from
:devto the prod assets:wchargin-branch: program-default-assets