aiida-common-workflows icon indicating copy to clipboard operation
aiida-common-workflows copied to clipboard

Allow the possibility to install only certain packages

Open bosonie opened this issue 3 years ago • 3 comments

The number of codes involved in the project is growing (14 so far) and, with that, the number of dependencies of our package. In fact, each code has an associated AiiDA plugin with relative dependencies. We should set up a system that allows to install only the packages one user is interested about. I'm thinking something like pip install aiida-common-workflows[siesta,vasp,fleur]. It is in fact unlikely that one user wants to try all the codes involved in the project. Do you foresee any downside of this approach?

bosonie avatar Oct 14 '21 07:10 bosonie

This is something I would also support, if it is possible to implement. I guess we have other more pressing issue that should be prioritized, but this would indeed be nice to have at some point.

espenfl avatar Oct 14 '21 07:10 espenfl

I agree! Many plugins have a lot of dependencies, some are even sometimes hard to install.

I think though that we should also have a [all] as an option, if one really wants. I think this should only decide which dependencies to install, but all implementations will be there (then, this is easy, it's just a matter of moving dependencies to extras). The important thing is to make sure that there are no top-level imports for these optional dependencies (or, at least, these are only in files that would be loaded only when a user really wants to use that module). For user's convenience, maybe also the factory should do a try/except ImportError to provide an error message that is easy to understand.

One question: by default, is there any dependency that is installed? I.e., do we want to have some minimal set of codes that are always there? E.g. the MaX codes, or the open codes available in quantum mobile? Or, should we define names for those (e.g. [max], or [quantummobile])? (I don't know, just a suggestion)

To make sure this works, I suggest that in the tests we run tests with:

  1. all implementations known, to check that there are no obvious dependencies conflicts
  2. only one implementation A, to check that there are no import errors for all other ones
  3. only another implementation B, to check that if implementation A is missing, it does not raise ImportErrors (the only case that could have been missed in the tests of point 2).

giovannipizzi avatar Oct 18 '21 08:10 giovannipizzi

I also agree and would simply provide an extra option for each code that provides at least one implementation and the all as suggested by @giovannipizzi .

For user's convenience, maybe also the factory should do a try/except ImportError to provide an error message that is easy to understand.

This is possible, but we would have to override the WorkflowFactory from aiida-core. We can override it to check the entry point, which should always be of the form common_workflows.{workflow}.{plugin}. If we create the convention that the plugin name in the entry points will also be the key of the extra requirements, it is easy to format the message:

Please install the additional required dependencies with `pip install aiida-common-workflows[plugin]`.

Or, should we define names for those (e.g. [max], or [quantummobile])? (I don't know, just a suggestion)

I wouldn't install anything by default to be honest. In any case, if a user wants to start using the package, they have to configure the codes in AiiDA, so asking them to install the package with the extras they need seems like an acceptable extra step. For existing pre-configured environments, such as Quantum Mobilue, it would also be easy to install the packages it needs. Of course we could opt for a [max] tag, but I think this is easier to just keep in the script that builds the QM image. If their requirements change and a code should be added or removed, we have to update aiida-common-workflows and make a new release, which seems like a lot of hassle for no good reason.

sphuber avatar Oct 18 '21 09:10 sphuber