From d4c495437c80497b80eb96fa1df7a0dd0e9da210 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Mon, 2 Dec 2024 11:22:03 +0100 Subject: [PATCH 1/4] Expose API for first level import aiida --- src/aiida/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/aiida/__init__.py b/src/aiida/__init__.py index 743c5009ab..23797eecaa 100644 --- a/src/aiida/__init__.py +++ b/src/aiida/__init__.py @@ -19,8 +19,8 @@ More information at http://www.aiida.net """ -from aiida.common.log import configure_logging # noqa: F401 -from aiida.manage.configuration import get_config_option, get_profile, load_profile, profile_context # noqa: F401 +from aiida.common.log import configure_logging +from aiida.manage.configuration import get_config_option, get_profile, load_profile, profile_context __copyright__ = ( 'Copyright (c), This file is part of the AiiDA platform. ' @@ -35,6 +35,17 @@ ) __paper_short__ = 'S. P. Huber et al., Scientific Data 7, 300 (2020).' +__all__ = [ + 'load_profile', + 'configure_logging', + 'get_config_option', + 'get_profile', + 'profile_context', + 'get_strict_version', + 'get_version', + 'get_file_header', +] + def get_strict_version(): """Return a distutils StrictVersion instance with the current distribution version @@ -93,7 +104,7 @@ def get_file_header(comment_char: str = '# ') -> str: return '\n'.join(f'{comment_char}{line}' for line in lines) -def load_ipython_extension(ipython): +def _load_ipython_extension(ipython): """Load the AiiDA IPython extension, using ``%load_ext aiida``.""" from .tools.ipython.ipython_magics import AiiDALoaderMagics From 53dff727a67f5b24d3483f6dc71ad3ca916091a8 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Mon, 2 Dec 2024 11:26:46 +0100 Subject: [PATCH 2/4] Redirect load_ipython_extension to the deprecated implementation --- src/aiida/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/aiida/__init__.py b/src/aiida/__init__.py index 23797eecaa..ac2490414c 100644 --- a/src/aiida/__init__.py +++ b/src/aiida/__init__.py @@ -44,6 +44,7 @@ 'get_strict_version', 'get_version', 'get_file_header', + 'load_ipython_extension', ] @@ -104,8 +105,8 @@ def get_file_header(comment_char: str = '# ') -> str: return '\n'.join(f'{comment_char}{line}' for line in lines) -def _load_ipython_extension(ipython): +def load_ipython_extension(ipython): """Load the AiiDA IPython extension, using ``%load_ext aiida``.""" - from .tools.ipython.ipython_magics import AiiDALoaderMagics + from aiida.tools.ipython.ipython_magics import load_ipython_extension - ipython.register_magics(AiiDALoaderMagics) + load_ipython_extension(ipython) From 77ad915dd27d27b41156f5c1b895cb5b0d4805a6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:47:37 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/aiida/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aiida/__init__.py b/src/aiida/__init__.py index ac2490414c..00f51cff95 100644 --- a/src/aiida/__init__.py +++ b/src/aiida/__init__.py @@ -36,15 +36,15 @@ __paper_short__ = 'S. P. Huber et al., Scientific Data 7, 300 (2020).' __all__ = [ - 'load_profile', 'configure_logging', 'get_config_option', + 'get_file_header', 'get_profile', - 'profile_context', 'get_strict_version', 'get_version', - 'get_file_header', 'load_ipython_extension', + 'load_profile', + 'profile_context', ] From 8bb411f6b212e2203b1a6e4d1c1f87489518599d Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Mon, 2 Dec 2024 21:01:00 +0100 Subject: [PATCH 4/4] rda --- src/aiida/__init__.py | 5 ++++- src/aiida/tools/ipython/ipython_magics.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/aiida/__init__.py b/src/aiida/__init__.py index 00f51cff95..88d97aaddc 100644 --- a/src/aiida/__init__.py +++ b/src/aiida/__init__.py @@ -106,7 +106,10 @@ def get_file_header(comment_char: str = '# ') -> str: def load_ipython_extension(ipython): - """Load the AiiDA IPython extension, using ``%load_ext aiida``.""" + """Load the AiiDA IPython extension, using ``%load_ext aiida``. + + :param ipython: InteractiveShell instance. If ``None``, the global InteractiveShell is used. + """ from aiida.tools.ipython.ipython_magics import load_ipython_extension load_ipython_extension(ipython) diff --git a/src/aiida/tools/ipython/ipython_magics.py b/src/aiida/tools/ipython/ipython_magics.py index 486ee50481..342053eb55 100644 --- a/src/aiida/tools/ipython/ipython_magics.py +++ b/src/aiida/tools/ipython/ipython_magics.py @@ -205,7 +205,6 @@ def register_ipython_extension(ipython=None): The %aiida IPython extension provides the same environment as the `verdi shell`. :param ipython: InteractiveShell instance. If omitted, the global InteractiveShell is used. - """ if ipython is None: ipython = get_ipython()