Skip to content

Commit

Permalink
warn_package_outdated -> notify_if_package_outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
awoimbee committed Nov 21, 2024
1 parent 1e9ad3e commit 128463c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/ansys/simai/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
)
from ansys.simai.core.utils.config_file import get_config
from ansys.simai.core.utils.configuration import ClientConfig
from ansys.simai.core.utils.misc import warn_package_outdated
from ansys.simai.core.utils.misc import notify_if_package_outdated
from ansys.simai.core.utils.typing import steal_kwargs_type_on_method

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -332,7 +332,7 @@ def _check_for_new_version(self) -> None:
except (SimAIError, KeyError) as e:
logger.debug(f"Could not query package version on pypi: {e}")
return None

Check warning on line 334 in src/ansys/simai/core/client.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/simai/core/client.py#L332-L334

Added lines #L332 - L334 were not covered by tests
warn_package_outdated("ansys-simai-core", __version__, latest_version)
notify_if_package_outdated("ansys-simai-core", __version__, latest_version)


from_config = SimAIClient.from_config
4 changes: 1 addition & 3 deletions src/ansys/simai/core/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

from semver.version import Version

from ansys.simai.core.errors import SimAIError

logger = logging.getLogger(__name__)


Expand All @@ -50,7 +48,7 @@ def dict_get(obj: dict, *keys: str, default=None):
return obj or default


def warn_package_outdated(package: str, current_version: str, latest_version: str):
def notify_if_package_outdated(package: str, current_version: str, latest_version: str):
try:
version_current = Version.parse(current_version)
version_latest = Version.parse(latest_version)
Expand Down
11 changes: 2 additions & 9 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,14 @@ def test_client_creation_invalid_config():

@pytest.mark.parametrize(
"local_ver,latest_ver,expected",
[
("1.1.0", "1.1.1", "available."),
("1.0.9-rc8", "1.0.9", "available."),
("1.0.9", "1.9.0", "required."),
]
],
)
@responses.activate
def test_client_version_auto_warn(
caplog,
mocker,
local_ver,
latest_ver,
expected
):
def test_client_version_auto_warn(caplog, mocker, local_ver, latest_ver, expected):
"""WHEN the SDK version is slightly outdated compared to what the API responds
THEN a warning is printed
"""
Expand Down

0 comments on commit 128463c

Please sign in to comment.