-
Notifications
You must be signed in to change notification settings - Fork 3.1k
docs: add contributing guide #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zichen0116
wants to merge
1
commit into
p-e-w:master
Choose a base branch
from
zichen0116:docs/add-contributing-guide
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Contributing to Heretic | ||
|
|
||
| Thank you for your interest in contributing to Heretic! This document provides guidelines and instructions for contributing. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Python 3.10 or higher | ||
| - [uv](https://docs.astral.sh/uv/) (recommended for dependency management) | ||
| - A CUDA-capable GPU (for testing model-related changes) | ||
|
|
||
| ### Setting Up the Development Environment | ||
|
|
||
| 1. Fork the repository on GitHub. | ||
|
|
||
| 2. Clone your fork locally: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/<your-username>/heretic.git | ||
| cd heretic | ||
| ``` | ||
|
|
||
| 3. Install dependencies using uv: | ||
|
|
||
| ```bash | ||
| uv sync --all-extras --dev | ||
| ``` | ||
|
|
||
| 4. Verify the installation: | ||
|
|
||
| ```bash | ||
| uv run heretic --help | ||
| ``` | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Code Style | ||
|
|
||
| This project enforces code style through automated tooling. Please follow these conventions: | ||
|
|
||
| - **Formatting**: Code is formatted with [Ruff](https://docs.astral.sh/ruff/). Run `uv run ruff format .` before committing. | ||
| - **Linting**: Imports are sorted and code is linted with Ruff. Run `uv run ruff check --extend-select I .` to check. | ||
| - **Type checking**: All code is type-checked with [ty](https://github.com/astral-sh/ty). Run `uv run ty check .` to verify. | ||
| - **Naming**: Avoid abbreviations in identifier names unless they are widely understood (e.g. "KL divergence"). | ||
| - **Comments**: Comments should start with a capital letter and end with a period, using correct grammar and spelling. | ||
| - **Type annotations**: Function and method signatures must be fully type-annotated, including the return type. | ||
| - **SPDX headers**: Every Python source file must start with an SPDX/Copyright header. | ||
| - **Config settings**: When adding new settings in `config.py`, also add them to `config.default.toml` with their default value and description as a comment. The order in `config.default.toml` should match `config.py`. | ||
|
|
||
| ### Running Checks | ||
|
|
||
| Before submitting a pull request, ensure all checks pass locally: | ||
|
|
||
| ```bash | ||
| # Format check | ||
| uv run ruff format --check . | ||
|
|
||
| # Lint and import sort check | ||
| uv run ruff check --output-format=github --extend-select I . | ||
|
|
||
| # Type check | ||
| uv run ty check --output-format=github --error-on-warning . | ||
|
|
||
| # Build verification | ||
| uv build | ||
| ``` | ||
|
|
||
| The CI pipeline runs these checks on Python 3.10, 3.11, 3.12, and 3.13. | ||
|
|
||
| ### Making Changes | ||
|
|
||
| 1. Create a new branch from `master`: | ||
|
|
||
| ```bash | ||
| git checkout -b <branch-name> master | ||
| ``` | ||
|
|
||
| 2. Make your changes, following the code style guidelines above. | ||
|
|
||
| 3. Commit your changes with a descriptive message. | ||
|
|
||
| 4. Push to your fork and open a pull request against the `master` branch. | ||
|
|
||
| ## Pull Request Guidelines | ||
|
|
||
| - **One change per PR**: Each pull request should implement one change, and one change only. If your changes are semantically independent, split them into separate PRs. | ||
| - **Do not modify unrelated code**: Do not change existing code unless the changes are directly related to the PR. This includes formatting and comment changes to unrelated files. | ||
| - **Semantic PR title**: PR titles are validated by CI. Use a [Conventional Commits](https://www.conventionalcommits.org/) prefix: | ||
| - `feat:` for new features | ||
| - `fix:` for bug fixes | ||
| - `perf:` for performance improvements | ||
| - `docs:` for documentation changes | ||
| - `build:` for build system changes | ||
| - **Describe your changes**: Include a summary of what your PR does and why in the PR description. | ||
| - **Link related issues**: If your PR addresses an issue, reference it in the description (e.g. "Closes #123"). | ||
|
|
||
| ## Reporting Issues | ||
|
|
||
| - Search [existing issues](https://github.com/p-e-w/heretic/issues) before opening a new one. | ||
| - Include your environment details (OS, Python version, GPU, PyTorch version) when reporting bugs. | ||
| - Provide the full error output and steps to reproduce the problem. | ||
|
|
||
| ## License | ||
|
|
||
| By contributing to this project, you agree to release your contributions under the [AGPL-3.0-or-later](LICENSE) license. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL for
tyis incorrect.tyis maintained byp-e-w, notastral-sh. It should point tohttps://github.com/p-e-w/ty.