Skip to content

Commit d068ab1

Browse files
authored
Start guides for best-practices. (#49)
1 parent 0d54622 commit d068ab1

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed

docs/changes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
1212
- :gh:`45` adds the option to stop execution after a number of tasks has failed. Closes
1313
:gh:`44`.
1414
- :gh:`47` reduce node names in error messages while resolving dependencies.
15+
- :gh:`49` starts a style guide for pytask.
1516
- :gh:`50` implements correct usage of singular and plural in collection logs.
1617
- :gh:`51` allows to invoke pytask through the Python interpreter with ``python -m
1718
pytask`` which will add the current path to ``sys.path``.
@@ -28,7 +29,6 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
2829
- :gh:`42` ensures that lists with one element and dictionaries with only a zero key as
2930
input for ``@pytask.mark.depends_on`` and ``@pytask.mark.produces`` are preserved as a
3031
dictionary inside the function.
31-
- :gh:`43` releases v0.0.10.
3232

3333

3434
0.0.9 - 2020-10-28
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Organization
2+
============
3+
4+
How to contribute
5+
-----------------
6+
7+
Any contribution is highly appreciated. Feel free to continue a discussion in `an
8+
existing issue <https://github.com/pytask-dev/pytask/issues>`_ ticket or `file a new
9+
ticket <https://github.com/pytask-dev/pytask/issues/new/choose>`_ if, for example, some
10+
of the following applies to you:
11+
12+
- You have a question regarding an existing guide or feel a guide needs clarification.
13+
14+
- You want to share your own experience with the suggestions provided in a guide.
15+
16+
- You want to extend the collection by providing another best-practices guide.
17+
18+
19+
Structure of guides
20+
-------------------
21+
22+
1. Each guide should start with a description of the scope of the guide. At best, guides
23+
deal with one thing only. If guides deal with higher-level topics, they should link
24+
to lower-level guides instead of trying to explain too much.
25+
26+
2. The second section is a TL;DR (too long; did not read) which provides a short summary
27+
of the guide and its (five) most important messages.
28+
29+
3. The third section provides the advice in detail. This section must be well
30+
structured, concise, and easy to understand. Each tip is associated with an example.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Structure of task files
2+
=======================
3+
4+
This section provides best-practices on how to structure task files.
5+
6+
7+
TL;DR
8+
-----
9+
10+
- A task function should be the first function in a task module and serve as an
11+
entry-point to the whole module.
12+
13+
- There might be multiple task functions in a task module, but it is recommended to
14+
split modules once they become too large.
15+
16+
- The task function is mainly responsible for handling IO operations like loading and
17+
saving files and calling Python functions on the task's inputs. IO should not be
18+
handled in other functions since it introduces side-effects.
19+
20+
- All other functions in the module are private functions used to accomplish only this
21+
specific task. The functions should be pure, meaning without side-effects.
22+
23+
- Functions used to accomplish tasks in multiple task modules should have their own
24+
module.
25+
26+
27+
.. seealso::
28+
29+
The advice above may remind readers of "deep modules", a term coined by John
30+
Ousterhout and described in "A Philosophy of Software Design".

docs/how_to_guides/index.rst

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
How-to Guides
22
=============
33

4-
How-to guides provide detailed explanations on how to accomplish specific tasks with
5-
pytask.
4+
This section contains two collections of documents.
65

76

7+
How-to Guides
8+
-------------
9+
10+
The first collection of how-to guides provide detailed explanations on how to accomplish
11+
specific tasks with pytask.
12+
813
.. toctree::
914
:maxdepth: 1
1015

1116
how_to_write_a_plugin
1217
how_to_extend_parametrizations
1318
how_to_influence_build_order
19+
20+
21+
Best-Practices
22+
--------------
23+
24+
The second collection comprises best-practices guides for pytask. The guides combine
25+
experience with pytask and build systems in general, research projects, and software
26+
engineering to provide useful and easily understandable instructions.
27+
28+
Contributions in any form - additions, comments, own experiences, request for
29+
clarifications - are highly appreciated. Please continue a discussion in `an existing
30+
issue <https://github.com/pytask-dev/pytask/issues>`_ ticket or `file a new ticket
31+
<https://github.com/pytask-dev/pytask/issues/new/choose>`_.
32+
33+
For more information on how best-practices guides are organized and how to contribute,
34+
see the section on :doc:`bp_organization`.
35+
36+
.. toctree::
37+
:maxdepth: 1
38+
39+
bp_organization
40+
bp_structure_of_task_files

0 commit comments

Comments
 (0)