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
6 changes: 3 additions & 3 deletions tensorboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@

@lazy.lazy_load('tensorboard.notebook')
def notebook():
import importlib # pylint: disable=g-import-not-at-top
import importlib
return importlib.import_module('tensorboard.notebook')


@lazy.lazy_load('tensorboard.program')
def program():
import importlib # pylint: disable=g-import-not-at-top
import importlib
return importlib.import_module('tensorboard.program')


@lazy.lazy_load('tensorboard.summary')
def summary():
import importlib # pylint: disable=g-import-not-at-top
import importlib
return importlib.import_module('tensorboard.summary')


Expand Down
4 changes: 2 additions & 2 deletions tensorboard/backend/application_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from werkzeug import test as werkzeug_test
from werkzeug import wrappers
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/backend/event_processing/directory_loader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

import tensorflow as tf

Expand Down
4 changes: 2 additions & 2 deletions tensorboard/backend/http_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from werkzeug import test as wtest
from werkzeug import wrappers
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/backend/security_validator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

import werkzeug
from werkzeug import test as werkzeug_test
Expand Down
12 changes: 6 additions & 6 deletions tensorboard/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def tf():
ImportError: if a TF-like API is not available.
"""
try:
from tensorboard.compat import notf # pylint: disable=g-import-not-at-top
from tensorboard.compat import notf
except ImportError:
try:
import tensorflow # pylint: disable=g-import-not-at-top
import tensorflow
return tensorflow
except ImportError:
pass
from tensorboard.compat import tensorflow_stub # pylint: disable=g-import-not-at-top
from tensorboard.compat import tensorflow_stub
return tensorflow_stub


Expand Down Expand Up @@ -94,12 +94,12 @@ def _pywrap_tensorflow():
ImportError: if we couldn't import pywrap_tensorflow.
"""
try:
from tensorboard.compat import notf # pylint: disable=g-import-not-at-top
from tensorboard.compat import notf
except ImportError:
try:
from tensorflow.python import pywrap_tensorflow # pylint: disable=g-import-not-at-top
from tensorflow.python import pywrap_tensorflow
return pywrap_tensorflow
except ImportError:
pass
from tensorboard.compat.tensorflow_stub import pywrap_tensorflow # pylint: disable=g-import-not-at-top
from tensorboard.compat.tensorflow_stub import pywrap_tensorflow
return pywrap_tensorflow
4 changes: 2 additions & 2 deletions tensorboard/default_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

import pkg_resources

Expand Down
4 changes: 2 additions & 2 deletions tensorboard/lazy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_self_composition(self):

@lazy.lazy_load("inner")
def inner():
import collections # pylint: disable=g-import-not-at-top
import collections
return collections

@lazy.lazy_load("outer")
Expand Down Expand Up @@ -70,7 +70,7 @@ def foo():
self.assertEquals(repr(foo), "<module 'foo' via LazyModule (not yet loaded)>")

def test_repr_after_load(self):
import collections # pylint: disable=g-import-not-at-top
import collections
@lazy.lazy_load("foo")
def foo():
return collections
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
from __future__ import division
from __future__ import print_function

# pylint: disable=g-import-not-at-top

import os

# Disable the TF GCS filesystem cache which interacts pathologically with the
# pattern of reads used by TensorBoard for logdirs. See for details:
# https://github.com/tensorflow/tensorboard/issues/1225
# This must be set before the first import of tensorflow.
os.environ['GCS_READ_CACHE_DISABLED'] = '1'
# pylint: enable=g-import-not-at-top


import sys

Expand Down
4 changes: 2 additions & 2 deletions tensorboard/manager_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorboard import manager

Expand Down
4 changes: 2 additions & 2 deletions tensorboard/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorboard import manager
from tensorboard import test as tb_test
Expand Down
2 changes: 1 addition & 1 deletion tensorboard/plugins/beholder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Only import Beholder API when tensorflow is available.
try:
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
import tensorflow
except ImportError:
pass
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/beholder/beholder_plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def load(self, context):
A BeholderPlugin instance or None if it couldn't be loaded.
"""
try:
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
import tensorflow
except ImportError:
return
# pylint: disable=g-import-not-at-top

from tensorboard.plugins.beholder.beholder_plugin import BeholderPlugin
return BeholderPlugin(context)
10 changes: 5 additions & 5 deletions tensorboard/plugins/debugger/debugger_plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ def load(self, context):
if flags.debugger_data_server_grpc_port > 0 or flags.debugger_port > 0:
# Verify that the required Python packages are installed.
try:
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
import tensorflow
except ImportError:
raise ImportError(
'To use the debugger plugin, you need to have TensorFlow installed:\n'
' pip install tensorflow')

if flags.debugger_data_server_grpc_port > 0:
# pylint: disable=line-too-long,g-import-not-at-top
# pylint: disable=line-too-long
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional since orthogonal to this PR but conceptually makes sense to kill these as of #3021, right?

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—I didn’t want to bother automatically matching those in #3021
because they’re not directly on the import lines, which makes it
non-trivial, whereas g-import-not-at-top can be removed in all cases.
But I’m happy to remove those; almost all our line-too-longs are
useless in one way or another.

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 in #3025.

from tensorboard.plugins.debugger import debugger_plugin as debugger_plugin_lib
# pylint: enable=line-too-long,g-import-not-at-top
# pylint: enable=line-too-long

# debugger_data_server_grpc opens the non-interactive Debugger Plugin,
# which appears as health pills in the Graph Plugin.
Expand All @@ -148,9 +148,9 @@ def load(self, context):
noninteractive_plugin.listen(flags.debugger_data_server_grpc_port)
return noninteractive_plugin
elif flags.debugger_port > 0:
# pylint: disable=line-too-long,g-import-not-at-top
# pylint: disable=line-too-long
from tensorboard.plugins.debugger import interactive_debugger_plugin as interactive_debugger_plugin_lib
# pylint: enable=line-too-long,g-import-not-at-top
# pylint: enable=line-too-long
interactive_plugin = (
interactive_debugger_plugin_lib.InteractiveDebuggerPlugin(context))
logger.info('Starting Interactive Debugger Plugin at gRPC port %d',
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/debugger/debugger_plugin_testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def setUp(self):
super(DebuggerPluginTestBase, self).setUp()
# Importing the debugger_plugin can sometimes unfortunately produce errors.
try:
# pylint: disable=g-import-not-at-top

from tensorboard.plugins.debugger import debugger_plugin
from tensorboard.plugins.debugger import debugger_server_lib
# pylint: enable=g-import-not-at-top

except Exception as e: # pylint: disable=broad-except
raise self.skipTest(
'Skipping test because importing some modules failed: %r' % e)
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/hparams/backend_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import
import tensorflow as tf

from google.protobuf import text_format
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/hparams/keras_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorboard.plugins.hparams import keras
from tensorboard.plugins.hparams import metadata
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/hparams/list_metric_evals_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import
import tensorflow as tf

from google.protobuf import text_format
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/hparams/list_session_groups_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import tensorflow as tf
try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from google.protobuf import text_format
from tensorboard.backend.event_processing import event_accumulator
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/hparams/summary_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorboard import test
from tensorboard.compat import tf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def load(self, context):
A InteractiveInferencePlugin instance or None if it couldn't be loaded.
"""
try:
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
import tensorflow
except ImportError:
return
# pylint: disable=line-too-long,g-import-not-at-top
# pylint: disable=line-too-long
Copy link
Contributor

Choose a reason for hiding this comment

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

Also kill this one?

from tensorboard.plugins.interactive_inference.interactive_inference_plugin import InteractiveInferencePlugin
return InteractiveInferencePlugin(context)
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from six.moves import urllib_parse
from google.protobuf import json_format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorflow_serving.apis import classification_pb2
from tensorflow_serving.apis import predict_pb2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def _is_colab():


if _is_colab():
from witwidget.notebook.colab.wit import * # pylint: disable=wildcard-import,g-import-not-at-top
from witwidget.notebook.colab.wit import * # pylint: disable=wildcard-import
else:
from witwidget.notebook.jupyter.wit import * # pylint: disable=wildcard-import,g-import-not-at-top
from witwidget.notebook.jupyter.wit import * # pylint: disable=wildcard-import


class WitConfigBuilder(object):
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/mesh/mesh_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import


class MeshPluginTest(tf.test.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tensorboard/plugins/profile/profile_plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def load(self, context):
A ProfilePlugin instance or None if it couldn't be loaded.
"""
try:
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
import tensorflow
# Available in TensorFlow 1.14 or later, so do import check
# pylint: disable=g-import-not-at-top,unused-import
# pylint: disable=unused-import
from tensorflow.python.eager import profiler_client
except ImportError:
return
# pylint: disable=g-import-not-at-top

from tensorboard.plugins.profile.profile_plugin import ProfilePlugin
return ProfilePlugin(context)
4 changes: 2 additions & 2 deletions tensorboard/program_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

try:
# python version >= 3.3
from unittest import mock # pylint: disable=g-import-not-at-top
from unittest import mock
except ImportError:
import mock # pylint: disable=g-import-not-at-top,unused-import
import mock # pylint: disable=unused-import

from tensorboard import program
from tensorboard import test as tb_test
Expand Down
Loading