Skip to content

Commit

Permalink
Explicitly load and set configuration folder in the main module level
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 20, 2024
1 parent 8408ef5 commit e5768f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/aiida/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

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.manage.configuration.settings import AiiDAConfigPathResolver

__copyright__ = (
'Copyright (c), This file is part of the AiiDA platform. '
Expand All @@ -35,6 +36,8 @@
)
__paper_short__ = 'S. P. Huber et al., Scientific Data 7, 300 (2020).'

# Initialize the configuration directory settings
AiiDAConfigPathResolver.set_configuration_directory()

def get_strict_version():
"""Return a distutils StrictVersion instance with the current distribution version
Expand Down
5 changes: 0 additions & 5 deletions src/aiida/manage/configuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,3 @@ def _get_configuration_directory_from_envvar() -> pathlib.Path:
break

return dirpath_config or default_dirpath_config


# XXX: Can I move this to aiida.__init__???
# Initialize the configuration directory settings
AiiDAConfigPathResolver.set_configuration_directory()
8 changes: 5 additions & 3 deletions tests/manage/test_caching_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def test_merge_deprecated_yaml(tmp_path):
"""
from aiida.common.warnings import AiidaDeprecationWarning
from aiida.manage import configuration, get_manager
from aiida.manage.configuration import get_config_option, load_profile, settings
from aiida.manage.configuration import get_config_option, load_profile
from aiida.manage.configuration.settings import AiiDAConfigPathResolver


# Store the current configuration instance and config directory path
current_config = configuration.CONFIG
Expand All @@ -57,7 +59,7 @@ def test_merge_deprecated_yaml(tmp_path):
configuration.CONFIG = None

# Create a temporary folder, set it as the current config directory path
settings.set_configuration_directory(pathlib.Path(tmp_path))
AiiDAConfigPathResolver.set_configuration_directory(pathlib.Path(tmp_path))
config_dictionary = json.loads(
pathlib.Path(__file__)
.parent.joinpath('configuration/migrations/test_samples/reference/6.json')
Expand Down Expand Up @@ -86,7 +88,7 @@ def test_merge_deprecated_yaml(tmp_path):
# Reset the config folder path and the config instance. Note this will always be executed after the yield no
# matter what happened in the test that used this fixture.
get_manager().unload_profile()
settings.set_configuration_directory(current_config_path)
AiiDAConfigPathResolver.set_configuration_directory(current_config_path)
configuration.CONFIG = current_config
load_profile(current_profile_name)

Expand Down

0 comments on commit e5768f6

Please sign in to comment.