diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e042d362..b03a49814 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,12 @@ If a formatting test fails, it will fix the modified code in place and abort the `git commit`. After looking over the changes, you can `git add ` and then repeat the previous `git commit` command. +You can also run: +``` +make format +``` +which will do the same as above, and it'll also automatically build a `venv` python environment if you +don't already have one, which will isolate the requirements of this project from requirements of other projects. ## Testing DeepSpeed tracks two types of tests: unit tests and more costly model convergence tests. @@ -38,6 +44,11 @@ You can also provide the `-v` flag to `pytest` to see additional information abo tests. Note that [pytest-forked](https://github.com/pytest-dev/pytest-forked) and the `--forked` flag are required to test CUDA functionality in distributed tests. +You can also run: +``` +make test +``` + ### Model Tests To execute model tests, first [install DeepSpeed](#installation). The [DeepSpeedExamples](https://github.com/deepspeedai/DeepSpeedExamples/) repository is cloned diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..8756897eb --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +# usage: make help + +.PHONY: help test format +.DEFAULT_GOAL := help + +help: ## this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + echo $(MAKEFILE_LIST) + +test: ## run tests + pytest --forked tests/unit/ + +format: ## fix formatting + @if [ ! -d "venv" ]; then \ + python -m venv venv; \ + . venv/bin/activate; \ + pip install pre-commit -U; \ + pre-commit clean; \ + pre-commit uninstall; \ + pre-commit install; \ + deactivate; \ + fi + . venv/bin/activate && pre-commit run --files $$(git diff --name-only master) && deactivate