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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "ValidMind Library"
license = "Commercial License"
name = "validmind"
readme = "README.pypi.md"
version = "2.8.1"
version = "2.8.2"

[tool.poetry.dependencies]
aiohttp = {extras = ["speedups"], version = "*"}
Expand Down
42 changes: 42 additions & 0 deletions validmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@

After you have pasted the code snippet into your development source code and executed the code, the Python Library API will register with ValidMind. You can now use the ValidMind Library to document and test your models, and to upload to the ValidMind Platform.
"""
import threading
import warnings

import pkg_resources
from IPython.display import HTML, display

# Ignore Numba warnings. We are not requiring this package directly
from numba.core.errors import NumbaDeprecationWarning, NumbaPendingDeprecationWarning

Expand All @@ -51,8 +55,46 @@
)
from .tests.decorator import tags, tasks, test
from .tests.run import print_env
from .utils import is_notebook, parse_version
from .vm_models.result import RawData

__shown = False


def show_warning(installed, running):
global __shown

if __shown:
return
__shown = True

message = (
f"⚠️ This kernel is running an older version of validmind ({running}) "
f"than the latest version installed on your system ({installed}).\n\n"
"You may need to restart the kernel if you are experiencing issues."
)
display(HTML(f"<div style='color: red;'>{message}</div>"))


def check_version():
# get the installed vs running version of validmind
# to make sure we are using the latest installed version
# in case user has updated the package but forgot to restart the kernel
installed = pkg_resources.get_distribution("validmind").version
running = __version__

if parse_version(installed) > parse_version(running):
show_warning(installed, running)

# Schedule the next check for 5 minutes from now
timer = threading.Timer(300, check_version)
timer.daemon = True
timer.start()


if is_notebook():
check_version()

__all__ = [ # noqa
"__version__",
# main library API
Expand Down
2 changes: 1 addition & 1 deletion validmind/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.8.1"
__version__ = "2.8.2"
13 changes: 13 additions & 0 deletions validmind/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@
logger = get_logger(__name__)


def parse_version(version: str) -> tuple[int, ...]:
"""
Parse a semver version string into a tuple of major, minor, patch integers

Args:
version (str): The semantic version string to parse

Returns:
tuple[int, ...]: A tuple of major, minor, patch integers
"""
return tuple(int(x) for x in version.split(".")[:3])


def is_notebook() -> bool:
"""
Checks if the code is running in a Jupyter notebook or IPython shell
Expand Down
Loading