diff --git a/src/aiida/__init__.py b/src/aiida/__init__.py index 75215240d7..7459797b85 100644 --- a/src/aiida/__init__.py +++ b/src/aiida/__init__.py @@ -19,7 +19,15 @@ More information at http://www.aiida.net """ -from aiida.manage.configuration import load_profile +from __future__ import annotations + +from typing import TYPE_CHECKING + +from aiida.common.log import configure_logging +from aiida.manage.configuration import get_config_option, get_profile, load_profile, profile_context + +if TYPE_CHECKING: + from IPython.core.interactiveshell import InteractiveShell __copyright__ = ( 'Copyright (c), This file is part of the AiiDA platform. ' @@ -34,7 +42,7 @@ ) __paper_short__ = 'S. P. Huber et al., Scientific Data 7, 300 (2020).' -__all__ = ['load_profile'] +__all__ = ['load_profile', 'configure_logging', 'get_config_option', 'get_profile', 'profile_context'] def get_strict_version(): @@ -94,7 +102,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: InteractiveShell): """Load the AiiDA IPython extension, using ``%load_ext aiida``.""" from .tools.ipython.ipython_magics import AiiDALoaderMagics diff --git a/src/aiida/common/log.py b/src/aiida/common/log.py index fc0f860aef..378cfa2c9d 100644 --- a/src/aiida/common/log.py +++ b/src/aiida/common/log.py @@ -15,6 +15,7 @@ import enum import io import logging +from pathlib import Path import types import typing as t @@ -164,7 +165,7 @@ def evaluate_logging_configuration(dictionary): return result -def configure_logging(with_orm=False, daemon=False, daemon_log_file=None): +def configure_logging(with_orm: bool = False, daemon: bool = False, daemon_log_file: None | Path = None) -> None: """Setup the logging by retrieving the LOGGING dictionary from aiida and passing it to the python module logging.config.dictConfig. If the logging needs to be setup for the daemon, set the argument 'daemon' to True and specify the path to the log file. This