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

chore(analytics): use utils is_jupyter to determine notebook state #5173

Merged
merged 1 commit into from
Jan 7, 2025
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: 2 additions & 15 deletions src/bentoml/_internal/utils/analytics/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ...configuration import BENTOML_VERSION
from ...configuration.containers import BentoMLContainer
from ...utils import bentoml_cattr
from ...utils import is_jupyter

if t.TYPE_CHECKING:
from pathlib import Path
Expand Down Expand Up @@ -92,20 +93,6 @@ def is_interactive() -> bool:
return not hasattr(main, "__file__")


@lru_cache(maxsize=1)
def in_notebook() -> bool:
try:
from IPython import get_ipython

if "IPKernelApp" not in get_ipython().config: # pragma: no cover
return False
except ImportError:
return False
except AttributeError:
return False
return True


@attr.define
class CommonProperties:
# when the event is triggered
Expand All @@ -116,7 +103,7 @@ class CommonProperties:
bentoml_version: str = attr.field(default=BENTOML_VERSION)
python_version: str = attr.field(factory=get_python_version)
is_interactive: bool = attr.field(factory=is_interactive)
in_notebook: bool = attr.field(factory=in_notebook)
in_notebook: bool = attr.field(factory=is_jupyter)

# resource related
memory_usage_percent: float = attr.field(init=False)
Expand Down
Loading