We welcome your input! 👐
We want to make it as simple and straightforward as possible to contribute to this project, whether it is a:
- Bug Report
- Discussion
- Feature Request
- Creating a Pull Request (PR)
- Becoming a maintainer
We use GitHub issues to track the bugs. Report a bug by using our Bug Report Template in Issues.
We enabled GitHub Discussions in anomalib to welcome the community to ask questions and/or propose ideas/solutions. This will not only provide a medium to the community to discuss about anomalib but also help us de-clutter Issues.
We utilize GitHub issues to track the feature requests as well. If you are certain regarding the feature you are interested and have a solid proposal, you could then create the feature request by using our Feature Request Template in Issues. If it's still in an idea phase, you could then discuss that with the community in our Discussion.
We actively welcome your pull requests:
First, fork the Anomalib repository by following the GitHub documentation on forking a repo. Then, clone your forked repository to your local machine and create a new branch from main.
Set up your development environment to start contributing. This involves installing the required dependencies and setting up pre-commit hooks for code quality checks. Note that this guide assumes you are using Conda for package management. However, the steps are similar for other package managers.
Development Environment Setup Instructions
-
Create and activate a new Conda environment:
conda create -n anomalib_dev python=3.10 conda activate anomalib_dev
-
Install the development requirements:
# Option I: Via anomalib install anomalib install --option dev #Option II: Via pip install pip install -e .[dev]
Optionally, for a full installation with all dependencies:
# Option I: via anomalib install anomalib install --option full # Option II: via pip install pip install -e .[full]
-
Install and configure pre-commit hooks:
prek install
Pre-commit hooks help ensure code quality and consistency. After each commit,
prek will automatically run the configured checks for the changed file.
If you would like to manually run the checks for all files, use:
prek run --all-filesTo bypass pre-commit hooks temporarily (e.g., for a work-in-progress commit), use:
git commit -m 'WIP commit' --no-verifyHowever, make sure to address any pre-commit issues before finalizing your pull request.
-
Write Code: Follow the project's coding standards and write your code with clear intent. Ensure your code is well-documented and includes examples where appropriate. For code quality we use ruff, whose configuration is in
pyproject.tomlfile. -
Add Tests: If your code includes new functionality, add corresponding tests using pytest to maintain coverage and reliability.
-
Update Documentation: If you've changed APIs or added new features, update the documentation accordingly. Ensure your docstrings are clear and follow Google's docstring guide.
-
Pass Tests and Quality Checks: Ensure the test suite passes and that your code meets quality standards by running:
prek run --all-files pytest tests/
-
Update the Changelog: For significant changes, add a summary to the CHANGELOG.
-
Check Licensing: Ensure you own the code or have rights to use it, adhering to appropriate licensing.
-
Follow Conventional Commits for PR Titles: We use Commitizen to enforce conventional commit format for PR titles and branch names. Since we squash merge PRs, individual commit messages can be in any format during development, but your PR title must follow conventional commit format.
PR Title Format (Required)
Your PR title must follow conventional commit format. Individual commit messages during development can be any format (e.g., "wip", "fix typo"), but the PR title becomes the squash commit message.
Each PR title consists of a header, and optionally a body and footer:
<type>(<scope>): <description> [optional body] [optional footer]Types:
feat: A new featurefix: A bug fixdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringperf: Performance improvementstest: Adding or modifying testsbuild: Build system changesci: CI configuration changeschore: General maintenance
Scopes:
data: Data loading, processing, or augmentationmodel: Model architecture or implementationmetric: Evaluation metricsutils: Utility functionscli: Command-line interfacedocs: Documentationci: CI/CD configurationengine: Training/inference enginevisualization: Visualization toolsbenchmarking: Benchmarking toolslogger: Logging functionalityopenvino: OpenVINO integrationnotebooks: Jupyter notebooks
Rules:
- The type and scope are case-sensitive
- The type must be lowercase
- The description should be in present tense
- The description should not end with a period
- The description should not be in sentence-case, start-case, pascal-case, or upper-case
PR Title Examples:
feat(model): add transformer architecture for anomaly detectionfix(data): handle corrupted image files during trainingdocs: update installation instructions for Windowschore(ci): migrate from commit message validation to PR title validationNote: The PR description can contain additional details, but the title must be concise and follow the format above.
Optional Emojis: You can optionally add emojis at the beginning of your PR title for better visual distinction:
🚀 feat(model): add transformer architecture for anomaly detection 🐞 fix(data): handle corrupted image files during training 📚 docs: update installation instructions for Windows 🔧 chore(ci): migrate from commit message validation to PR title validationSuggested Emoji Mapping (Optional):
- 🚀 for
feat(new features) - 🐞 for
fix(bug fixes) - 📚 for
docs(documentation) - 🎨 for
style(code style/formatting) - 🔄 for
refactor(code refactoring) - ⚡ for
perf(performance improvements) - 🧪 for
test(adding/modifying tests) - 📦 for
build(build system changes) - 🔧 for
chore(general maintenance) - 🚧 for
ci(CI/CD configuration)
Note: Emojis are completely optional. PR titles without emojis are equally valid.
Branch Naming
Branch names must follow the format:
<type>/<scope>/<description>Examples:
feat/model/add-transformerfix/data/load-image-bugdocs/readme/update-installationrefactor/utils/optimize-performance
The type and scope should match the ones used in commit messages.
Development Workflow
During Development: Individual commits can use any format for convenience:
git add <files> git commit -m "wip: working on transformer model" git commit -m "fix typo" git commit -m "address review comments"
Creating the PR: Ensure your PR title follows conventional commit format. The PR title becomes the final commit message when merged.
Optional - Using Commitizen for PR titles: You can use Commitizen to help format your PR titles:
# Check if a message follows conventional format echo "feat(model): add transformer architecture" | cz check --commit-msg-file -
To check if your commits follow the conventional format:
cz check
To bump the version based on commit history:
cz bump
Suppressing False Positives
If necessary, to suppress false positives, add inline comment with specific syntax. Please also add a comment explaining why you decided to disable a rule or provide a risk-acceptance reason.
Findings can be ignored inline with # nosec BXXX comments.
import subprocess # nosec B404 # this is actually fineDetails in Bandit docs.
Findings can be ignored inline with # zizmor: ignore[rulename] comments.
uses: actions/checkout@v3 # zizmor: ignore[artipacked] this is actually fineDetails in Zizmor docs.
Findings can be ignored inline with # nosemgrep: rule-id comments.
# nosemgrep: python.lang.security.audit.dangerous-system-call.dangerous-system-call # this is actually fine
r = os.system(' '.join(command))Details in Semgrep docs.
Once you've followed the above steps and are satisfied with your changes:
- Push your changes to your forked repository.
- Go to the original Anomalib repository you forked and click "New pull request".
- Choose your fork and the branch with your changes to open a pull request.
- Fill in the pull request template with the necessary details about your changes.
We look forward to your contributions!
You accept that your contributions will be licensed under the Apache-2.0 License if you contribute to this repository. If this is a concern, please notify the maintainers.