Skip to content

Commit 2cd02f3

Browse files
authored
Add workflow for running cpu pytests (NVIDIA#13)
* Add workflow for cpu pytests Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Install wheel to fix fasttext import Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Omit python 3.8, do not fast fail Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Check if updating setuptools/pip changes cython errors Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Explicitly install cython Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Try freeing up space before install Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * Try rapids_no_initialize Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> * remove python 3.9 testing for now Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com> --------- Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com>
1 parent 8d47911 commit 2cd02f3

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.github/workflows/test.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test Python package
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
9+
# When this workflow is queued, automatically cancel any previous running
10+
# or pending jobs from the same branch
11+
concurrency:
12+
group: test-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build_and_test:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest]
22+
python-version: ["3.10"]
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install NeMo-Curator and pytest
30+
# TODO: Remove pytest when optional test dependencies are added to setup.py
31+
32+
# Installing wheel beforehand due to fasttext issue:
33+
# https://github.com/facebookresearch/fastText/issues/512#issuecomment-1837367666
34+
# Explicitly install cython: https://github.com/VKCOM/YouTokenToMe/issues/94
35+
run: |
36+
pip install wheel cython
37+
pip install --no-cache-dir --extra-index-url https://pypi.nvidia.com .
38+
pip install pytest
39+
- name: Run tests
40+
# TODO: Remove env variable when gpu dependencies are optional
41+
run: |
42+
RAPIDS_NO_INITIALIZE=1 python -m pytest -v --cpu
43+
44+

conftest.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
4+
def pytest_addoption(parser):
5+
parser.addoption(
6+
"--cpu", action="store_true", default=False, help="Run tests without gpu marker"
7+
)
8+
9+
10+
def pytest_collection_modifyitems(config, items):
11+
if config.getoption("--cpu"):
12+
skip_gpu = pytest.mark.skip(reason="Skipping GPU tests")
13+
for item in items:
14+
if "gpu" in item.keywords:
15+
item.add_marker(skip_gpu)

0 commit comments

Comments
 (0)