@@ -18,61 +18,35 @@ instructions in this file.
1818HADDOCK3 has two main testing workflows. Here, within the repository, we
1919test the HADDOCK3's Python shell, code style, and package building. Our
2020Continuous Integration (CI) pipeline is based on
21- [ tox] [ tox ] and GitHub Actions. We will
22- explain you how to use them.
21+ pytest and GitHub Actions. We will explain you how to use them.
2322
2423To contribute to the HADDOCK3's Python shell, follow these steps:
2524
26251 . [ Fork] [ fork ] the HADDOCK3 repository
27262 . Create a new branch in your fork (` git checkout -b <new_branch_name> ` )
28- 3 . Develop your code and tests :
27+ 3 . Develop your code:
2928
3029 1 . HADDOCK3 source is in ` src/haddock ` . Always implement code in
3130 the lowest Python version supported (this case is 3.9).
32- 2 . Tests sit in the ` tests/ ` folder. Use
33- [ pytest] ( https://docs.pytest.org/en/6.2.x/ ) for testing.
34- 3 . See more details on how to contribute with code and tests in the
31+ 2 . See more details on how to contribute with code and tests in the
3532 subheadings below.
3633
37- 4 . While you are developing (or when you think you have finished), you can
38- (should) use our ` tox ` environments to test your code. Use the
39- following commands from the main repository folder:
34+ 4 . Test your code:
35+ 1 . Unit tests sit in the ` tests/ ` folder. Use
36+ [ pytest] ( https://docs.pytest.org/en/6.2.x/ ) for testing by running ` pytest tests/ ` .
37+ 2 . Integration tests are located in the ` integration_tests/ ` folder.
38+ You can run them with ` pytest integration_tests/ ` .
4039
41- 1 . ` tox -e test ` runs tests in current python version. If you tox
42- to report test names and status for every single test (high verbosity) use
43- ` tox -e test -- -vv ` .
44- 2 . ` tox -e lint ` shows you errors in the code style.
45- 3 . ` tox -e build ` simulates building the HADDOCK3 package.
46- 4 . Run the above altogether with the simple ` tox ` command
47- 5 . If you want to submit high-quality code, you may wish to run
48- ` tox -e radon ` to assess your code cyclomatic complexity.
49-
50- 5 . You can work on these ` tox ` tests until they all pass green before
40+ 5 . You can work on these tests until they all pass green before
5141submitting your PR.
5242
53436 . Check if your contribution fulfills the requeriments proposed in the
5444PR template, these are based on the experience of some developers to ensure the long-term
5545survival of the codebase. Suggestions are always welcomed.
5646
57- 7 . We also have an ` examples ` folder with test cases that you can run
58- (should) to ensure the integrity of the python shell as a whole:
59- 1. Navigate to any of the examples folder and run the ` -test.cfg `
60- file (see [ USAGE] ( USAGE.md ) ).
61- 2. ` *-test.cfg ` runs are meant for testing purposes only. The
62- ` examples/ ` folder also contain ` *-full.cfg ` files for production runs.
63- You don't need to run these for testin.
64- 2. If you have a powerful computer and want to run all tests in a
65- row, navigate to the ` examples ` folder and run `python run_tests.py
66- -b` . The ` -b` flag ensures the run will stop asap an error is found.
67- 3. if your computer is not powerful enough, you can ask us to run
68- those tests once you submitted the pull request.
69- 4. For example, the ` docking-protein-protein-test.cfg ` run in less
70- than 3 minutes on a ` Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz ` laptop
71- using 7 cores. All ` -test.cfg ` together take about 45 minutes.
72-
73- 8 . Add a list of your new additions to the ` CHANGELOG.md ` file by
74- adding a new sub-header as described bellow. This is mandatory for `tox
75- -e build` to pass. Note this applies only after we have released the
47+ 7 . Add a list of your new additions to the ` CHANGELOG.md ` file by
48+ adding a new sub-header as described bellow.
49+ Note this applies only after we have released the
7650stable ` 3.0.0 ` version.
7751
7852``` markdown
@@ -86,7 +60,7 @@ stable `3.0.0` version.
8660(... the rest of the file ...)
8761```
8862
89- 8 . If you have difficulties with ` tox ` , let us know. These ` tox ` tests
63+ 8 . If you have difficulties with the ` tests ` , let us know. These tests
9064are the same that run on the GitHub Actions once you send the PR. So,
9165sending the PR is another way to ensure all tests pass.
9266
@@ -106,7 +80,7 @@ contribute to that folder and respective files. Summarizing here:
10680
10781* New command-line clients go in the ` clis/ ` folder. See how the current
10882 clients here created and use that as a template. Remember to update also the
109- ` setup.py ` file.
83+ ` pyproject.toml ` file.
11084* Add any new functions that you foresee are general and
11185 could serve different places in the code to the ` libs/ ` folder. Find a
11286 ` lib*.py ` files that would serve your purpuses, otherwise create a new
@@ -130,8 +104,8 @@ you create new `*.py` files you should create a new test file of the
130104same name, ` test_new_file_name.py ` . Aim at 100% test coverage for the
131105code you have created. Write tests according to [ pytest] [ pytest ] . You
132106can see examples in our ` test_*.py ` files. You can run the tests using
133- the ` tox -e test ` commands explained above. Or, if you want to run the
134- tests for a singly file use ` tox -e test -- tests/test_myfile.py` .
107+ the ` pytest tests/ ` command explained above. Or, if you want to run the
108+ tests for a singly file use ` pytest tests/test_myfile.py` .
135109
136110### 1.3 Dependencies
137111
@@ -152,118 +126,16 @@ us by opening an issue.
152126another project. If licenses are compatible, copy their code to the
153127HADDOCK3 repository writing all necessary headers to grant authorship
154128and comply with license requirements.
155- 1. If licenses aren't compatible, talk is us. We may have an
129+ 1. If licenses aren't compatible, talk to us. We may have an
156130 alternative.
1571311 . Your new module largely depends on a library and reimplementing or
158132copying is not an option. Then, consider if we can use that dependency
159- as a ** runtime dependency** (like ` gdock ` or ` lightdock ` ) instead of an
133+ as a ** runtime (thirdparty) dependency** (like ` gdock ` or ` lightdock ` ) instead of an
160134installation dependency.
1611351 . Nothing of the above is possible. You ** really** need an * install
162136dependency* . Talk with us before.
163137
164- ### 1.4 Code style
165-
166- HADDOCK3 follows nice code style rules. These are * almost* hard rules,
167- but there is some room for exceptions - common sense prevails. When
168- developing code, run ` tox -e lint ` to inspect if your code follows our
169- conventions. We use [ flake8] [ flake ] with the [ following rules] [ fr ] and
170- docstrings follow [ numpydoc] [ numpydoc ] style. You can hold on our code
171- for style. Nevertheless, here's a dummy code snippet for your reference.
172- Line have a soft max of 80 chars.
173-
174- ``` python
175- """ Module's docstring."""
176- # any comments. You can add here licensing stuff
177- # first import standard library
178- import os
179- from path import Pathlib
180-
181- # import third library
182- import numpy as np
183-
184- # import from haddock3
185- from haddock import log
186- # multiline import
187- from haddock.libs.libio import (
188- lib1,
189- lib2,
190- lib3,
191- lib4,
192- )
193-
194-
195- # all this are possible
196- GLOBAL_VARIBLE = None
197- _hidden_global_variable = None
198-
199- avoid_lower_case_globals = None
200-
201-
202- def my_nice_func (arg1 , arg2 , arg3 ):
203- """ Docstring here."""
204- # do stuf
205-
206- # if the function has many arguments, separate them by new lines.
207- # mind the identations
208- def my_nice_func_with_big_name (
209- var1 ,
210- var2 ,
211- var3 ,
212- named_var1 = " something" ,
213- named_var2 = " else" ,
214- ** kwargs ,
215- ):
216- """ Docstring here."""
217- # do stuff
218- return
219-
220-
221- multiline_list = [
222- var1,
223- var2,
224- var3,
225- var4,
226- ]
227-
228- multiline_dict = {
229- " key1" : 1 ,
230- " key2" : 2 ,
231- " key3" : 3 ,
232- " key4" : 4 ,
233- " key5" : 5 ,
234- }
235-
236- # separate comprehensions by sections if line don't fit 80 chars
237- # same for dictionaries
238- cool_list_comprehension = [
239- dome_some_long_stuff(i)
240- for i in some_iterable
241- if validate(i)
242- ]
243-
244- double_quotes_allowed = " string"
245- single_quotes_allowed = ' string'
246- # don't try to homogenize quotes all around the code, respect the
247- # original input.
248-
249- # define first use later
250- generator_with_a_large_name = zip (
251- iter1,
252- iter2,
253- iter3,
254- iter4,
255- iter5,
256- )
257-
258- for a, b, c, d, e in generator_with_a_large_name:
259- # do stuff
260-
261- # use noqa: E501 for slightly long lines, in case splitting into
262- # multiple lines reduces readability
263- this_is_a_long_line = that_makes_no_much_sense(to_separate, in_multiple_lines, abcd) # noqa: E501
264- ```
265-
266- ### 1.5 Code structure
138+ ### 1.4 Code structure
267139
268140Write code in the form of small functions, because small functions are
269141easier to test. Combine small functions to compose larger functions. If
@@ -276,7 +148,7 @@ needed. Write comments that explain why you do stuff, and not how you do
276148stuff. Use the ` TODO: ` flag in your comments to note something for the
277149future. If needed, raise an issue.
278150
279- ### 1.6 Creating a new module
151+ ### 1.5 Creating a new module
280152
281153To develop a new HADDOCK3 module follow our guidelines and templates
282154under ` src/haddock/modules/_template_cat/_template_mod/ ` .
@@ -302,9 +174,17 @@ the documentation website.
302174
303175You can render the documentation locally to inspect the end result
304176before creating a pull request. To compile the documentation locally:
305- activate the ` haddock3 ` python environment inside the haddock3 github
306- folder, run ` tox -e docs ` and then use your favourite browser to open the
307- ` haddock3-docs/index.html ` file. We invite you to read through Sphinx-doc
177+ - install HADDOCK in development mode with the ` docs ` extra requirements
178+ (` pip install -e '.[docs]' ` )
179+ - activate the ` haddock3 ` python environment inside the haddock3 github
180+ folder
181+ - run the following commands:
182+ ``` bash
183+ sphinx-apidoc -f -e -o docs/ src/haddock -d 1
184+ sphinx-build -b html docs haddock3-docs
185+ ```
186+
187+ We invite you to read through Sphinx-doc
308188webpage if you want to exploit any advanced feature of Sphinx, but we
309189already provide examples for virtually any use you may need.
310190
@@ -321,11 +201,8 @@ an example. See also the `docs/conf.py` file `setup(app)` line.
321201 need to add that library name to the ` mock ` list in the ` docs/conf.py `
322202 file.
323203
324-
325- [ tox ] : https://tox.wiki/en/latest/index.html " tox "
326204[ fork ] : https://docs.github.com/en/get-started/quickstart/fork-a-repo
327205[ pytest ] : https://docs.pytest.org/ " pytest "
328206[ flake ] : https://flake8.pycqa.org/en/latest/ " flake8 "
329- [ fr ] : https://github.com/haddocking/haddock3/blob/b44304f0a1509d44d9689d7e2e4124f0ae3af0a1/tox.ini#L116-L130
330207[ numpydoc ] : https://numpydoc.readthedocs.io/en/latest/format.html
331208[ numba ] : https://numba.pydata.org/ " Numba "
0 commit comments