Skip to content

Commit 10120b7

Browse files
authored
move developer notes into a new CONTRIBUTING.md file (#360)
1 parent 6583157 commit 10120b7

File tree

2 files changed

+72
-67
lines changed

2 files changed

+72
-67
lines changed

CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
![logo](https://raw.githubusercontent.com/wiki/open-atmos/PyPartMC/logo.svg)
2+
3+
# notes for PyPartMC developers
4+
5+
## Implementation outline
6+
7+
- PyPartMC is written in C++, Fortran and uses [pybind11](https://pybind11.readthedocs.io/en/stable/) and [CMake](https://cmake.org/).
8+
- JSON support is handled with [nlohmann::json](https://github.com/nlohmann/json) and [pybind11_json](https://github.com/pybind/pybind11_json)
9+
- PartMC and selected parts of SUNDIALS are statically linked (and compiled in during `pip install` or `python -m build`)
10+
- C (SUNDIALS, netCDF), C++ (pybind11, ...) and Fortran (PartMC, CAMP, netCDF-fortran) dependencies are linked through [git submodules](https://github.com/open-atmos/PyPartMC/blob/main/.gitmodules)
11+
- MOSAIC dependency is optionally linked through setting the environmental variable `MOSAIC_HOME`
12+
- a [drop-in replacement of the PartMC spec file routines](https://github.com/open-atmos/PyPartMC/blob/main/src/spec_file_pypartmc.F90) is used for i/o from/to JSON
13+
14+
## Implementation architecture
15+
16+
```mermaid
17+
flowchart TD
18+
subgraph J ["Julia"]
19+
julia_user_code["Julia user code"] --> PyCall.jl
20+
end
21+
subgraph M ["Matlab"]
22+
matlab_user_code["Matlab user code"] --> matlab_python["Matlab built-in\nPython interface"]
23+
end
24+
subgraph P ["Python"]
25+
python_user_code -.-> NumPy
26+
python_user_code["Python user code"] ---> PyPartMC["pubind11-generated\nPyPartMC module"]
27+
matlab_python --> PyPartMC
28+
PyCall.jl --> PyPartMC
29+
end
30+
subgraph Cpp ["C++"]
31+
cpp_user_code["C++ user code"] ----> ppmc_cpp
32+
PyPartMC --> ppmc_cpp["PyPartMC-C++"]
33+
ppmc_cpp --> pybind11_json
34+
pybind11_json ---> nlohmann::JSON
35+
spec_file_pypartmc_cpp --> nlohmann::JSON
36+
end
37+
subgraph C ["C"]
38+
spec_file_pypartmc_c --> spec_file_pypartmc_cpp["SpecFile-C++"]
39+
ppmc_cpp --> ppmc_c["PyPartMC-C"]
40+
netCDF-C
41+
SUNDIALS
42+
camp_c["CAMP C code"]
43+
end
44+
subgraph Fortran ["Fortran"]
45+
PartMC -....-> MOSAIC
46+
ppmc_c --> ppmc_f["PyPartMC-F"]
47+
ppmc_f ---> PartMC
48+
PartMC --> netCDF-F
49+
netCDF-F --> netCDF-C
50+
PartMC --> SUNDIALS
51+
PartMC ---> camp_f
52+
camp_f["CAMP"] --> camp_c
53+
PartMC ----> spec_file_pypartmc_f[SpecFile-F]
54+
spec_file_pypartmc_f --> spec_file_pypartmc_c["SpecFile-C"]
55+
end
56+
57+
style PartMC fill:#7ae7ff,stroke-width:2px,color:#2B2B2B
58+
```
59+
60+
## How to debug
61+
```sh
62+
git clone --recursive git+https://github.com/open-atmos/PyPartMC.git
63+
cd PyPartMC
64+
DEBUG=1 VERBOSE=1 pip --verbose install -e .
65+
gdb python
66+
(gdb) run -m pytest -s -vv -We -p no:unraisableexception tests
67+
```
68+
69+
## Pre-commit hooks
70+
PyPartMC codebase benefits from Pylint, Black and isort code analysis (which are all part of the CI workflows where we also use pre-commit hooks. The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing. To set up the hooks locally, install pre-commit via `pip install pre-commit` and set up the git hooks via `pre-commit install` (this needs to be done every time you clone the project). To run all pre-commit hooks, run `pre-commit run --all-files`. The `.pre-commit-config.yaml` file can be modified in case new hooks are to be added or existing ones need to be altered.
71+

README.md

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The Python API can facilitate using PartMC from other environments - see, e.g.,
99

1010
For an outline of the project, rationale, architecture, and features, refer to: [D'Aquino et al., 2024 (SoftwareX)](https://doi.org/10.1016/j.softx.2023.101613) (please cite if PyPartMC is used in your research).
1111
For a list of talks and other relevant resources, please see [project Wiki](https://github.com/open-atmos/PyPartMC/wiki/).
12+
If interested in contributing to PyPartMC, please have a look a the [notes for developers](https://github.com/open-atmos/PyPartMC/tree/main/CONTRIBUTING.md).
1213

1314
[![US Funding](https://img.shields.io/static/v1?label=US%20DOE%20Funding%20by&color=267c32&message=ASR&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAMAAAA25D/gAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAASFBMVEVOTXyyIjRDQnNZWINZWITtzdFUU4BVVIFVVYHWiZM9PG/KZnNXVoJaWYT67/FKSXhgX4hgX4lcW4VbWoX03uHQeIN2VXj///9pZChlAAAAAWJLR0QXC9aYjwAAAAd0SU1FB+EICRMGJV+KCCQAAABdSURBVBjThdBJDoAgEETRkkkZBBX0/kd11QTTpH1/STqpAAwWBkobSlkGbt0o5xmEfqxDZJB2Q6XMoBwnVSbTylWp0hi42rmbwTOYPDfR5Kc+07IIUQQvghX9THsBHcES8/SiF0kAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDgtMDlUMTk6MDY6MzcrMDA6MDCX1tBgAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA4LTA5VDE5OjA2OjM3KzAwOjAw5oto3AAAAABJRU5ErkJggg==)](https://asr.science.energy.gov/) [![PL Funding](https://img.shields.io/static/v1?label=PL%20Funding%20by&color=d21132&message=NCN&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQ4jWP8////fwYqAiZqGjZqIHUAy4dJS6lqIOMdEZvRZDPcDQQAb3cIaY1Sbi4AAAAASUVORK5CYII=)](https://www.ncn.gov.pl/?language=en)
1415

@@ -226,61 +227,6 @@ fprintf('%g # kg/m3\n', dot([masses{:}], [num_concs{:}]))
226227

227228
PyPartMC is used within the [test workflow of the PySDM project](https://github.com/atmos-cloud-sim-uj/PySDM/tree/main/tests/smoke_tests/box/partmc).
228229

229-
## Implementation outline
230-
231-
- PyPartMC is written in C++, Fortran and uses [pybind11](https://pybind11.readthedocs.io/en/stable/) and [CMake](https://cmake.org/).
232-
- JSON support is handled with [nlohmann::json](https://github.com/nlohmann/json) and [pybind11_json](https://github.com/pybind/pybind11_json)
233-
- PartMC and selected parts of SUNDIALS are statically linked (and compiled in during `pip install` or `python -m build`)
234-
- C (SUNDIALS, netCDF), C++ (pybind11, ...) and Fortran (PartMC, CAMP, netCDF-fortran) dependencies are linked through [git submodules](https://github.com/open-atmos/PyPartMC/blob/main/.gitmodules)
235-
- MOSAIC dependency is optionally linked through setting the environmental variable `MOSAIC_HOME`
236-
- a [drop-in replacement of the PartMC spec file routines](https://github.com/open-atmos/PyPartMC/blob/main/src/spec_file_pypartmc.F90) is used for i/o from/to JSON
237-
238-
## Implementation architecture
239-
240-
```mermaid
241-
flowchart TD
242-
subgraph J ["Julia"]
243-
julia_user_code["Julia user code"] --> PyCall.jl
244-
end
245-
subgraph M ["Matlab"]
246-
matlab_user_code["Matlab user code"] --> matlab_python["Matlab built-in\nPython interface"]
247-
end
248-
subgraph P ["Python"]
249-
python_user_code -.-> NumPy
250-
python_user_code["Python user code"] ---> PyPartMC["pubind11-generated\nPyPartMC module"]
251-
matlab_python --> PyPartMC
252-
PyCall.jl --> PyPartMC
253-
end
254-
subgraph Cpp ["C++"]
255-
cpp_user_code["C++ user code"] ----> ppmc_cpp
256-
PyPartMC --> ppmc_cpp["PyPartMC-C++"]
257-
ppmc_cpp --> pybind11_json
258-
pybind11_json ---> nlohmann::JSON
259-
spec_file_pypartmc_cpp --> nlohmann::JSON
260-
end
261-
subgraph C ["C"]
262-
spec_file_pypartmc_c --> spec_file_pypartmc_cpp["SpecFile-C++"]
263-
ppmc_cpp --> ppmc_c["PyPartMC-C"]
264-
netCDF-C
265-
SUNDIALS
266-
camp_c["CAMP C code"]
267-
end
268-
subgraph Fortran ["Fortran"]
269-
PartMC -....-> MOSAIC
270-
ppmc_c --> ppmc_f["PyPartMC-F"]
271-
ppmc_f ---> PartMC
272-
PartMC --> netCDF-F
273-
netCDF-F --> netCDF-C
274-
PartMC --> SUNDIALS
275-
PartMC ---> camp_f
276-
camp_f["CAMP"] --> camp_c
277-
PartMC ----> spec_file_pypartmc_f[SpecFile-F]
278-
spec_file_pypartmc_f --> spec_file_pypartmc_c["SpecFile-C"]
279-
end
280-
281-
style PartMC fill:#7ae7ff,stroke-width:2px,color:#2B2B2B
282-
```
283-
284230
## FAQ
285231
- Q: How to install PyPartMC with MOSAIC enabled?
286232
A: Installation can be done using `pip`, however, `pip` needs to be instructed not to use binary packages available at pypi.org but rather to compile from source (pip will download the source from pip.org), and the path to compiled MOSAIC library needs to be provided at compile-time; the following command should convey it:
@@ -322,18 +268,6 @@ Could not find NC_M4 using the following names: m4, m4.exe
322268
```
323269
Try installing `m4` (e.g., using [MSYS2](https://packages.msys2.org/package/m4?repo=msys&variant=x86_64) on Windows).
324270
325-
## Notes for developers
326-
#### How to debug
327-
```sh
328-
git clone --recursive git+https://github.com/open-atmos/PyPartMC.git
329-
cd PyPartMC
330-
DEBUG=1 VERBOSE=1 pip --verbose install -e .
331-
gdb python
332-
(gdb) run -m pytest -s -vv -We -p no:unraisableexception tests
333-
```
334-
#### Pre-commit hooks
335-
PyPartMC codebase benefits from Pylint, Black and isort code analysis (which are all part of the CI workflows where we also use pre-commit hooks. The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing. To set up the hooks locally, install pre-commit via `pip install pre-commit` and set up the git hooks via `pre-commit install` (this needs to be done every time you clone the project). To run all pre-commit hooks, run `pre-commit run --all-files`. The `.pre-commit-config.yaml` file can be modified in case new hooks are to be added or existing ones need to be altered.
336-
337271
## Credits
338272
339273
#### PyPartMC:

0 commit comments

Comments
 (0)