Cloud-CV/EvalAI

View on GitHub
scripts/monitoring/auto_scale_eks_nodes.py

Summary

Maintainability
C
1 day
Test Coverage

Function start_job has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def start_job():

    # Get metrics
    staff_evalai_interface = create_evalai_interface(STAFF_AUTH_TOKEN)

Severity: Minor
Found in scripts/monitoring/auto_scale_eks_nodes.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 scale_up_workers has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def scale_up_workers(challenge, original_desired_size, pending_submissions, evalai_interface, aws_keys, new_desired_size):
Severity: Minor
Found in scripts/monitoring/auto_scale_eks_nodes.py - About 45 mins to fix

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

    def start_eks_worker(challenge, pending_submissions, evalai_interface, aws_keys, new_desired_size):
    Severity: Minor
    Found in scripts/monitoring/auto_scale_eks_nodes.py - About 35 mins to fix

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

      def scale_up_or_down_workers(challenge, evalai_interface, staff_evalai_interface, aws_keys, scale_up_desired_size):
      Severity: Minor
      Found in scripts/monitoring/auto_scale_eks_nodes.py - About 35 mins to fix

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

        def scale_up_or_down_workers(challenge, evalai_interface, staff_evalai_interface, aws_keys, scale_up_desired_size):
            try:
                challenge_metrics = staff_evalai_interface.get_challenge_submission_metrics_by_pk(challenge["id"])
                pending_submissions = get_pending_submission_count(challenge_metrics)
            except Exception as e:  # noqa: F841
        Severity: Minor
        Found in scripts/monitoring/auto_scale_eks_nodes.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            try:
                challenge_metrics = staff_evalai_interface.get_challenge_submission_metrics_by_pk(challenge["id"])
                pending_submissions = get_pending_submission_count(challenge_metrics)
            except Exception as e:  # noqa: F841
                print(
        Severity: Major
        Found in scripts/monitoring/auto_scale_eks_nodes.py and 1 other location - About 2 hrs to fix
        scripts/monitoring/auto_scale_ec2_workers.py on lines 76..86

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        def get_boto3_client(resource, aws_keys):
            client = boto3.client(
                resource,
                region_name=aws_keys["AWS_REGION"],
                aws_access_key_id=aws_keys["AWS_ACCESS_KEY_ID"],
        Severity: Major
        Found in scripts/monitoring/auto_scale_eks_nodes.py and 1 other location - About 1 hr to fix
        scripts/monitoring/auto_scale_ec2_workers.py on lines 20..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

        def get_pending_submission_count(challenge_metrics):
            pending_submissions = 0
            for status in ["running", "submitted", "queued", "resuming"]:
                pending_submissions += challenge_metrics.get(status, 0)
            return pending_submissions
        Severity: Major
        Found in scripts/monitoring/auto_scale_eks_nodes.py and 2 other locations - About 1 hr to fix
        scripts/monitoring/auto_scale_ec2_workers.py on lines 30..34
        scripts/monitoring/auto_scale_workers.py on lines 20..24

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status