Jupyter: Adds notebook checks
@@ -11,6 +11,25 @@ versions = _version.get_versions()
__info = {"version": versions['version'], "git_revision": versions['full-revisionid']}
+def _isnotebook():
+ """
+ Checks if we are inside a jupyter notebook or not.
+ """
+ try:
+ shell = get_ipython().__class__.__name__
+ if shell in ['ZMQInteractiveShell', 'google.colab._shell']:
+ return True
+ elif shell == 'TerminalInteractiveShell':
+ return False
+ else:
+ return False
+ except NameError:
+ return False
+
+
+__info["isnotebook"] = _isnotebook()
+
+
def get_information(key):
"""
Obtains a variety of runtime information about QCFractal.
@@ -27,4 +46,8 @@ def provenance_stamp(routine):
generating routine's name is passed in through `routine`.
"""
- return {'creator': 'QCFractal', 'version': get_information('version'), 'routine': routine}
\ No newline at end of file
+ return {
+ 'creator': 'QCFractal',
+ 'version': get_information('version'),
+ 'routine': routine,
+ }
\ No newline at end of file
