From ef01782e3f9d7718f81d337dabfafd2267cc4f80 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 14 Jun 2021 16:12:23 +0200 Subject: [PATCH] Remove deprecated profile options of connect.py --- CHANGELOG.md | 2 ++ ipykernel/connect.py | 76 ++++++-------------------------------------- 2 files changed, 12 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63586900b..7e70dfaaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changes in IPython kernel +* remove `find_connection_file` and profile arg of `connect_qtconsole` and `get_connection_info`, deprecated since IPykernel 4.2.2. + * Set `stop_on_error_timeout` default to 0.0 matching pre 5.5.0 default behavior with correctly working flag from 5.5.0. ## 5.5 diff --git a/ipykernel/connect.py b/ipykernel/connect.py index 08c374141..5f3560b39 100644 --- a/ipykernel/connect.py +++ b/ipykernel/connect.py @@ -34,80 +34,27 @@ def get_connection_file(app=None): return filefind(app.connection_file, ['.', app.connection_dir]) -def find_connection_file(filename='kernel-*.json', profile=None): - """DEPRECATED: find a connection file, and return its absolute path. - - THIS FUNCTION IS DEPRECATED. Use jupyter_client.find_connection_file instead. - - Parameters - ---------- - filename : str - The connection file or fileglob to search for. - profile : str [optional] - The name of the profile to use when searching for the connection file, - if different from the current IPython session or 'default'. - - Returns - ------- - str : The absolute path of the connection file. - """ - - import warnings - warnings.warn("""ipykernel.find_connection_file is deprecated, use jupyter_client.find_connection_file""", - DeprecationWarning, stacklevel=2) - from IPython.core.application import BaseIPythonApplication as IPApp - try: - # quick check for absolute path, before going through logic - return filefind(filename) - except IOError: - pass - - if profile is None: - # profile unspecified, check if running from an IPython app - if IPApp.initialized(): - app = IPApp.instance() - profile_dir = app.profile_dir - else: - # not running in IPython, use default profile - profile_dir = ProfileDir.find_profile_dir_by_name(get_ipython_dir(), 'default') - else: - # find profiledir by profile name: - profile_dir = ProfileDir.find_profile_dir_by_name(get_ipython_dir(), profile) - security_dir = profile_dir.security_dir - - return jupyter_client.find_connection_file(filename, path=['.', security_dir]) - - -def _find_connection_file(connection_file, profile=None): +def _find_connection_file(connection_file): """Return the absolute path for a connection file - If nothing specified, return current Kernel's connection file - - If profile specified, show deprecation warning about finding connection files in profiles - Otherwise, call jupyter_client.find_connection_file """ if connection_file is None: # get connection file from current kernel return get_connection_file() else: - # connection file specified, allow shortnames: - if profile is not None: - warnings.warn( - "Finding connection file by profile is deprecated.", - DeprecationWarning, stacklevel=3, - ) - return find_connection_file(connection_file, profile=profile) - else: - return jupyter_client.find_connection_file(connection_file) - - -def get_connection_info(connection_file=None, unpack=False, profile=None): + return jupyter_client.find_connection_file(connection_file) + + +def get_connection_info(connection_file=None, unpack=False): """Return the connection information for the current Kernel. Parameters ---------- connection_file : str [optional] The connection file to be used. Can be given by absolute path, or - IPython will search in the security directory of a given profile. + IPython will search in the security directory. If run from IPython, If unspecified, the connection file for the currently running @@ -115,14 +62,13 @@ def get_connection_info(connection_file=None, unpack=False, profile=None): unpack : bool [default: False] if True, return the unpacked dict, otherwise just the string contents of the file. - profile : DEPRECATED Returns ------- The connection dictionary of the current kernel, as string or dict, depending on `unpack`. """ - cf = _find_connection_file(connection_file, profile) + cf = _find_connection_file(connection_file) with open(cf) as f: info = f.read() @@ -134,7 +80,7 @@ def get_connection_info(connection_file=None, unpack=False, profile=None): return info -def connect_qtconsole(connection_file=None, argv=None, profile=None): +def connect_qtconsole(connection_file=None, argv=None): """Connect a qtconsole to the current kernel. This is useful for connecting a second qtconsole to a kernel, or to a @@ -144,14 +90,13 @@ def connect_qtconsole(connection_file=None, argv=None, profile=None): ---------- connection_file : str [optional] The connection file to be used. Can be given by absolute path, or - IPython will search in the security directory of a given profile. + IPython will search in the security directory. If run from IPython, If unspecified, the connection file for the currently running IPython Kernel will be used, which is only allowed from inside a kernel. argv : list [optional] Any extra args to be passed to the console. - profile : DEPRECATED Returns ------- @@ -159,7 +104,7 @@ def connect_qtconsole(connection_file=None, argv=None, profile=None): """ argv = [] if argv is None else argv - cf = _find_connection_file(connection_file, profile) + cf = _find_connection_file(connection_file) cmd = ';'.join([ "from IPython.qt.console import qtconsoleapp", @@ -180,7 +125,6 @@ def connect_qtconsole(connection_file=None, argv=None, profile=None): __all__ = [ 'write_connection_file', 'get_connection_file', - 'find_connection_file', 'get_connection_info', 'connect_qtconsole', ]