Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/jabs-core/src/jabs/core/utils/update_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def check_for_update() -> tuple[bool, str | None, str]:
has_update = parse_version(latest_version) > parse_version(current_version)
return has_update, latest_version, current_version
except Exception as e:
logger.warning(f"Failed to check for updates: {e}")
logger.warning("Failed to check for updates: %s", e)
return False, None, version_str()


Expand All @@ -49,5 +49,5 @@ def is_pypi_install() -> bool:
installer = dist.read_text("INSTALLER")
return installer is not None and installer.strip() in ("pip", "uv")
except Exception as e:
logger.debug(f"Could not determine installation method: {e}")
logger.debug("Could not determine installation method: %s", e)
return False
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Unit tests for jabs.utils.update_checker module."""
"""Unit tests for jabs.core.utils.update_checker module."""

import json
from importlib import metadata
from unittest.mock import MagicMock, Mock, patch

from jabs.utils.update_checker import check_for_update, is_pypi_install
from jabs.core.utils.update_checker import check_for_update, is_pypi_install


class TestCheckForUpdate:
Expand All @@ -18,7 +18,7 @@ def test_update_available(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="0.9.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="0.9.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -35,7 +35,7 @@ def test_no_update_available(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -52,7 +52,7 @@ def test_newer_local_version(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="2.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="2.0.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -64,7 +64,7 @@ def test_newer_local_version(self):
def test_network_error(self):
"""Test handling of network errors when checking for updates."""
with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch(
"urllib.request.urlopen",
side_effect=Exception("Network error"),
Expand All @@ -84,7 +84,7 @@ def test_invalid_json_response(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -101,7 +101,7 @@ def test_missing_version_in_response(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -118,7 +118,7 @@ def test_timeout_handling(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch("urllib.request.urlopen", return_value=mock_response) as mock_urlopen,
):
check_for_update()
Expand All @@ -136,7 +136,7 @@ def test_version_comparison_with_prereleases(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="0.9.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="0.9.0"),
patch("urllib.request.urlopen", return_value=mock_response),
):
has_update, latest, current = check_for_update()
Expand All @@ -153,7 +153,7 @@ def test_pypi_api_url(self):
mock_response.__exit__ = Mock(return_value=False)

with (
patch("jabs.utils.update_checker.version_str", return_value="1.0.0"),
patch("jabs.core.utils.update_checker.version_str", return_value="1.0.0"),
patch("urllib.request.urlopen", return_value=mock_response) as mock_urlopen,
):
check_for_update()
Expand Down
8 changes: 6 additions & 2 deletions src/jabs/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""JABS utilities"""
"""JABS utilities.

from .update_checker import check_for_update, is_pypi_install
The update-check helpers live in ``jabs-core`` and are re-exported here so that
``from jabs.utils import check_for_update`` keeps working for the GUI.
"""

from jabs.core.utils import check_for_update, is_pypi_install

# a hard coded random seed used for the final training done with all
# training data before saving the classifier
Expand Down
53 changes: 0 additions & 53 deletions src/jabs/utils/update_checker.py

This file was deleted.

Loading