Skip to content

Development environment

Leopold Talirz edited this page Mar 5, 2021 · 22 revisions

Getting the code

  • fork the aiida-core repository

  • git clone your fork to have a local copy.

  • Check out the right branch and create a new one for your development:

    git checkout develop
    git checkout -b my-new-addition
    

Creating a python virtual environment

We recommend doing any development on AiiDA in a separate virtual python environment. If you don't already have your own tools to do this, we recommend using conda environments:

Pre-commit hooks

The AiiDA pre-commit hooks help you write clean code by running

  • code formatting
  • syntax checking
  • static analysis
  • checks for missing docstrings
  • checks for consistency of dependencies and version numbers
  • ...

locally at every commit you make. We currently use yapf and prospector, but more tools may follow.

Set up the hooks as follows:

cd aiida-core
pip install -e .[pre-commit]
pre-commit install
pre-commit run  # test running the hooks
# from now on, hooks will check the *changed* files on every commit

Besides of pre-commit, you may want to take a look at other complements you can also install such as tests and docs (take a look at the "extras_require" inside of the setup.json).

Note:

  • If you work in a conda environment on a system that also has virtualenv installed, you may need to conda install virtualenv to avoid problems with virtualenv inside conda.
  • On Ubuntu-18.04 you may need to sudo apt install ruby-dev

Useful commands

  • Use pre-commit run to run the checks without committing
  • If you ever need to commit a 'work in progress' you may skip the checks via git commit --no-verify. Yet, keep in mind that the pre-commit hooks will also run (and fail) at the continuous integration stage when you push them upstream.
  • For historical reasons, some code files are excluded from pre-commit checks in aiida. When touching such a file, please try to remove them from the exclude list .pre-commit-config.yaml.

Troubleshooting

  • In some cases of very long strings, yapf will not be able to split the string and then prospector will complain. In this case just split the string manually. See discussion in #2114.

Using Windows Subsystem for Linux (WSL)

For speed considerations WSL 2 is recommended. WSL 2 introduces a full-blown VM for your Linux distributions, meaning faster I/O-operations and no need for Windows "support" services (like RabbitMQ). In other words, WSL 2 should provide a more self-contained installation and running experience.

Note, however that it is only available through the Windows Insider Program, using Windows 10 builds 18917 and higher. For more information, see the WSL documentation.

Tip:

Consider using Visual Studio Code with the Remote WSL extension for a full IDE experience, if you're not using in-terminal IDEs. See the VS Code WSL documentation for more information.

Clone this wiki locally