forked from recommenders-team/recommenders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotebook_utils.py
37 lines (30 loc) · 904 Bytes
/
notebook_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
def is_jupyter():
"""Check if the module is running on Jupyter notebook/console.
Returns:
bool: True if the module is running on Jupyter notebook or Jupyter console,
False otherwise.
"""
try:
shell_name = get_ipython().__class__.__name__
if shell_name == "ZMQInteractiveShell":
return True
else:
return False
except NameError:
return False
def is_databricks():
"""Check if the module is running on Databricks.
Returns:
bool: True if the module is running on Databricks notebook,
False otherwise.
"""
try:
if os.path.realpath(".") == "/databricks/driver":
return True
else:
return False
except NameError:
return False