iterative/dvc

View on GitHub
dvc/repo/experiments/queue/celery.py

Summary

Maintainability
D
2 days
Test Coverage

File celery.py has 531 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import hashlib
import locale
import logging
import os
from collections import defaultdict
Severity: Major
Found in dvc/repo/experiments/queue/celery.py - About 1 day to fix

    LocalCeleryQueue has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LocalCeleryQueue(BaseStashQueue):
        """DVC experiment queue.
    
        Maps queued experiments to (Git) stash reflog entries.
        """
    Severity: Minor
    Found in dvc/repo/experiments/queue/celery.py - About 5 hrs to fix

      Function _get_done_result has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_done_result(
              self, entry: QueueEntry, timeout: Optional[float] = None
          ) -> Optional["ExecutorResult"]:
              from celery.exceptions import TimeoutError as _CeleryTimeout
      
      
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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 _mark_inactive_tasks_failure has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _mark_inactive_tasks_failure(
              self, remained_entries: dict[QueueEntry, str]
          ) -> None:
              remained_revs: list[str] = []
              running_ids = self._get_running_task_ids()
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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 collect_active_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def collect_active_data(
              self,
              baseline_revs: Optional[Collection[str]],
              fetch_refs: bool = False,
              **kwargs,
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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 iter_done has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def iter_done(self) -> Generator[QueueDoneResult, None, None]:
              for result, entry in self._iter_done_tasks():
                  try:
                      exp_result = self.get_result(entry)
                  except FileNotFoundError:
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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 collect_success_executors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def collect_success_executors(
              self,
              baseline_revs: Optional[Collection[str]],
              **kwargs,
          ) -> dict[str, "ExpExecutor"]:
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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 logs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def logs(self, rev: str, encoding: Optional[str] = None, follow: bool = False):
              queue_entry: Optional[QueueEntry] = self.match_queue_entry_by_name(
                  {rev}, self.iter_active(), self.iter_done()
              ).get(rev)
              if queue_entry is None:
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.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

      Function collect_failed_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def collect_failed_data(
              self,
              baseline_revs: Optional[Collection[str]],
              **kwargs,
          ) -> dict[str, list["ExpRange"]]:
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.py - About 25 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 kill has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def kill(self, revs: Collection[str], force: bool = False) -> None:
              name_dict: dict[str, Optional[QueueEntry]] = self.match_queue_entry_by_name(
                  set(revs), self.iter_active()
              )
      
      
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.py - About 25 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 _try_to_kill_tasks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _try_to_kill_tasks(
              self, to_kill: dict[QueueEntry, str], force: bool
          ) -> dict[QueueEntry, str]:
              fail_to_kill_entries: dict[QueueEntry, str] = {}
              for queue_entry, rev in to_kill.items():
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.py - About 25 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 shutdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def shutdown(self, kill: bool = False):
              self.celery.control.shutdown()
              if kill:
                  to_kill: dict[QueueEntry, str] = {}
                  for entry in self.iter_active():
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.py - About 25 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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def wait(self, revs: Collection[str], **kwargs) -> None:
              """Block until the specified tasks have completed."""
              revs = [revs] if isinstance(revs, str) else revs
              results = self.match_queue_entry_by_name(
                  revs, self.iter_queued(), self.iter_done(), self.iter_failed()
      Severity: Minor
      Found in dvc/repo/experiments/queue/celery.py - About 25 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