IBM/pytorchpipe

View on GitHub

Showing 102 of 320 total issues

Function run_experiment has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

    def run_experiment(self):
        """
        Main function of the ``OnlineTrainer``, runs the experiment.

        Iterates over the (cycled) DataLoader (one iteration = one episode).
Severity: Minor
Found in ptp/workers/online_trainer.py - About 1 day 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 run_experiment has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def run_experiment(self):
        """
        Main function of the ``OfflineTrainer``, runs the experiment.

        Iterates over the (cycled) DataLoader (one iteration = one episode).
Severity: Minor
Found in ptp/workers/offline_trainer.py - About 1 day 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 vqa_med_2019.py has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) IBM Corporation 2019
#
Severity: Major
Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 1 day to fix

    File pipeline_manager.py has 506 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    #
    # Copyright (C) tkornuta, IBM Corporation 2019
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    Severity: Major
    Found in ptp/application/pipeline_manager.py - About 1 day to fix

      Function build has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

          def build(self, use_logger=True):
              """
              Method creating the pipeline, consisting of:
                  - a list components ordered by the priority (dictionary).
                  - task (as a separate "link" to object in the list of components, instance of a class derrived from Task class)
      Severity: Minor
      Found in ptp/application/pipeline_manager.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

      Function handshake_input_definitions has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def handshake_input_definitions(self, all_definitions, log_errors=True):
              """ 
              Checks whether all_definitions contain fields required by the given component.
      
              :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 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

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

          def __init__(self, name, config):
              """
              Initializes the model.
      
              :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
      Severity: Minor
      Found in ptp/components/models/general_usage/recurrent_neural_network.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

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

          def forward(self, data_streams):
              """
              Forward pass of the model.
      
              :param data_streams: DataStreams({'inputs', 'predictions ...}), where:
      Severity: Minor
      Found in ptp/components/models/general_usage/recurrent_neural_network.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 setup_experiment has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

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

          def build(task, config, task_subset_name):
              """
              Static method returning particular sampler, depending on the name \
              provided in the list of parameters & the specified task class.
      
      
      Severity: Minor
      Found in ptp/application/sampler_factory.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

      File trainer.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      # -*- coding: utf-8 -*-
      #
      # Copyright (C) IBM Corporation 2019
      #
      Severity: Minor
      Found in ptp/workers/trainer.py - About 4 hrs to fix

        Function setup_individual_experiment has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_individual_experiment(self):
                """
                Setup individual test experiment in the case of multiple tests, or the main experiment in the case of \
                one test experiment.
        
        
        Severity: Minor
        Found in ptp/workers/processor.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 calculate_BLEU has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            def calculate_BLEU(self, data_streams):
                """
                Calculates BLEU for predictions of a given batch.
        
                :param data_streams: DataStreams containing the targets and predictions (and optionally masks).
        Severity: Minor
        Found in ptp/components/statistics/bleu_statistics.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 load_pretrained_embeddings has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def load_pretrained_embeddings(logger, folder, embeddings_name, word_to_ix, embeddings_size):
            """
            Creates embedding vector for words from the provided (word:index) mappings (dictionary).
        
            Loads the pretrained embeddings from the GloVe project - for the words found in the dictionary.
        Severity: Minor
        Found in ptp/components/mixins/embeddings.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 a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, name, config):
                """
                Initializes the model.
        
                :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
        Severity: Minor
        Found in ptp/components/models/general_usage/seq2seq.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

        PipelineManager has 27 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class PipelineManager(object):
            """
            Class responsible for instantiating the pipeline consisting of several components.
            """
        
        
        Severity: Minor
        Found in ptp/application/pipeline_manager.py - About 3 hrs to fix

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

              def load_models(self):
                  """
                  Method analyses the configuration and loads models one by one by looking whether they got 'load' variable present in their configuration section.
          
                  ..note::
          Severity: Minor
          Found in ptp/application/pipeline_manager.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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, name, config):
                  """
                  Initializes the model.
          
                  :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
          Severity: Minor
          Found in ptp/components/models/general_usage/attention_decoder.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 __init__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, name, config):
                  """
                  Initializes task object. Calls base constructor. Downloads the dataset if not present and loads the adequate files depending on the mode.
          
                  :param name: Name of the component.
          Severity: Minor
          Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.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 __init__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, name, config):
                  """
                  Initializes the classifier.
          
                  :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
          Severity: Minor
          Found in ptp/components/models/general_usage/feed_forward_network.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

          Severity
          Category
          Status
          Source
          Language