|
| 1 | +# Developing HADDOCK3 |
| 2 | + |
| 3 | +This file provides information on how to setup a development environment for HADDOCK3. |
| 4 | + |
| 5 | +- [System requirements](#system-requirements) |
| 6 | +- [Setting up the development environment](#setting-up-the-development-environment) |
| 7 | + - [Clone the repository](#clone-the-repository) |
| 8 | + - [Python environment](#python-environment) |
| 9 | + - [Install Python dependencies](#install-python-dependencies) |
| 10 | + - [Running tests](#running-tests) |
| 11 | + |
| 12 | +## System requirements |
| 13 | + |
| 14 | +- Python 3.9 |
| 15 | +- OpenMPI |
| 16 | + |
| 17 | +### Installing system dependencies |
| 18 | + |
| 19 | +Below the instructions are provided for a Ubuntu system using `apt-get`. If you are using a different system, please refer to the respective package manager - `yum`, `dnf`, `pacman`, `homebrew`, `port`, etc. |
| 20 | + |
| 21 | +```bash |
| 22 | +sudo apt-get update && |
| 23 | + # Needed for building Python |
| 24 | + sudo apt-get install build-essential python-setuptools python-pip && |
| 25 | + sudo apt-get install libncursesw5-dev libgdbm-dev libc6-dev && |
| 26 | + sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev && |
| 27 | + sudo apt-get install libssl-dev openssl && |
| 28 | + sudo apt-get install libffi-dev && |
| 29 | + # Needed for haddock3 installation |
| 30 | + sudo apt-get install git gcc && |
| 31 | + # Needed to run the MPI related tests |
| 32 | + sudo apt-get install openmpi-bin libopenmpi3 libopenmpi-dev |
| 33 | +``` |
| 34 | + |
| 35 | +After all the system-dependencies are in place, download and compile python. |
| 36 | + |
| 37 | +**Conda is NOT recommended for development** |
| 38 | + |
| 39 | +```bash |
| 40 | +wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz |
| 41 | +tar -xf Python-3.9.6.tgz |
| 42 | +cd Python-3.9.6 |
| 43 | +./configure --enable-optimizations |
| 44 | +sudo make altinstall -j 8 |
| 45 | +``` |
| 46 | + |
| 47 | +Then `python3.9` should be available on your system at `/usr/local/bin/python3.9` |
| 48 | + |
| 49 | +On **OSX**, you can use a package-manager such as [brew](https://brew.sh) to install Python 3.9. |
| 50 | + |
| 51 | +> Please keep in mind installing python with a package manager can mask system dependencies that your development might add. That's why we recommended you install it from source. |
| 52 | +
|
| 53 | +```bash |
| 54 | + |
| 55 | +``` |
| 56 | + |
| 57 | +## Setting up the development environment |
| 58 | + |
| 59 | +### Clone the repository |
| 60 | + |
| 61 | +```bash |
| 62 | +git clone https://github.com/haddocking/haddock3.git |
| 63 | +cd haddock3 |
| 64 | +``` |
| 65 | + |
| 66 | +### Python environment |
| 67 | + |
| 68 | +We recommend you use Python's native virtual environment to manage the dependencies. |
| 69 | + |
| 70 | +```bash |
| 71 | +python3.9 -m venv .venv |
| 72 | +source .venv/bin/activate |
| 73 | +``` |
| 74 | + |
| 75 | +### Install python dependencies |
| 76 | + |
| 77 | +Install both project dependencies and test dependencies using pip. |
| 78 | + |
| 79 | +```bash |
| 80 | +pip install -r requirements.txt && |
| 81 | + pip install \ |
| 82 | + coverage==7.2.5 \ |
| 83 | + pytest==7.3.1 \ |
| 84 | + pytest-cov==4.0.0 \ |
| 85 | + hypothesis==6.75.1 \ |
| 86 | + pytest-mock==3.12.0 \ |
| 87 | + fastapi==0.110.1 \ |
| 88 | + httpx==0.27.0 \ |
| 89 | + mpi4py==3.1.6 |
| 90 | +``` |
| 91 | + |
| 92 | +> If you are using a Mac, if the installation of mpi4py fails, run first `brew install mpi4py` |
| 93 | +
|
| 94 | +### Install haddock3 in development mode. |
| 95 | + |
| 96 | +In this mode the files are linked to the appropriate paths inside the python environment; |
| 97 | + |
| 98 | +```bash |
| 99 | +python setup.py develop |
| 100 | +``` |
| 101 | + |
| 102 | +## Running tests |
| 103 | + |
| 104 | +In `haddock3` we use the pytest framework, the tests are located in `tests/` (unit) and `integration_tests/` directories. |
| 105 | + |
| 106 | +```bash |
| 107 | +pytest |
| 108 | +``` |
| 109 | + |
| 110 | +## Installation in an HPC environment |
| 111 | + |
| 112 | +**Please get in contact with the system administrator before doing development in a shared HPC environment.** |
| 113 | + |
| 114 | +For installation in an HPC environment we recommend to check the installed Python versions on the system and also importantly if an `openmpi` (or other custom MPI) installation is available on the system. |
| 115 | +Those are often offered via the `module` command. |
| 116 | +If you only intend to develop haddock3 using the multiprocessing scheduler, the above instructions should be fine. But to harvest the MPI capabilities of an HPC system it is best to build haddock3 using the installed MPI version on the HPC system. |
0 commit comments