mfinzi/pristine-ml

View on GitHub

Showing 72 of 97 total issues

Function _queue_management_worker has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

def _queue_management_worker(executor_reference,
                             processes,
                             pending_work_items,
                             work_ids_queue,
                             call_queue,
Severity: Minor
Found in oil/tuning/localGpuExecutor.py - About 6 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

File localGpuExecutor.py has 410 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
#import torch.multiprocessing as multiprocessing
from concurrent import futures
import torch
torch.multiprocessing.set_start_method("spawn",force="True")#.get_context('spawn')
Severity: Minor
Found in oil/tuning/localGpuExecutor.py - About 5 hrs to fix

    Function __getattr__ has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def __getattr__(self, name):
            try:
                return super().__getattr__(name)
            except AttributeError:
                attr = getattr(self.module, name)
    Severity: Minor
    Found in oil/utils/parallel.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 forward has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def forward(self, x):
            x_shape = x.shape
            if len(x.shape)==2:
                x=x.view(x.shape[0],x.shape[1],1,1)
            if len(x.shape)==3:
    Severity: Minor
    Found in oil/architectures/parts/deconv.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 genCur has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def genCur(func, unique = True, minArgs = None):
        """ Generates a 'curried' version of a function. """
        def g(*myArgs, **myKwArgs):
            def f(*args, **kwArgs):
                if args or kwArgs:                  # some more args!
    Severity: Minor
    Found in oil/utils/utils.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 __getattr__ has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def __getattr__(self, name):
            try:
                return super().__getattr__(name)
            except AttributeError:
                attr = getattr(self.module, name)
    Severity: Minor
    Found in oil/utils/parallel.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

    File utils.py has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import numpy as np
    import torch
    import numbers
    import time
    import torch.nn as nn
    Severity: Minor
    Found in oil/utils/utils.py - About 2 hrs to fix

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

          def forward(self, x):
      
              N,C,H,W=x.shape
              out_h=(H+2*self.padding[0]-self.kernel_size[0]+1)//self.stride[0]
              out_w=(W+2*self.padding[0]-self.kernel_size[0]+1)//self.stride[1]
      Severity: Minor
      Found in oil/architectures/parts/deconv.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 logStuff has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def logStuff(self, step, minibatch=None):
              metrics = {}
              if minibatch is not None and hasattr(self,'loss'):
                  try: metrics['Minibatch_Loss'] = self.loss(minibatch).cpu().data.numpy()
                  except (NotImplementedError, TypeError): pass
      Severity: Minor
      Found in oil/model_trainers/trainer.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 split_dataset has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def split_dataset(dataset,splits):
          """ Inputs: A torchvision.dataset DATASET and a dictionary SPLITS
              containing fractions or number of elements for each of the new datasets.
              Allows values (0,1] or (1,N] or -1 to fill with remaining.
              Example {'train':-1,'val':.1} will create a (.9, .1) split of the dataset.
      Severity: Minor
      Found in oil/datasetup/datasets.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 unflatten has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def unflatten(d,sep='/'):
          """Take a dictionary with keys {'k1/k2/k3':v} to {'k1':{'k2':{'k3':v}}}
              as outputted by flatten """
          out_dict={}
          for k,v in d.items():
      Severity: Minor
      Found in oil/tuning/configGenerator.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 makeTrainer has 15 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def makeTrainer(*,dataset=CIFAR10,network=layer13,num_epochs=100,
      Severity: Major
      Found in oil/recipes/simpleTrial.py - About 1 hr to fix

        Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1,bias=True, eps=1e-2, n_iter=5, momentum=0.1, mode=4, num_groups=16,debug=False):
        Severity: Major
        Found in oil/architectures/parts/deconv.py - About 1 hr to fix

          Function makeTrainer has 13 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def makeTrainer(*,dataset=CIFAR10,network=layer13,num_epochs=200,
          Severity: Major
          Found in oil/recipes/trainPi.py - About 1 hr to fix

            Function makeTrainer has 12 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def makeTrainer(*,gen=resnetgan.Generator,disc=resnetgan.Discriminator,
            Severity: Major
            Found in oil/recipes/trainGan.py - About 1 hr to fix

              Function __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1,bias=True, eps=1e-2, n_iter=5, momentum=0.1, num_groups=16,sampling_stride=3):
              Severity: Major
              Found in oil/architectures/parts/deconv.py - About 1 hr to fix

                Function makeTrainer has 12 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def makeTrainer(*,gen=cgan.Generator,disc=cgan.Discriminator,
                Severity: Major
                Found in oil/recipes/trainCGan.py - About 1 hr to fix

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

                  def _find_images_and_annotation(root_dir):
                      images = {}
                      attr = None
                      assert os.path.exists(root_dir), "{} not exists".format(root_dir)
                      for root, _, fnames in sorted(os.walk(root_dir)):
                  Severity: Minor
                  Found in oil/datasetup/celeba.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 __call__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __call__(self,cfg,i=None):
                          try:
                              cfg.pop('local_rank',None) #TODO: properly handle distributed
                              resume = cfg.pop('resume',False)
                              save = cfg.pop('save',False)
                  Severity: Minor
                  Found in oil/tuning/study.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 _process_worker has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _process_worker(call_queue, result_queue,gpu_set,gpu_pool):
                      """Evaluates calls from call_queue and places the results in result_queue.
                      This worker is run in a separate process.
                      Args:
                          call_queue: A multiprocessing.Queue of _CallItems that will be read and
                  Severity: Minor
                  Found in oil/tuning/localGpuExecutor.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

                  Severity
                  Category
                  Status
                  Source
                  Language