Welcome to the ONNX IR project! We appreciate your interest in contributing.
Before contributing, please familiarize yourself with our development guidelines:
- Coding Style: Our coding conventions and style guidelines
- Design Principles: The core principles guiding the design of ONNX IR
- Python 3.9 or higher
- Git
-
Clone the repository:
git clone https://github.com/onnx/ir-py.git cd ir-py -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install development dependencies:
pip install -r requirements-dev.txt
-
Install the package in development mode:
pip install -e .
We use lintrunner for code quality checks. The project includes several linters:
- RUFF: Python linter and code formatter
- MYPY: Static type checker
- EDITORCONFIG-CHECKER: EditorConfig compliance checker
-
Initialize lintrunner (this installs the required linting tools):
lintrunner init
-
Run all linters:
lintrunner
-
Apply automatic fixes where possible:
lintrunner -a --output oneline
-
Format code only:
lintrunner f --output oneline
You can lint specific files or directories:
lintrunner src/onnx_ir/
lintrunner path/to/specific/file.pyThe project uses nox for testing across different environments and pytest as the test runner.
# Run all tests
nox -s test
# Run tests with specific Python version (if available)
nox -s test --python 3.11
# Run tests with ONNX weekly build
nox -s test-onnx-weekly
# Run tests with PyTorch nightly
nox -s test-torch-nightlyIf you prefer to run tests directly:
# Run all tests
pytest
# Run tests with coverage
pytest --cov=onnx_ir
# Run specific test file
pytest tests/test_specific.py
# Run doctests
pytest src --doctest-modules-
Ensure your code passes all linting checks:
lintrunner
-
Run the test suite:
pytest path/to/test.py
- Fork the repository and create a feature branch from
main - Write clear, descriptive commit messages. Be sure to signoff your commits.
- Add tests for new functionality
- Update documentation if needed
- Ensure all CI checks pass
- Request review from maintainers
Use clear and descriptive PR description:
[component] brief description of change
More detailed explanation if needed, including:
- What was changed
- Why it was changed
- Any breaking changes
- Create an issue or comment on an existing one to discuss your proposed changes
- Fork the repository and create a feature branch
- Make your changes following our coding style and design principles
- Add or update tests as appropriate
- Run linting and tests locally
- Submit a pull request with a clear description of your changes
- Issues: Report bugs or request features via GitHub Issues
- Discussions: For questions and discussions, use GitHub Discussions
- Documentation: Visit the official documentation
By contributing to ONNX IR, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to ONNX IR! 🎉