Sparsify is developed and tested using Python 3.8-3.9. To develop Sparsify, you will also need the development dependencies and to follow the styling guidelines.
Here's some details to get started.
Development Installation
To develop the Sparsify UI, you will also need to install Node.js and yarn.
git clone https://github.com/neuralmagic/sparsify.git
cd sparsify
python3 -m pip install -e ./[dev]
yarn install
This will clone the Sparsify repo, install sparsify, and install the development dependencies.
Code Styling and Formatting checks
make style
make quality
This will run automatic code styling using prettier
for UI code and black
and isort
for the backend.
It also tests that the repository's code matches its style standards.
EXAMPLE: test changes locally
make test
This will run all Sparisfy unit tests. File any error found before changes as an Issue and fix any errors found after making changes before submitting a Pull Request.
-
Fork the
neuralmagic/sparsify
repository into your GitHub account: https://github.com/neuralmagic/sparsify/fork. -
Clone your fork of the GitHub repository, replacing
<username>
with your GitHub username.Use ssh (recommended):
git clone git@github.com:<username>/sparsify.git
Or https:
git clone https://github.com/<username>/sparsify.git
-
Add a remote to keep up with upstream changes.
git remote add upstream https://github.com/neuralmagic/sparsify.git
If you already have a copy, fetch upstream changes.
git fetch upstream
-
Create a feature branch to work in.
git checkout -b feature-xxx remotes/upstream/main
-
Work in your feature branch.
git commit -a
-
Periodically rebase your changes
git pull --rebase
-
When done, combine ("squash") related commits into a single one
git rebase -i upstream/main
This will open your editor and allow you to re-order commits and merge them:
- Re-order the lines to change commit order (to the extent possible without creating conflicts)
- Prefix commits using
s
(squash) orf
(fixup) to merge extraneous commits.
-
Submit a pull-request
git push origin feature-xxx
Go to your fork main page
https://github.com/<username>/sparsify
If you recently pushed your changes GitHub will automatically pop up a
Compare & pull request
button for any branches you recently pushed to. If you click that button it will automatically offer you to submit your pull-request to theneuralmagic/sparsify
repository.- Give your pull-request a meaningful title.
You'll know your title is properly formatted once the
Semantic Pull Request
GitHub check transitions from a status of "pending" to "passed". - In the description, explain your changes and the problem they are solving.
- Give your pull-request a meaningful title.
You'll know your title is properly formatted once the
-
Addressing code review comments
Repeat steps 5. through 7. to address any code review comments and rebase your changes if necessary.
Push your updated changes to update the pull request
git push origin [--force] feature-xxx
--force
may be necessary to overwrite your existing pull request in case your commit history was changed when performing the rebase.Note: Be careful when using
--force
since you may lose data if you are not careful.git push origin --force feature-xxx