IBM/pytorchpipe

View on GitHub
ptp/application/pipeline_manager.py

Summary

Maintainability
F
3 days
Test Coverage

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

    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 freeze_models has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def freeze_models(self):
              """
              Method analyses the configuration and freezes:
                  - all models when 'freeze' flag for whoe pipeline is set,
                  - individual models when their 'freeze' flags are set.
      Severity: Minor
      Found in ptp/application/pipeline_manager.py - About 55 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 forward has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def forward(self, data_streams):
              """
              Method responsible for processing the data dict, using all components in the components queue.
      
              :param data_streams: :py:class:`ptp.utils.DataStreams` object containing both input data to be processed and that will be extended by the results.
      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 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

      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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def save(self, chkpt_dir, training_status, loss):
              """
              Generic method saving the parameters of all models in the pipeline to a file.
      
              :param chkpt_dir: Directory where the model will be saved.
      Severity: Minor
      Found in ptp/application/pipeline_manager.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

      There are no issues that match your filters.

      Category
      Status