IBM/pytorchpipe

View on GitHub

Showing 102 of 320 total issues

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

    def __init__(self, name, config):
        """
        Initializes the task.

        .. warning::
Severity: Minor
Found in ptp/components/tasks/image_to_class/cifar_100.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 deeply nested control flow statements.
Open

                            for name, param in self.pipeline.named_parameters():
                                try:
                                    self.training_batch_writer.add_histogram(name + '/grad', 
                                        param.grad.data.cpu().numpy(), self.app_state.episode, bins='doane')

Severity: Major
Found in ptp/workers/offline_trainer.py - About 45 mins to fix

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

        def cuda(self):
            """ 
            Moves all models to GPU.
            """
            self.logger.info("Moving model(s) to GPU(s)")
    Severity: Minor
    Found in ptp/application/pipeline_manager.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 deeply nested control flow statements.
    Open

                                for name, param in self.pipeline.named_parameters():
                                    try:
                                        self.training_batch_writer.add_histogram(name, 
                                            param.data.cpu().numpy(), self.app_state.episode, bins='doane')
    
    
    Severity: Major
    Found in ptp/workers/offline_trainer.py - About 45 mins to fix

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

          def setup_experiment(self):
              """
              Sets up experiment for episode trainer:
      
                  - Calls base class setup_experiment to parse the command line arguments,
      Severity: Minor
      Found in ptp/workers/online_trainer.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 setup_experiment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def setup_experiment(self):
              """
              Sets up experiment for episode trainer:
      
                  - Calls base class setup_experiment to parse the command line arguments,
      Severity: Minor
      Found in ptp/workers/offline_trainer.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 deeply nested control flow statements.
      Open

                                  if (validation_batch_loss < self.loss_stop_threshold):
                                      # Change the status.
                                      training_status = "Converged (Partial Validation Loss went below " \
                                          "Loss Stop threshold {})".format(self.loss_stop_threshold)
      
      
      Severity: Major
      Found in ptp/workers/online_trainer.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    for name, param in self.pipeline.named_parameters():
                                        try:
                                            self.training_batch_writer.add_histogram(name, 
                                                param.data.cpu().numpy(), self.app_state.episode, bins='doane')
        
        
        Severity: Major
        Found in ptp/workers/online_trainer.py - About 45 mins to fix

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

              def backward(self, data_streams):
                  """
                  Propagates gradients backwards, starting from losses returned by every loss component in the pipeline.
                  If using many losses the components derived from loss must overwrite the ''loss_keys()'' method.
          
          
          Severity: Minor
          Found in ptp/application/pipeline_manager.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, name, config):
                  """
                  Initializes object. Loads keys and values of variables and adds them to globals.
          
                  :param name: Loss name.
          Severity: Minor
          Found in ptp/components/publishers/global_variable_publisher.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, name, class_type, config):
                  """
                  Initializes the component. This constructor:
          
                      - sets the access to ``AppState`` (for dtypes, settings, globals etc.)
          Severity: Minor
          Found in ptp/components/component.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 export_experiment_configuration_to_yml has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def export_experiment_configuration_to_yml(logger, log_dir, filename, config_interface_obj, user_confirm):
          Severity: Minor
          Found in ptp/configuration/config_parsing.py - About 35 mins to fix

            Function preprocess_text has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def preprocess_text(self, text, lowercase = False, remove_punctuation = False, tokenize = False, remove_stop_words = False):
            Severity: Minor
            Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 35 mins to fix

              Function save_word_mappings_to_csv_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def save_word_mappings_to_csv_file(logger, folder, filename, word_to_ix, fieldnames = ["word","index"]):
              Severity: Minor
              Found in ptp/components/mixins/word_mappings.py - About 35 mins to fix

                Function load_pretrained_embeddings has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def load_pretrained_embeddings(logger, folder, embeddings_name, word_to_ix, embeddings_size):
                Severity: Minor
                Found in ptp/components/mixins/embeddings.py - About 35 mins to fix

                  Function load_dataset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def load_dataset(self, source_files):
                          """
                          Loads the dataset from source files.
                  
                          :param source_files: list of jSON file with image ids, questions, answers, scene graphs, etc.
                  Severity: Minor
                  Found in ptp/components/tasks/image_text_to_class/gqa.py - About 35 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 export_output_definitions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def export_output_definitions(self, all_definitions, log_errors=True):
                          """ 
                          Exports output definitions to all_definitions, checking errors (e.g. if output field is already present in all_definitions).
                  
                          :param all_definitions: dictionary containing output data definitions (each of type :py:class:`ptp.configuration.DataDefinition`).
                  Severity: Minor
                  Found in ptp/components/component.py - About 35 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 export_to_tensorboard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def export_to_tensorboard(self, tb_writer = None):
                          """
                          Method exports current statistical aggregators values to TensorBoard.
                  
                          :param tb_writer: TensorBoard writer, optional
                  Severity: Minor
                  Found in ptp/utils/statistics_aggregator.py - About 35 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 setup_global_experiment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def setup_global_experiment(self):
                          """
                          Sets up the global test experiment for the ``Processor``:
                  
                              - Checks that the model to use exists
                  Severity: Minor
                  Found in ptp/workers/processor.py - About 35 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 preprocess_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def preprocess_text(self, text, lowercase = False, remove_punctuation = False, tokenize = False, remove_stop_words = False):
                          """
                          Function that preprocesses questions/answers as suggested by ImageCLEF VQA challenge organizers:
                              * lowercases all words (optional)
                              * removes punctuation (optional)
                  Severity: Minor
                  Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language