The PeekingDuck team enforces a code of conduct to foster an open and welcoming environment for the community.
We welcome all types of contributions to grow and make PeekingDuck better.
Before you report a new bug, do check our issues tracker to ensure that the problem hasn't already been reported. If it has, just leave a comment on the existing issue, instead of creating a new issue. If it has not been reported, file a new issue and tag it as a bug. In the issue, please provide a short description of the bug and the steps required to replicate it.
Useful Information
- Operating System (MacOS/Windows/Linux)
- Python environment (venv/pyenv/conda) and dependencies
- Step by step information to recreate the bug
If you've created new custom nodes that you'd like to showcase to the community, feel free to do so in our community discussion channels. If we find these nodes useful and aligned with PeekingDuck's direction, we'll work with you to incorporate them into the core PeekingDuck package!
If you have suggestions for new non-node PeekingDuck features, please open an issue, describe the feature and why it could be useful to PeekingDuck users.
Here is a guide of the general steps to contribute code to PeekingDuck.
-
Own an issue from the issues board. This is to prevent duplicate work.
- Pick an issue from our issues tracker and indicate your interest to work on the issue.
- If there are no one else working on the issue, the maintainer will assign the issue to you.
- After receiving the confirmation from the maintainer, you may begin work on the issue.
-
Contributing code
- Do read our code styles guidelines.
- Fork the aisingapore/PeekingDuck repository. For more details in this process, Jake Jarvis has a useful guide that describes steps 2-6 and 10 in more detail.
- Clone the forked branch to your local machine.
- [Recommended] track the original repository as another remote. After which you will be able to receive updates using
git fetch
. This is useful for long term contributions to the repository. - In your local repository, create a descriptive branch to work on your issue.
- Make the required changes within the branch.
- Add tests (if possible).
- Run the test suite and check that it passes.
- Push the changes to your github remote.
- Send us a pull request to PeekingDuck/dev.
- Make changes requested by your reviewer (if any).
Thank you for your contributions!!
Join us in our GitHub discussion board or AI Singapore's Community forum.
Post your thread regarding
- Questions on the project
- Suggestions/feature requests
- Your custom nodes and projects
Help us maintain the quality of our project by following the conventions we take below.
It is a good practice to have a consistent branch naming approach. We follow the convention below, where words
are separated by dashes (-
).
<type>-<short description of task>
│
└─⫸ Commit Type: build|cicd|docs|feat|fix|node|refactor|test
Examples:
fix-linux-threading, node-crowd-counting, refactor-use-pathlib
<type>
must be one of the following:
- build: Updates to dependencies and package building
- cicd: Changes to CI/CD
- docs: Documentation changes
- feat: Enhancements which are not new nodes
- fix: Bug fixes
- node: New nodes
- refactor: Code changes that neither fixes a bug nor adds a feature
- test: Unit or system tests
A standard git commit message makes it easier to read commit histories. This is a shortened version inspired by angular's contributing docs.
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: build|cicd|docs|feat|fix|node|refactor|test
<type>
must be one of the options described in the above Branch Names section.
We follow the PEP8 style guide, with PEP484 type hinting for functions and methods, and use Black code formatter to ensure consistent code format.
The following are commonly used conventions which we adhere to:
- Imports
- Absolute imports instead of relative imports (e.g. avoid
from ...nodes.node import AbstractNode
)
- Absolute imports instead of relative imports (e.g. avoid
- Paths/files
- Use
pathlib.Path
instead ofos.path
to make code cleaner
- Use
- Strings
- Use f-strings for clear and concise string formatting. This includes logging messages.
- Do not use
+
concatenation on a mix of string variables and literals
- Naming
snake_case
formodule_name
,package_name
,method_name
,function_name
,global_var_name
,instance_var_name
,function_parameter_name
,local_var_name
CapWords
forClassName
,ExceptionName
- Fully capitalised for
GLOBAL_CONSTANT_NAME
_dir
postfix for full paths of directories, e.g. where weights are stored_path
postfix for full paths to files, e.g.~/demo/pipeline_config.yml
_subdir
postfix for part of paths, e.g.src/custom_nodes
_name
postfix for file names, e.g.output.mp4
- Docstrings and comments
- Public classes, functions, methods should have docstrings
- Private/internal functions and methods can have less detailed docstrings, with optional
Args
andReturns
__init__
methods do not require docstrings- Avoid inline comments if the line width limit is exceeded as it causes the code to be wrapped
- Example of a class docstring including Read the Docs info: yolo.py
- Example of a function/method docstring: transforms.py
- Type Hints
- Use
pathlib.Path
type for arguments that are full paths (such as variables with_dir
and_path
postfixes) instead ofstr
- Avoid using
#type: ignore
as much as possible - declare variable type instead - Use
Optional
prefix if the variable can beNone
def func(a: Optional[str], b: Optional[str] = None) -> str: ...
- Use
PeekingDuck uses tools like pylint, pytest, mypy and bandit to maintain project quality. Run these tests locally to ensure that your code passes prior to submission of a Pull Request.
sh scripts/linter.sh # pylint for pep8 and code consistency
sh scripts/bandit.sh # bandit to check for security related issues on dependencies
sh scripts/check_format.sh # black to check for formatting issues
sh scripts/check_type.sh # mypy to check for type hints on function/method level
sh scripts/run_tests.sh unit # pytest for all except model nodes
sh scripts/run_tests.sh mlmodel # pytest for model nodes
sh scripts/usecase_tests.sh # check standard usecase to ensure it is not broken