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
11 changes: 11 additions & 0 deletions src/ansys/hps/client/check_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

from enum import Enum
from functools import wraps
import logging
from typing import Protocol

from .exceptions import VersionCompatibilityError

log = logging.getLogger(__name__)


class HpsRelease(Enum):
"""HPS release versions."""
Expand Down Expand Up @@ -67,13 +70,21 @@ def check_min_version(version: str, min_version: str) -> bool:
"""Check if a version string meets a minimum version."""
from packaging.version import parse

if version in ["0.0.dev", "0.0.0"]:
log.warning("Skipping min version check for backend development version")
return True

return parse(version) >= parse(min_version)


def check_max_version(version: str, max_version: str) -> bool:
"""Check if a version string meets a maximum version."""
from packaging.version import parse

if version in ["0.0.dev", "0.0.0"]:
log.warning("Skipping max version check for backend development version")
return True

return parse(version) <= parse(max_version)


Expand Down
5 changes: 5 additions & 0 deletions tests/test_check_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ def fn3(self):

assert MockApi("0.1.8").fn3()
assert MockApi("1.2.3").fn3()

# test skipping check for dev version
assert MockApi("0.0.dev").fn1()
assert MockApi("0.0.0").fn2()
assert MockApi("0.0.dev").fn3()
Loading