Skip to content

Commit

Permalink
tbdev turndown: replace dev subcommand with shim
Browse files Browse the repository at this point in the history
  • Loading branch information
nfelt committed Dec 20, 2023
1 parent 377caa0 commit ec1d443
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
10 changes: 8 additions & 2 deletions tensorboard/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ py_binary(
":assets_lib", # link dep for webfiles assets
":default",
":dynamic_plugins", # loads internal dynamic plugin like projector
":legacy_tbdev_subcommand",
":lib",
":main_lib",
":program",
"//tensorboard:expect_tensorflow_installed",
"//tensorboard/plugins:base_plugin",
"//tensorboard/uploader:uploader_subcommand",
"//tensorboard/util:tb_logging",
"//tensorboard/util:timing", # non-strict dep, for patching convenience
],
Expand All @@ -59,10 +59,10 @@ py_binary(
deps = [
":default",
":dynamic_plugins", # loads internal dynamic plugin like projector
":legacy_tbdev_subcommand",
":lib",
":main_lib",
":program",
"//tensorboard/uploader:uploader_subcommand",
],
)

Expand Down Expand Up @@ -647,3 +647,9 @@ py_test(
tags = ["support_notf"],
deps = [":lazy"],
)

py_library(
name = "legacy_tbdev_subcommand",
srcs = ["legacy_tbdev_subcommand.py"],
srcs_version = "PY3",
)
47 changes: 47 additions & 0 deletions tensorboard/legacy_tbdev_subcommand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Legacy `tensorboard dev` implementation to print shutdown info."""

import sys

from tensorboard import program


_SHUTDOWN_MESSAGE = """\
======================================================================
ERROR: This command is no longer operational and will be removed.
TensorBoard.dev has been shut down. For further information,
see the FAQ at <https://tensorboard.dev/>.
======================================================================
"""


class LegacyTbdevSubcommand(program.TensorBoardSubcommand):
"""Legacy `tensorboard dev` implementation to print shutdown info."""

def name(self):
return "dev"

def define_flags(self, parser):
pass # no flags to define

def run(self, flags):
sys.stderr.write(_SHUTDOWN_MESSAGE)
sys.stderr.flush()
sys.exit(1)

def help(self):
return "" # omit help to avoid suggesting users should try it
4 changes: 2 additions & 2 deletions tensorboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

from absl import app
from tensorboard import default
from tensorboard import legacy_tbdev_subcommand
from tensorboard import main_lib
from tensorboard import program
from tensorboard.plugins import base_plugin
from tensorboard.uploader import uploader_subcommand
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()
Expand All @@ -40,7 +40,7 @@ def run_main():

tensorboard = program.TensorBoard(
plugins=default.get_plugins(),
subcommands=[uploader_subcommand.UploaderSubcommand()],
subcommands=[legacy_tbdev_subcommand.LegacyTbdevSubcommand()],
)
try:
app.run(tensorboard.main, flags_parser=tensorboard.configure)
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/main_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

from absl import app
from tensorboard import default
from tensorboard import legacy_tbdev_subcommand
from tensorboard import main_lib
from tensorboard import program
from tensorboard.plugins import base_plugin
from tensorboard.uploader import uploader_subcommand


def run_main():
Expand All @@ -33,7 +33,7 @@ def run_main():
tensorboard = program.TensorBoard(
plugins=default.get_plugins(),
assets_zip_provider=lambda: open(path, "rb"),
subcommands=[uploader_subcommand.UploaderSubcommand()],
subcommands=[legacy_tbdev_subcommand.LegacyTbdevSubcommand()],
)

try:
Expand Down

0 comments on commit ec1d443

Please sign in to comment.