| 1 |
.PHONY: quality style test docs utils |
| 2 |
|
| 3 |
check_dirs := . |
| 4 |
|
| 5 |
# Check that source code meets quality standards |
| 6 |
|
| 7 |
# this target runs checks on all files |
| 8 |
quality: |
| 9 |
ruff check $(check_dirs) |
| 10 |
ruff format --check $(check_dirs) |
| 11 |
|
| 12 |
# Format source code automatically and check is there are any problems left that need manual fixing |
| 13 |
style: |
| 14 |
ruff check $(check_dirs) --fix |
| 15 |
ruff format $(check_dirs) |
| 16 |
|
| 17 |
# Run tests for the library |
| 18 |
test_core: |
| 19 |
python -m pytest -s -v ./tests/ \ |
| 20 |
--ignore=./tests/test_big_modeling.py \ |
| 21 |
--ignore=./tests/test_modeling_utils.py \ |
| 22 |
--ignore=./tests/test_examples.py \ |
| 23 |
--ignore=./tests/test_cli.py \ |
| 24 |
--ignore=./tests/deepspeed \ |
| 25 |
--ignore=./tests/fsdp \ |
| 26 |
--ignore=./tests/tp \ |
| 27 |
$(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_core.log",) |
| 28 |
|
| 29 |
test_cli: |
| 30 |
python -m pytest -s -v ./tests/test_cli.py $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_cli.log",) |
| 31 |
|
| 32 |
test_big_modeling: |
| 33 |
python -m pytest -s -v ./tests/test_big_modeling.py ./tests/test_modeling_utils.py $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_big_modeling.log",) |
| 34 |
|
| 35 |
test_deepspeed: |
| 36 |
python -m pytest -s -v ./tests/deepspeed $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_deepspeed.log",) |
| 37 |
|
| 38 |
test_fsdp: |
| 39 |
python -m pytest -s -v ./tests/fsdp $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_fsdp.log",) |
| 40 |
|
| 41 |
test_tp: |
| 42 |
python -m pytest -s -v ./tests/tp $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_tp.log",) |
| 43 |
|
| 44 |
# Since the new version of pytest will *change* how things are collected, we need `deepspeed` to |
| 45 |
# run after test_core and test_cli |
| 46 |
test: |
| 47 |
@status=0; \ |
| 48 |
for target in test_core test_cli test_big_modeling test_deepspeed test_fsdp test_tp; do \ |
| 49 |
$(MAKE) $$target || status=1; \ |
| 50 |
done; \ |
| 51 |
exit $$status |
| 52 |
|
| 53 |
test_examples: |
| 54 |
python -m pytest -s -v ./tests/test_examples.py $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_examples.log",) |
| 55 |
|
| 56 |
# Example-suite shards used by test.yml |
| 57 |
test_example_differences: |
| 58 |
python -m pytest -s -v ./tests/test_examples.py::ExampleDifferenceTests $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_example_diff.log",) |
| 59 |
|
| 60 |
test_checkpoint_epoch: |
| 61 |
python -m pytest -s -v ./tests/test_examples.py::FeatureExamplesTests -k "by_epoch" $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_checkpoint_epoch.log",) |
| 62 |
|
| 63 |
test_checkpoint_step: |
| 64 |
python -m pytest -s -v ./tests/test_examples.py::FeatureExamplesTests -k "by_step" $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_checkpoint_step.log",) |
| 65 |
|
| 66 |
# Same as test but used to install only the base dependencies |
| 67 |
test_prod: |
| 68 |
$(MAKE) test_core |
| 69 |
|
| 70 |
test_rest: |
| 71 |
python -m pytest -s -v ./tests/test_examples.py::FeatureExamplesTests -k "not by_step and not by_epoch" $(if $(IS_GITHUB_CI),--report-log "$(PYTORCH_VERSION)_rest.log",) |
| 72 |
|
| 73 |
# For developers to prepare a release |
| 74 |
prepare_release: |
| 75 |
rm -rf dist build |
| 76 |
python setup.py bdist_wheel sdist |
| 77 |
|
| 78 |
# Make sure this is ran in a fresh venv of some form |
| 79 |
install_test_release: |
| 80 |
pip uninstall accelerate -y |
| 81 |
pip install -i https://testpypi.python.org/pypi --extra-index-url https://pypi.org/simple accelerate$(if $(version),==$(version),) |
| 82 |
|
| 83 |
# Run as `make target=testpypi upload_release` |
| 84 |
upload_release: |
| 85 |
@if [ "$(target)" != "testpypi" ] && [ "$(target)" != "pypi" ]; then \ |
| 86 |
echo "Error: target must be either 'testpypi' or 'pypi'"; \ |
| 87 |
exit 1; \ |
| 88 |
fi |
| 89 |
twine upload dist/* -r $(target) |