Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check rerun notebook version on first import #8030

Merged
merged 4 commits into from
Nov 12, 2024
Merged
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
17 changes: 17 additions & 0 deletions rerun_py/rerun_sdk/rerun/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def set_default_size(*, width: int | None, height: int | None) -> None:
_default_height = height


_version_mismatch_checked = False


class Viewer:
"""
A viewer embeddable in a notebook.
Expand Down Expand Up @@ -80,6 +83,20 @@ def __init__(
"""

try:
global _version_mismatch_checked
if not _version_mismatch_checked:
import importlib.metadata
import warnings

rerun_notebook_version = importlib.metadata.version("rerun-notebook")
rerun_version = importlib.metadata.version("rerun-sdk")
if rerun_version != rerun_notebook_version:
warnings.warn(
f"rerun-notebook version mismatch: rerun-sdk {rerun_version}, rerun-notebook {rerun_notebook_version}",
category=ImportWarning,
)
_version_mismatch_checked = True

from rerun_notebook import Viewer as _Viewer # type: ignore[attr-defined]
except ImportError:
logging.error("Could not import rerun_notebook. Please install `rerun-notebook`.")
Expand Down
Loading