|
1 | 1 | # Contributing Guide |
2 | 2 |
|
3 | | -This repositary includes python modules for running the STEMMUS-SCOPE model in a |
4 | | -notebook. |
| 3 | +This repository includes the python package `PyStemmusScope` for running the STEMMUS-SCOPE model. |
5 | 4 |
|
6 | | -The workflow is executed using python and MATLAB on a Unix-like system. |
7 | | -The python packages are listed in the |
8 | | -[`environment.yml`](https://github.com/EcoExtreML/processing/blob/main/environment.yml) |
9 | | -file. Follow the instructions below to create conda environment and install |
10 | | -MATLAB Runtime. |
| 5 | +## Configure the python package for development and testing |
| 6 | + |
| 7 | +To contribute to development of the python package, we recommend installing the package in development mode. |
| 8 | + |
| 9 | + |
| 10 | +### Installation |
| 11 | + |
| 12 | +First, clone this repository: |
| 13 | + |
| 14 | +```sh |
| 15 | +git clone https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing.git |
| 16 | +``` |
| 17 | + |
| 18 | +Then install the package: |
| 19 | + |
| 20 | +```sh |
| 21 | +cd STEMMUS_SCOPE_Processing |
| 22 | +pip install -e . |
| 23 | +``` |
| 24 | + |
| 25 | +or |
| 26 | + |
| 27 | +```sh |
| 28 | +python setup.py develop |
| 29 | +``` |
| 30 | + |
| 31 | +### Run tests |
| 32 | + |
| 33 | +The testing framework used here is [PyTest](https://pytest.org). You can run |
| 34 | +tests as: |
| 35 | + |
| 36 | +```sh |
| 37 | +pytest |
| 38 | +``` |
| 39 | + |
| 40 | +### Build documentation |
| 41 | + |
| 42 | +To build the documentation locally: |
| 43 | + |
| 44 | +```sh |
| 45 | +cd docs/ |
| 46 | +make html |
| 47 | +``` |
| 48 | + |
| 49 | +Then open `_build/html/index.html` in a web broser to preview the documentation. |
| 50 | + |
| 51 | +### Run formatting tools |
| 52 | + |
| 53 | +You can use `prospector` to get information about errors, potential problems and convention violations. To run: |
| 54 | + |
| 55 | +```sh |
| 56 | +prospector |
| 57 | +``` |
| 58 | + |
| 59 | +To format the import statements, you can use `isort` as: |
| 60 | + |
| 61 | +```sh |
| 62 | +isort |
| 63 | +``` |
| 64 | + |
| 65 | +## Development of STEMMUS_SCOPE model |
| 66 | + |
| 67 | +<!-- markdown-link-check-disable-next-line --> |
| 68 | +To contribute to the STEMMUS_SCOPE model, you need access to the model source code that is stored in the repository [STEMMUS_SCOPE](https://github.com/EcoExtreML/STEMMUS_SCOPE). You also need a MATLAB license. |
| 69 | + |
| 70 | +### Development on Snellius using MATLAB |
| 71 | + |
| 72 | +[Snellius](https://servicedesk.surfsara.nl/wiki/display/WIKI/Snellius) is the |
| 73 | +Dutch National supercomputer hosted at SURF. MATLAB `2021a` is installed on |
| 74 | +Snellius, see the script |
| 75 | +[`run_jupyter_lab_snellius_dev.sh`](https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing/blob/main/run_jupyter_lab_snellius_dev.sh) |
| 76 | +on how to load the module. |
| 77 | + |
| 78 | +The script `run_jupyter_lab_snellius_dev.sh` activates the conda environment `pystemmusscope` and creates a jupyter lab server on Snellius for running the notebook |
| 79 | +interactively. Make sure that you create the `pystemmusscope` conda environment before submitting the the bash script. See **Create pystemmusscope environment** below. |
11 | 80 |
|
12 | 81 | <details> |
13 | | - <summary>Create conda environment </summary> |
| 82 | + <summary>Create pystemmusscope environment</summary> |
14 | 83 |
|
15 | 84 | Run the commands below in a terminal: |
16 | 85 |
|
17 | 86 | ```sh |
18 | | -# Download and install Conda |
| 87 | +# Download and install Mamba on linux |
19 | 88 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-pypy3-Linux-x86_64.sh |
20 | | -bash Mambaforge-pypy3-Linux-x86_64.sh |
21 | | --b -p ~/mamba |
| 89 | +bash Mambaforge-pypy3-Linux-x86_64.sh -b -p ~/mamba |
22 | 90 |
|
23 | 91 | # Update base environment |
24 | 92 | . ~/mamba/bin/activate |
25 | 93 | mamba update --name base mamba |
26 | 94 |
|
27 | | -# Clone this repository |
28 | | -git clone https://github.com/EcoExtreML/processing.git |
| 95 | +# Download environment file |
| 96 | +wget https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing/blob/main/environment.yml |
29 | 97 |
|
30 | | -# Create a conda environment called 'stemmus' with all required dependencies |
31 | | -cd processing |
32 | | -mamba env create |
| 98 | +# Create a conda environment called 'pystemmusscope' with all required dependencies |
| 99 | +mamba env create -f environment.yml |
33 | 100 |
|
34 | 101 | # The environment can be activated with |
35 | | -. ~/mamba/bin/activate stemmus |
| 102 | +. ~/mamba/bin/activate pystemmusscope |
36 | 103 |
|
37 | 104 | ``` |
38 | 105 | </details> |
39 | 106 |
|
40 | | -<details> |
41 | | - <summary>Use MATLAB </summary> |
42 | 107 |
|
43 | | -To run the STEMMUS_SCOPE, you need MATLAB version `>=2019`. |
| 108 | +### Development on CRIB using MATLAB |
44 | 109 |
|
45 | | -**On Snellius:** |
| 110 | +[CRIB](https://crib.utwente.nl/) is the ITC Geospatial Computing Platform. |
46 | 111 |
|
47 | | -[Snellius](https://servicedesk.surfsara.nl/wiki/display/WIKI/Snellius) is the |
48 | | -Dutch National supercomputer hosted at SURF. MATLAB Runtime is installed on |
49 | | -Snellius, see the script |
50 | | -[`run_jupyter_lab_snellius_dev.sh`](https://github.com/EcoExtreML/processing/blob/main/run_jupyter_lab_snellius_dev.sh) |
51 | | -on how to load the module. |
52 | | -</details> |
| 112 | +MATLAB `2021a` is installed on CRIB, and supports Python `3.8`, see [Versions of Python Compatible with MATLAB Products](https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf). |
53 | 113 |
|
54 | | -## Run jupyter notebook |
| 114 | +1. Log in CRIB with your username and password and select a proper compute unit. |
| 115 | +2. Install `PyStemmusScope` package. This step needs to be done once. |
| 116 | + <details> |
| 117 | + <summary>Install pystemmusscope with python 3.8</summary> |
55 | 118 |
|
56 | | -**On Snellius:** |
| 119 | + Run the commands below in a terminal: |
57 | 120 |
|
58 | | -Use the script |
59 | | -[`run_jupyter_lab_snellius_dev.sh`](https://github.com/EcoExtreML/processing/blob/main/run_jupyter_lab_snellius_dev.sh) |
60 | | -to create a jupyter lab server on Snellius for running the notebook |
61 | | -interactively. |
| 121 | + ```sh |
| 122 | + # Download and install Mamba on linux |
| 123 | + wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-pypy3-Linux-x86_64.sh |
| 124 | + bash Mambaforge-pypy3-Linux-x86_64.sh -b -p ~/mamba |
62 | 125 |
|
63 | | -**On CRIB:** |
| 126 | + # Update base environment |
| 127 | + . ~/mamba/bin/activate |
| 128 | + mamba update --name base mamba |
64 | 129 |
|
65 | | -[CRIB](https://crib.utwente.nl/) is the ITC Geospatial Computing Platform. |
| 130 | + # Download environment file |
| 131 | + wget https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing/blob/main/environment_3.8.yml |
| 132 | + |
| 133 | + # Create a conda environment called 'pystemmusscope' with all required dependencies |
| 134 | + mamba env create -f environment_3.8.yml |
| 135 | + ``` |
| 136 | + </details> |
66 | 137 |
|
67 | | -1. Log in CRIB with your username and password and select a proper compute unit. |
68 | | -2. Check `config_file_crib.txt` and change the paths if needed, specifically |
69 | | - "InputPath" and "OutputPath". |
70 | 138 | 3. click on the `Remote Desktop` in the |
71 | 139 | Launcher. Click on the `Applications`. You will find the 'MATLAB' software under |
72 | 140 | the `Research`. |
73 | 141 | 4. After clicking on 'MATLAB', it asks for your account information that is |
74 | 142 | connected to a MATLAB license. |
75 | | -5. Open the file `run_model_in_matlab_dev.m` and set the paths inside the script. |
76 | | -6. Then, run the main script `run_model_in_matlab_dev.m`. |
77 | | - |
78 | | -## Recipe of model execution |
79 | | - |
80 | | -The execution of the model includes following steps: |
81 | | - |
82 | | -- Update/set config files |
83 | | -- Create input directories, prepare input files |
84 | | -- Run the model |
85 | | -- Create output directories, prepare output files |
86 | | -- Create exe file |
| 143 | +5. Open the file `STEMMUS_SCOPE_run.m` and set the path of `config_file` to `../config_file_crib.txt` and change `WorkDir` and other configurations in `model.setup()`. |
| 144 | +6. Then, run the main script `STEMMUS_SCOPE_run.m`. |
0 commit comments