Cloud-CV/EvalAI

View on GitHub
scripts/workers/submission_worker.py

Summary

Maintainability
F
4 days
Test Coverage

File submission_worker.py has 771 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import contextlib
import importlib
Severity: Major
Found in scripts/workers/submission_worker.py - About 1 day to fix

    Function main has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    def main():
        killer = GracefulKiller()
        logger.info(
            "{} Using {} as temp directory to store data".format(
                WORKER_LOGS_PREFIX, BASE_TEMP_DIR
    Severity: Minor
    Found in scripts/workers/submission_worker.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 run_submission has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_submission(
        challenge_id, challenge_phase, submission, user_annotation_file_path
    ):
        """
        * receives a challenge id, phase id and user annotation file path
    Severity: Minor
    Found in scripts/workers/submission_worker.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 delete_old_temp_directories has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def delete_old_temp_directories(prefix='tmp'):
        temp_dir = tempfile.gettempdir()
    
        dir_creation_times = {}
    
    
    Severity: Minor
    Found in scripts/workers/submission_worker.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 get_or_create_sqs_queue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_or_create_sqs_queue(queue_name, challenge=None):
        """
        Returns:
            Returns the SQS Queue object
        """
    Severity: Minor
    Found in scripts/workers/submission_worker.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 run_submission has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def run_submission(
        challenge_id, challenge_phase, submission, user_annotation_file_path
    ):
        """
        * receives a challenge id, phase id and user annotation file path
    Severity: Minor
    Found in scripts/workers/submission_worker.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if (
                              current_running_submissions_count
                              == maximum_concurrent_submissions
                          ):
                              pass
      Severity: Major
      Found in scripts/workers/submission_worker.py - About 45 mins to fix

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

        def download_and_extract_file(url, download_location):
            """
            * Function to extract download a file.
            * `download_location` should include name of file as well.
            """
        Severity: Minor
        Found in scripts/workers/submission_worker.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 download_and_extract_zip_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def download_and_extract_zip_file(url, download_location, extract_location):
            """
            * Function to extract download a zip file, extract it and then removes the zip file.
            * `download_location` should include name of file as well.
            """
        Severity: Minor
        Found in scripts/workers/submission_worker.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