~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
chore: delete unused BaseFailure methods (#4173)
LearningCircuit8992eb78df77
diff --git a/src/local_deep_research/library/download_management/failure_classifier.py b/src/local_deep_research/library/download_management/failure_classifier.pyindex cf19ee6f40..26c773e53f 100644--- a/src/local_deep_research/library/download_management/failure_classifier.py+++ b/src/local_deep_research/library/download_management/failure_classifier.py@@ -43,34 +43,6 @@ class BaseFailure(ABC):"""Check if this is a permanent failure (never retry)"""return self.retry_after is None- def can_retry_now(self) -> bool:- """Check if this resource can be retried right now"""- if self.retry_after is None:- return False- return datetime.now(UTC) >= self.created_at + self.retry_after-- def get_cooldown_remaining(self) -> Optional[timedelta]:- """Get remaining cooldown time, or None if no cooldown"""- if self.retry_after is None:- return None-- retry_time = self.created_at + self.retry_after- if datetime.now(UTC) < retry_time:- return retry_time - datetime.now(UTC)- return None-- def to_dict(self) -> dict:- """Convert to dictionary for database storage"""- return {- "error_type": self.error_type,- "message": self.message,- "retry_after_timestamp": self.created_at + self.retry_after- if self.retry_after- else None,- "is_permanent": self.is_permanent(),- "created_at": self.created_at,- }-class PermanentFailure(BaseFailure):"""Resources that should never be retried"""diff --git a/tests/library/download_management/test_failure_classifier.py b/tests/library/download_management/test_failure_classifier.pyindex b38a9d3fee..68a5794d2c 100644--- a/tests/library/download_management/test_failure_classifier.py+++ b/tests/library/download_management/test_failure_classifier.py@@ -83,65 +83,6 @@ class TestBaseFailure:failure = TestFailure("error", "message", timedelta(hours=1))assert failure.is_permanent() is False- def test_can_retry_now_returns_false_for_permanent(self):- """Test that can_retry_now returns False for permanent failures."""- from local_deep_research.library.download_management.failure_classifier import (- BaseFailure,- )-- class TestFailure(BaseFailure):- pass-- failure = TestFailure("error", "message", None)- assert failure.can_retry_now() is False-- def test_can_retry_now_returns_false_during_cooldown(self):- """Test that can_retry_now returns False during cooldown."""- from local_deep_research.library.download_management.failure_classifier import (- BaseFailure,- )-- class TestFailure(BaseFailure):- pass-- # Create failure with 1 hour cooldown- failure = TestFailure("error", "message", timedelta(hours=1))- assert failure.can_retry_now() is False-- def test_to_dict_returns_expected_keys(self):- """Test that to_dict returns expected dictionary keys."""- from local_deep_research.library.download_management.failure_classifier import (- BaseFailure,- )-- class TestFailure(BaseFailure):- pass-- failure = TestFailure("test_error", "Test message", timedelta(hours=1))- result = failure.to_dict()-- assert "error_type" in result- assert "message" in result- assert "retry_after_timestamp" in result- assert "is_permanent" in result- assert "created_at" in result-- def test_to_dict_values_are_correct(self):- """Test that to_dict values are correct."""- from local_deep_research.library.download_management.failure_classifier import (- BaseFailure,- )-- class TestFailure(BaseFailure):- pass-- failure = TestFailure("my_error", "My message", timedelta(hours=2))- result = failure.to_dict()-- assert result["error_type"] == "my_error"- assert result["message"] == "My message"- assert result["is_permanent"] is False-class TestPermanentFailure:"""Tests for PermanentFailure class."""@@ -164,15 +105,6 @@ class TestPermanentFailure:failure = PermanentFailure("forbidden", "Access forbidden")assert failure.retry_after is None- def test_can_never_retry(self):- """Test that can_retry_now always returns False."""- from local_deep_research.library.download_management.failure_classifier import (- PermanentFailure,- )-- failure = PermanentFailure("gone", "Resource gone")- assert failure.can_retry_now() is False-class TestTemporaryFailure:"""Tests for TemporaryFailure class."""@@ -400,49 +332,3 @@ class TestFailureClassifier:result = classifier.classify_from_exception(exception)assert result.error_type == "timeout"---class TestGetCooldownRemaining:- """Tests for get_cooldown_remaining method."""-- def test_returns_none_for_permanent_failure(self):- """Test that None is returned for permanent failures."""- from local_deep_research.library.download_management.failure_classifier import (- PermanentFailure,- )-- failure = PermanentFailure("error", "message")- assert failure.get_cooldown_remaining() is None-- def test_returns_remaining_time_during_cooldown(self):- """Test that remaining time is returned during cooldown."""- from local_deep_research.library.download_management.failure_classifier import (- TemporaryFailure,- )-- # Create failure with 1 hour cooldown- failure = TemporaryFailure("error", "message", timedelta(hours=1))-- remaining = failure.get_cooldown_remaining()- assert remaining is not None- assert remaining.total_seconds() > 0- assert remaining <= timedelta(hours=1)-- def test_returns_none_after_cooldown_expires(self):- """Test that None is returned after cooldown expires."""- from local_deep_research.library.download_management.failure_classifier import (- TemporaryFailure,- )-- # Create failure with very short cooldown- failure = TemporaryFailure(- "error", "message", timedelta(microseconds=1)- )-- # Wait briefly for cooldown to expire- import time-- time.sleep(0.001)-- remaining = failure.get_cooldown_remaining()- assert remaining is Nonediff --git a/tests/library/download_management/test_failure_classifier_extended.py b/tests/library/download_management/test_failure_classifier_extended.pyindex 37856fe2c9..a9bddb847c 100644--- a/tests/library/download_management/test_failure_classifier_extended.py+++ b/tests/library/download_management/test_failure_classifier_extended.py@@ -347,15 +347,8 @@ class TestDomainSpecificLogic:)perm_failure = PermanentFailure("perm", "Permanent")- # Wait briefly for cooldown to expire- import time-- time.sleep(0.1)-- # After cooldown, temporary should be retryable- # Permanent should never be retryable+ # Permanent should always be permanent; temporary should notassert temp_failure.is_permanent() is False- assert perm_failure.can_retry_now() is Falseassert perm_failure.is_permanent() is Truedef test_permanent_failure_reasons(self):@@ -364,22 +357,6 @@ class TestDomainSpecificLogic:assert failure.retry_after is Noneassert failure.is_permanent() is True- assert failure.can_retry_now() is False- assert failure.get_cooldown_remaining() is None-- def test_failure_to_dict_serialization(self):- """Test failure can be serialized to dictionary"""- failure = TemporaryFailure(- "test_error", "Test message", timedelta(hours=2)- )-- result = failure.to_dict()-- assert result["error_type"] == "test_error"- assert result["message"] == "Test message"- assert result["is_permanent"] is False- assert "created_at" in result- assert result["retry_after_timestamp"] is not Noneclass TestBaseFailureMethods:@@ -395,40 +372,6 @@ class TestBaseFailureMethods:failure = TemporaryFailure("test", "Test", timedelta(hours=1))assert failure.is_permanent() is False- def test_can_retry_now_permanent(self):- """Test can_retry_now returns False for permanent failures"""- failure = PermanentFailure("test", "Test")- assert failure.can_retry_now() is False-- def test_can_retry_now_cooldown_active(self):- """Test can_retry_now returns False during active cooldown"""- failure = TemporaryFailure("test", "Test", timedelta(hours=1))- assert failure.can_retry_now() is False-- def test_can_retry_now_cooldown_expired(self):- """Test can_retry_now returns True after cooldown expires"""- failure = TemporaryFailure("test", "Test", timedelta(seconds=0))- assert failure.can_retry_now() is True-- def test_get_cooldown_remaining_permanent(self):- """Test get_cooldown_remaining returns None for permanent"""- failure = PermanentFailure("test", "Test")- assert failure.get_cooldown_remaining() is None-- def test_get_cooldown_remaining_expired(self):- """Test get_cooldown_remaining returns None after expiry"""- failure = TemporaryFailure("test", "Test", timedelta(seconds=0))- assert failure.get_cooldown_remaining() is None-- def test_get_cooldown_remaining_active(self):- """Test get_cooldown_remaining returns time during cooldown"""- failure = TemporaryFailure("test", "Test", timedelta(hours=1))- remaining = failure.get_cooldown_remaining()-- assert remaining is not None- assert remaining > timedelta(0)- assert remaining <= timedelta(hours=1)-def test_created_at_timestamp(self):"""Test created_at is set to current UTC time"""before = datetime.now(UTC)@@ -437,22 +380,6 @@ class TestBaseFailureMethods:assert before <= failure.created_at <= after- def test_to_dict_complete_structure(self):- """Test to_dict returns complete structure"""- failure = TemporaryFailure("test", "Test message", timedelta(hours=2))- result = failure.to_dict()-- expected_keys = [- "error_type",- "message",- "retry_after_timestamp",- "is_permanent",- "created_at",- ]-- for key in expected_keys:- assert key in result, f"Missing key: {key}"-class TestClassifyFromException:"""Tests for classify_from_exception method"""diff --git a/tests/library/download_management/test_failure_classifier_high_value.py b/tests/library/download_management/test_failure_classifier_high_value.pyindex 7fe4a6ab38..0a920c6c0c 100644--- a/tests/library/download_management/test_failure_classifier_high_value.py+++ b/tests/library/download_management/test_failure_classifier_high_value.py@@ -1,6 +1,6 @@"""High-value tests for library/download_management/failure_classifier.py."""-from datetime import timedelta, datetime+from datetime import timedeltafrom local_deep_research.library.download_management.failure_classifier import (@@ -23,23 +23,6 @@ class TestPermanentFailure:f = PermanentFailure("not_found", "Gone")assert f.is_permanent() is True- def test_can_never_retry(self):- f = PermanentFailure("not_found", "Gone")- assert f.can_retry_now() is False-- def test_cooldown_remaining_is_none(self):- f = PermanentFailure("forbidden", "No access")- assert f.get_cooldown_remaining() is None-- def test_to_dict_fields(self):- f = PermanentFailure("not_found", "Resource not found")- d = f.to_dict()- assert d["error_type"] == "not_found"- assert d["message"] == "Resource not found"- assert d["is_permanent"] is True- assert d["retry_after_timestamp"] is None- assert isinstance(d["created_at"], datetime)-def test_error_type_stored(self):f = PermanentFailure("gone", "Permanently removed")assert f.error_type == "gone"@@ -48,6 +31,10 @@ class TestPermanentFailure:f = PermanentFailure("gone", "Permanently removed")assert f.message == "Permanently removed"+ def test_retry_after_is_none(self):+ f = PermanentFailure("not_found", "Resource not found")+ assert f.retry_after is None+# ---------------------------------------------------------------------------# TemporaryFailure@@ -61,31 +48,6 @@ class TestTemporaryFailure:f = TemporaryFailure("timeout", "Timed out", timedelta(minutes=30))assert f.is_permanent() is False- def test_cannot_retry_immediately(self):- f = TemporaryFailure("timeout", "Timed out", timedelta(hours=1))- assert f.can_retry_now() is False-- def test_can_retry_after_cooldown(self):- f = TemporaryFailure("timeout", "Timed out", timedelta(seconds=0))- assert f.can_retry_now() is True-- def test_cooldown_remaining_positive(self):- f = TemporaryFailure("error", "err", timedelta(hours=2))- remaining = f.get_cooldown_remaining()- assert remaining is not None- assert remaining > timedelta(0)-- def test_cooldown_remaining_none_after_expiry(self):- f = TemporaryFailure("error", "err", timedelta(seconds=0))- assert f.get_cooldown_remaining() is None-- def test_to_dict_has_retry_timestamp(self):- f = TemporaryFailure("timeout", "t", timedelta(hours=1))- d = f.to_dict()- assert d["is_permanent"] is False- assert d["retry_after_timestamp"] is not None- assert isinstance(d["retry_after_timestamp"], datetime)-def test_retry_after_stored(self):cooldown = timedelta(minutes=30)f = TemporaryFailure("timeout", "t", cooldown)