tensorflow/tensorflow

View on GitHub
tensorflow/python/eager/context.py

Summary

Maintainability
F
1 wk
Test Coverage

File context.py has 2292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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
Severity: Major
Found in tensorflow/python/eager/context.py - About 6 days to fix

    Context has 120 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Context:
      """Environment in which eager operations execute."""
    
      # TODO(agarwal): create and link in some documentation for `execution_mode`.
      # pylint: disable=redefined-outer-name
    Severity: Major
    Found in tensorflow/python/eager/context.py - About 2 days to fix

      Function config has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

        def config(self):
          """Return the ConfigProto with all runtime deltas applied."""
          # Ensure physical devices have been discovered and config has been imported
          self._initialize_physical_devices()
      
      
      Severity: Minor
      Found in tensorflow/python/eager/context.py - About 5 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _compute_gpu_options has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

        def _compute_gpu_options(self):
          """Build the GPUOptions proto."""
          visible_device_list = []
          virtual_devices = []
          gpu_index = -1
      Severity: Minor
      Found in tensorflow/python/eager/context.py - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function set_logical_device_configuration has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_logical_device_configuration(self, dev, virtual_devices):
          """Set the virtual device configuration for a PhysicalDevice."""
          self._initialize_physical_devices()
      
          if dev not in self._physical_devices:
      Severity: Minor
      Found in tensorflow/python/eager/context.py - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function __init__ has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def __init__(self,
                     config=None,
                     device_policy=None,
                     execution_mode=None,
                     server_def=None):
      Severity: Minor
      Found in tensorflow/python/eager/context.py - About 1 hr to fix

        Function config has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def config(self):
            """Return the ConfigProto with all runtime deltas applied."""
            # Ensure physical devices have been discovered and config has been imported
            self._initialize_physical_devices()
        
        
        Severity: Minor
        Found in tensorflow/python/eager/context.py - About 1 hr to fix

          Function _import_config has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def _import_config(self):
              """Import config if passed in during construction.
          
              If Context was created with a ConfigProto such as when calling
              tf.compat.v1.enable_eager_execution(), then we need to pull out the
          Severity: Minor
          Found in tensorflow/python/eager/context.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function __enter__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def __enter__(self):
              ctx = self._ctx
              old_device_name = ctx.device_name
              old_device_spec = ctx.device_spec
              new_device_name = self._device_name
          Severity: Minor
          Found in tensorflow/python/eager/context.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function ensure_initialized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def ensure_initialized(self):
              """Initialize handle and devices if not already done so."""
              if self._initialized:
                return
              with self._initialize_lock:
          Severity: Minor
          Found in tensorflow/python/eager/context.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function set_visible_devices has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_visible_devices(self, devices, device_type=None):
              """Set the list of visible devices."""
              self._initialize_physical_devices()
          
              if not isinstance(devices, list):
          Severity: Minor
          Found in tensorflow/python/eager/context.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function configure_coordination_service has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def configure_coordination_service(self,
          Severity: Major
          Found in tensorflow/python/eager/context.py - About 1 hr to fix

            Function _initialize_logical_devices has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def _initialize_logical_devices(self):
                """Helper to initialize devices."""
                # Store list of devices
                logical_devices = []
                context_devices = []
            Severity: Minor
            Found in tensorflow/python/eager/context.py - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function get_compiler_ir has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def get_compiler_ir(
            Severity: Minor
            Found in tensorflow/python/eager/context.py - About 45 mins to fix

              Function execution_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def execution_mode(self, mode):
                  """Sets execution mode for current thread."""
                  if mode not in (None, SYNC, ASYNC):
                    raise ValueError("Execution mode should be None/SYNC/ASYNC. Got %s" %
                                     mode)
              Severity: Minor
              Found in tensorflow/python/eager/context.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function configure_coordination_service has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def configure_coordination_service(self,
                                                   service_type,
                                                   service_leader="",
                                                   enable_health_check=True,
                                                   cluster_register_timeout_in_ms=0,
              Severity: Minor
              Found in tensorflow/python/eager/context.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function get_device_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def get_device_details(self, device):  # pylint: disable=redefined-outer-name
                  """Returns details about a physical devices.
              
                  Args:
                    device: A `tf.config.PhysicalDevice` returned by
              Severity: Minor
              Found in tensorflow/python/eager/context.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function configure_collective_ops has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def configure_collective_ops(
                    self,
                    collective_leader="",
                    scoped_allocator_enabled_ops=("CollectiveReduce",),
                    use_nccl_communication=False,
              Severity: Minor
              Found in tensorflow/python/eager/context.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              There are no issues that match your filters.

              Category
              Status