Coding Conventions
TODO: update
DO NOT FORGET TESTS
Most style are enforced with the pre-commit hooks which automatically reformat the code and sort the imports. Code should follow PEP-8, particularly for naming conventions as these aren't modified by the pre-commit hooks.
Module Specifications
Depending on which module you are using, there could be rules to follow that are listed below.
Module | Do | Do not |
---|---|---|
`pytest` | ||
`datetime` | ||
`SQL Alchemy` |
Structure
The following structures principles may also be followed:
__init__.py
should not contain code, but__all__
- At a package level (router for example) we have one file per system (configuration.py for example)
- If we need more files (think of jobs, which have the sandbox, the joblogging, etc), we put them in a sub module (e.g routers.job). The code goes in a specific file (job.py, joblogging.py) but we use the the init.py to expose the specific file
See this issue.
Architecture
To make sure that each part of DiracX is doing only what it is supposed to do, you also need to follow these instructions:
diracx-routers
should deal with user interactions through HTTPs. It is expected to deal with permissions and should calldiracx-logic
. Results returned should be translated into HTTP responses.diracx-logic
should embed Dirac specificities. It should encapsulate the logic of the services and should calldiracx-db
to interact with databases.diracx-db
should contain atomic methods (complex logic is expected to be located indiracx-db
).