aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
433 stars 186 forks source link

$HOME/.aiida/config.json be forced migrated even I have AIIDA_PATH set other path #5935

Closed unkcpz closed 1 year ago

unkcpz commented 1 year ago

Describe the bug

I have a conda (micromamba) environment set with AIIDA_PATH set by in the /home/jyu/micromamba/envs/aiida-sssp-dev/etc/conda/activate.d/env_vars.sh, I have:

export AIIDA_PATH="/home/jyu/micromamba/envs/aiida-sssp-dev/etc/.aiida"

but when I activate the env by micromamba activate the /home/jyu/.aiida/config.json is forced migrated to the latest version compatible with the aiida-core version in the conda environment.

The message I got:

current configuration file `/home/jyu/.aiida/config.json` is outdated and will be migrated
original backed up to `/home/jyu/.aiida/config.json.20230317-112911.203557`

Steps to reproduce

Steps to reproduce the behavior:

  1. create a new conda (I didn't check conda but use the micromamba, maybe that is the issue?) environment and set the env_var.sh with the AIIDA_PATH.
  2. Installed latest aiida-core.
  3. In $HOME/.aiida/config.json, the config version is the old compatible version, I have 5.
  4. activate the conda environment and the message as shown above for config migration poped up.

Expected behavior

If the specific AIIDA_PATH is set, it will be used.

Your environment

Other relevant software versions, e.g. Postres & RabbitMQ

Additional context

sphuber commented 1 year ago

The config is retrieved in aiida.manage.configuration.load_config, the path of which is determined by aiida.manage.configuration.get_config_path. That uses the AIIDA_CONFIG_FOLDER global from aiida.manage.configuration.settings which should be based on the AIIDA_PATH variable. Can you open an ipython shell and run the following:

In [1]: from aiida.manage.configuration import get_config_path

In [2]: get_config_path()
Out[2]: '/home/sph/.aiida/config.json'

In [3]: from aiida.manage.configuration.settings import AIIDA_CONFIG_FOLDER

In [4]: AIIDA_CONFIG_FOLDER
Out[4]: PosixPath('/home/sph/.aiida')

That should be a first check to see whether the env variable is read.

unkcpz commented 1 year ago

Thanks @sphuber. The catch in my case is the issue happened when I run micromamba activate <env>. The profile and the python environment are not yet loaded I assume. I tried to add print in here https://github.com/aiidateam/aiida-core/blob/0bc8ef06b57ee31a5062a225c23f04fc26d00980/aiida/manage/configuration/config.py#L100-L104, but very strange that nothing is printed out.

I'll try if this issue can be reproduced in conda.

sphuber commented 1 year ago

Did you find anything more out concerning this issues @unkcpz ?

unkcpz commented 1 year ago

Sadly, no, it is not an issue for me now, I delete the aiida-core installed by the system python which is an old version, and keep all environments separated in micromamba env the issue didn't show again. I close this and I'll reopen it if encounter again with more details.