in telemetry/telemetry.py [0:0]
def get_notebook_name():
"""Return the name of the running notebook."""
name = "unknown"
# first we try to get the name from the Jupyter environment
if os.environ.get("JPY_SESSION_NAME"):
name = os.path.basename(os.environ["JPY_SESSION_NAME"])
# next we check for Visual Studio Code metadata
elif "__vsc_ipynb_file__" in globals():
name = os.path.basename(globals()["__vsc_ipynb_file__"])
# else we try to get it from the Colab environment
else:
import requests
try:
name = requests.get("http://172.28.0.12:9000/api/sessions").json()[0][
"name"
]
except Exception:
pass
return name.split(".ipynb")[0].lower()