aiidateam / aiida-wannier90

AiiDA plugin for the Wannier90 code
https://aiida-wannier90.readthedocs.io
Other
9 stars 15 forks source link

AttributeError: module 'aiida.common' has no attribute 'setup' #25

Closed DanielMarchand closed 5 years ago

DanielMarchand commented 5 years ago

When running the wannier90 tests, (latest dev branch, at time of writing of aiida_core, aiida-wannier90 branch of aiida-wannier repo).

$cd $MY_AIIDA_DIR/aiida-wannier90/tests $pytest

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/daniel/virtualenvs/aiida_v1.0.0b/lib/python3.6/site-packages/aiida_pytest/_configure.py:65: in configure
    with reset_after_run():
/usr/lib/python3.6/contextlib.py:81: in __enter__
    return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextmanager
    def reset_after_run():
>       config_folder = os.path.expanduser(aiida.common.setup.AIIDA_CONFIG_FOLDER)
E       AttributeError: module 'aiida.common' has no attribute 'setup'

/home/daniel/virtualenvs/aiida_v1.0.0b/lib/python3.6/site-packages/aiida_pytest/_configure.py:142: AttributeError
============================================================================================= 8 error in 1.78 seconds =============================================================================================

This is odd because if I run a $verdi shell I can, in fact, import aiida.common.setup

(FYI this is really just assigned to me, I'm using the 'assign' function merely to alert you to the existence of the issue)

giovannipizzi commented 5 years ago

Hi, this has been moved to aiida.manage.configuration.settings.AIIDA_CONFIG_FOLDER (@sphuber is this correct?)

However, one shouldn't use this property directly, but use the method of the Manager, e.g. load_config() as an example. Where is the actual code getting the config_folder? What is the ultimate goal of the function, so we can point you at the best function to call?

DanielMarchand commented 5 years ago

Hi Giovanni,

I did a bit of digging, the errors are coming from aiida_pytest, a dependency which I see has not been migrated. I've applied the basic changes to aiida_pytest and made a pull request https://github.com/greschd/aiida_pytest/pull/9, however the aiida_pytest tests still do not pass.

Do you know who developed aiida_pytest, ideally, they could migrate the plugin to b1. Else, we can do it or, we could consider breaking the dependency and making the wannier90 tests entirely self-sufficient.

giovannipizzi commented 5 years ago

Yes, it's Dominik Gresch @greschd - I think that some of the features have inspired the AiiDA fixtures and are now present in the AiiDA fixtures. I'd like to hear @greschd 's feeling, but if not essential I'd try to use the AiiDA fixtures, and improve them with the code from aiida_pytest where appropriate

greschd commented 5 years ago

Hi all,

I agree with Giovanni's suggestion here: It's best to replace the aiida_pytest with AiiDA's own fixtures wherever possible, to avoid compatibility issues.

To be honest, aiida_pytest is quite an ugly code, it should be considered more as a first draft of the fixture feature. It also has some warts coming from the pre-click command-line interface, where it needs to mimic keyboard input.

I didn't have the time to get acquainted with the AiiDA fixtures yet, so I'm not sure if there might be something in aiida_pytest which is still missing.

DanielMarchand commented 5 years ago

OK, thanks for letting us know, I'll work on swapping out aiida_pytest with the new test fixtures.

giovannipizzi commented 5 years ago

Tests are running fine on travis so I will close this issue. Discussion on aiida-pytest can be moved to other issues if needed