Fix IPython detection. The previous attempt triggered if a module from IPython were imported even if we weren't actually in an IPython shell.
@@ -297,12 +297,13 @@ def try_to_set_up_logging():
def get_python_type():
- if 'ipykernel' in sys.modules:
- return 'jupyter'
- elif 'IPython' in sys.modules:
+ try:
+ if 'terminal' in get_ipython().__module__:
return 'ipython'
else:
- return 'python'
+ return 'jupyter'
+ except (NameError, AttributeError):
+ return "python"
def init(job_type='train', config=None, allow_val_change=False):
