|
| 1 | +# Developer Guide |
| 2 | + |
| 3 | +## Installation guide |
| 4 | + |
| 5 | +The Python implementation of DePSI is under development. At present you can only install it from the GitHub repository. |
| 6 | + |
| 7 | +It is assumed that you have `mamba` installed. If not, you can find the installation instructions [here](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html). Other package managers like `conda` or `venv` can be used as well. |
| 8 | + |
| 9 | +Clone this repository and `cd` into it: |
| 10 | + |
| 11 | +```bash |
| 12 | +git clone git@github.com:TUDelftGeodesy/DePSI.git |
| 13 | +cd DePSI |
| 14 | +``` |
| 15 | + |
| 16 | +Create a new conda environment (here we give an example name `depsi-dev`) with `mamba`.: |
| 17 | + |
| 18 | +```bash |
| 19 | +mamba create -c conda-forge -n depsi-dev python=3.12 |
| 20 | +``` |
| 21 | + |
| 22 | +Here we use Python 3.12 since we aim to support python 3.10 and above. |
| 23 | + |
| 24 | +Activate the environment: |
| 25 | + |
| 26 | +```bash |
| 27 | +mamba activate depsi-dev |
| 28 | +``` |
| 29 | + |
| 30 | +Install this package in development mode, with extra dependencies for development and documentation: |
| 31 | + |
| 32 | +```bash |
| 33 | +pip install -e ".[dev,docs]" |
| 34 | +``` |
| 35 | + |
| 36 | +In the end, install the pre-commit hooks, which will run the checks before each commit: |
| 37 | +```bash |
| 38 | +pre-commit install |
| 39 | +``` |
| 40 | + |
| 41 | +## Linting and formatting |
| 42 | + |
| 43 | +We use `ruff` for linting and formatting. If the pre-commit hooks are installed, the checks will be run automatically before each commit. |
| 44 | + |
| 45 | +To manually run the checks, use the following command in the root directory of the repository: |
| 46 | + |
| 47 | +```bash |
| 48 | +ruff check . |
| 49 | +``` |
| 50 | + |
| 51 | +## Testing |
| 52 | + |
| 53 | +We use `pytest` for testing. All tests are located in the `tests` directory. |
| 54 | + |
| 55 | +To run the tests, use the following command in the root directory of the repository: |
| 56 | + |
| 57 | +```bash |
| 58 | +pytest tests |
| 59 | +``` |
| 60 | + |
| 61 | +The [GitHub Actions](https://github.com/TUDelftGeodesy/DePSI/blob/main/.github/workflows/build.yml) will run the tests automatically for each push and pull-request |
| 62 | +on the `main` branch. |
| 63 | + |
| 64 | +## Documentation |
| 65 | + |
| 66 | +We use `mkdocs` for documentation. |
| 67 | + |
| 68 | +To check the documentation at local, use the following command in the root directory of the repository: |
| 69 | + |
| 70 | +```bash |
| 71 | +mkdocs serve |
| 72 | +``` |
| 73 | + |
| 74 | +This will build and render the documentation at a local server. Follow the link provided in the terminal to view the documentation in the browser. |
| 75 | + |
| 76 | +## Parallelization |
| 77 | + |
| 78 | +We use `dask` in many functions for delayed computation and parallelization. Since DePSI operates with Xarray, in most cases, we us Xarray's interface with Dask Arrays, such as `xarray.apply_gufunc` or `xarray.map_blocks` to perform parallel computation. Please refer to the [Xarray Tutorial of Parallelizing Custom Functions](https://tutorial.xarray.dev/advanced/parallel-intro.html) as the best practices for implementing parallelization in DePSI. |
0 commit comments