Skip to content
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

pytest without need to dealing with PYTHONPATH #95

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ Create unit tests and convergence tests for your kernel in the tests directory.
2. run `make checkstyle` to ensure code style.
3. run `make test-convergence` to ensure convergence.

If encounter the import error `ModuleNotFoundError: No module named 'test.utils'`, please add `Liger-Kernel` folder in the path
```
export PYTHONPATH="${PYTHONPATH}:your-path-here/Liger-Kernel"
```

### Run pytest on single file
`pytest test_sample.py::test_function_name`
`python -m pytest test_sample.py::test_function_name`

## Submit PR
Fork the repo, copy and paste the successful test logs in the PR and submit the PR followed by the PR template (**[example PR](https://github.com/linkedin/Liger-Kernel/pull/21)**).
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.PHONY: test checkstyle test-convergence
.PHONY: test checkstyle test-convergence all


all: test test-convergence checkstyle

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

# Command to run pytest for correctness tests
test:
pytest --disable-warnings test/ --ignore=test/convergence
python -m pytest --disable-warnings test/ --ignore=test/convergence


# Command to run flake8 (code style check), isort (import ordering), and black (code formatting)
Expand All @@ -18,4 +21,4 @@ checkstyle:
# Command to run pytest for convergence tests
# We have to explicitly set HF_DATASETS_OFFLINE=1, or dataset will silently try to send metrics and timeout (80s) https://github.com/huggingface/datasets/blob/37a603679f451826cfafd8aae00738b01dcb9d58/src/datasets/load.py#L286
test-convergence:
HF_DATASETS_OFFLINE=1 pytest --disable-warnings test/convergence
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence
Loading