Skip to content

Commit cb525a7

Browse files
committed
Ensure flags get initialized (#716)
The open source entry-point might not have been invoking tf.app.run() which a user reports might have caused errors like this to happen: absl.flags._exceptions.UnparsedFlagAccessError: Trying to access flag --debugger_data_server_grpc_port before flags were parsed. See tensorflow/tensorflow@2652704
1 parent f115366 commit cb525a7

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

tensorboard/__main__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15+
"""Module that allows the user to run `python -m tensorboard`."""
1516

1617
from __future__ import absolute_import
1718
from __future__ import division
1819
from __future__ import print_function
1920

20-
import sys
21+
from tensorboard import main as _main
2122

22-
from tensorboard.main import main
23+
run_main = _main.run_main
24+
25+
del _main
2326

2427
if __name__ == '__main__':
25-
sys.exit(main())
28+
run_main()

tensorboard/main.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
from tensorboard import program
3232

3333

34+
def run_main():
35+
"""Initializes flags and calls main()."""
36+
tf.app.run(main)
37+
38+
3439
def main(unused_argv=None):
3540
"""Standard TensorBoard program CLI.
3641
@@ -59,4 +64,4 @@ def run_simple_server(*args, **kwargs):
5964

6065

6166
if __name__ == '__main__':
62-
tf.app.run()
67+
run_main()

tensorboard/pip_package/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
]
4242

4343
CONSOLE_SCRIPTS = [
44-
'tensorboard = tensorboard.main:main',
44+
'tensorboard = tensorboard.main:run_main',
4545
]
4646

4747
def get_readme():

0 commit comments

Comments
 (0)