tensorflow/models

View on GitHub
official/common/distribute_utils.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function get_distribution_strategy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def get_distribution_strategy(distribution_strategy="mirrored",
                              num_gpus=0,
                              all_reduce_alg=None,
                              num_packs=1,
                              tpu_address=None,
Severity: Minor
Found in official/common/distribute_utils.py - About 2 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 get_distribution_strategy has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_distribution_strategy(distribution_strategy="mirrored",
Severity: Minor
Found in official/common/distribute_utils.py - About 45 mins to fix

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

    def configure_cluster(worker_hosts=None, task_index=-1):
      """Set multi-worker cluster spec in TF_CONFIG environment variable.
    
      Args:
        worker_hosts: comma-separated list of worker ip:port pairs.
    Severity: Minor
    Found in official/common/distribute_utils.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

    Avoid too many return statements within this function.
    Open

        return tf.distribute.OneDeviceStrategy("device:GPU:0")
    Severity: Major
    Found in official/common/distribute_utils.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return tf.distribute.experimental.ParameterServerStrategy(cluster_resolver)
      Severity: Major
      Found in official/common/distribute_utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return tf.distribute.MirroredStrategy(
        Severity: Major
        Found in official/common/distribute_utils.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status