aiidateam / aiida-pseudo

MIT License
5 stars 8 forks source link

CLI: update to be compatible with `aiida-core==2.1` #136

Closed sphuber closed 1 year ago

sphuber commented 1 year ago

Fixes #130

Currently the CLI is broken with aiida-core==2.1. The reason is that we are using the PROFILE option, which relies on the command that it is attached to configure certain things, such as the context. In v2.1, the behavior was changed causing the commands to except because the PROFILE option cannot find certain attributes it expects in the context.

For the PROFILE option to work, the root command should use the class aiida.cmdline.groups.VerdiCommandGroup as its cls. This class defines a custom context class that is necessary. It also automatically provides the verbosity option for all subcommands, so the explicit declaration can now be removed.

The problem was not detected in the unit tests because they only show up when the root command is invoked. The unit tests call the subcommands directly though, and this circumvents the root command. This is documented behavior of click and there is no way around it. The only solution is to call the commands through the command line interface exactly as they would be called normally.

This is now done in the test_commands.py file. The test parametrizes over all existing (sub)commands and directly calls it as a subprocess. This guarantees that the root command is called including its specific context that needs to be setup.