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");
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)
- Read upRead up
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.
"""
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::
- Read upRead up
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.
- Read upRead up
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.
- Read upRead up
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)")
- Read upRead up
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.
- Read upRead up
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.
- Read upRead up
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"