From 3e227477993492951cbd2fcc0de524b98f105fa2 Mon Sep 17 00:00:00 2001 From: chenyu Date: Thu, 20 Feb 2025 14:40:41 -0500 Subject: [PATCH] run unit test on windows ci (#9187) * factor out testing_minimal in setup.py [pr] * testing_unit + windows --- .github/workflows/test.yml | 7 +++++-- setup.py | 26 ++++++++++++++------------ test/unit/test_helpers.py | 3 ++- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e57edea90..4df40f654f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -263,7 +263,7 @@ jobs: uses: ./.github/actions/setup-tinygrad with: key: unittest-12 - deps: testing + deps: testing_unit - name: Test README run: awk '/```python/{flag=1;next}/```/{flag=0}flag' README.md > README.py && PYTHONPATH=. python README.py - name: Run unit tests @@ -624,10 +624,13 @@ jobs: uses: ./.github/actions/setup-tinygrad with: key: windows-minimal - deps: testing_minimal + deps: testing_unit - name: Set env shell: bash run: printf "${{ matrix.backend == 'llvm' && 'LLVM=1' || matrix.backend == 'clang' && 'CLANG=1'}}" >> $GITHUB_ENV + - name: Run unit tests + if: matrix.backend=='llvm' + run: python -m pytest -n=auto test/unit/ --ignore=test/unit/test_disk_tensor.py --ignore=test/unit/test_elf.py --ignore=test/unit/test_tar.py - name: Run pytest (${{ matrix.backend }}) shell: bash run: | diff --git a/setup.py b/setup.py index f0bd40a0de..0063457e49 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,14 @@ directory = Path(__file__).resolve().parent with open(directory / 'README.md', encoding='utf-8') as f: long_description = f.read() +testing_minimal = [ + "numpy", + "torch", + "pytest", + "pytest-xdist", + "hypothesis", +] + setup(name='tinygrad', version='0.10.1', description='You like pytorch? You like micrograd? You love tinygrad! <3', @@ -35,19 +43,14 @@ setup(name='tinygrad', "types-tqdm", ], #'mlperf': ["mlperf-logging @ git+https://github.com/mlperf/logging.git@4.1.0-rc3"], - 'testing_minimal': [ - "numpy", - "torch", - "pytest", - "pytest-xdist", - "hypothesis", + 'testing_minimal': testing_minimal, + 'testing_unit': testing_minimal + [ + "tqdm", + "safetensors", + "tabulate" # for sz.py ], - 'testing': [ - "numpy", - "torch", + 'testing': testing_minimal + [ "pillow", - "pytest", - "pytest-xdist", "onnx==1.16.0", "onnx2torch", "opencv-python", @@ -60,7 +63,6 @@ setup(name='tinygrad', "blobfile", "librosa", "networkx", - "hypothesis", "nibabel", "bottle", "ggml-python", diff --git a/test/unit/test_helpers.py b/test/unit/test_helpers.py index 749e332b11..434f3bc0f7 100644 --- a/test/unit/test_helpers.py +++ b/test/unit/test_helpers.py @@ -1,5 +1,4 @@ import gzip, unittest -from PIL import Image from tinygrad import Variable from tinygrad.helpers import Context, ContextVar from tinygrad.helpers import merge_dicts, strip_parens, prod, round_up, fetch, fully_flatten, from_mv, to_mv, polyN, time_to_str @@ -126,11 +125,13 @@ class TestFetch(unittest.TestCase): assert (len(fetch('https://google.com', allow_caching=False).read_bytes())>0) def test_fetch_img(self): + from PIL import Image img = fetch("https://avatars.githubusercontent.com/u/132956020", allow_caching=False) with Image.open(img) as pimg: assert pimg.size == (77, 77), pimg.size def test_fetch_subdir(self): + from PIL import Image img = fetch("https://avatars.githubusercontent.com/u/132956020", allow_caching=False, subdir="images") with Image.open(img) as pimg: assert pimg.size == (77, 77), pimg.size