Skip to content

Commit

Permalink
ci: drop macos example test run (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Dec 10, 2024
1 parent de6b1c6 commit 31c2156
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
pyv: ['3.9', '3.12']
group: ['get_started', 'llm_and_nlp or computer_vision', 'multimodal']
exclude:
Expand Down Expand Up @@ -166,9 +166,12 @@ jobs:
- name: Install nox
run: uv pip install nox --system

# HF runs against actual API - thus run it only once
- name: Set hf token
if: matrix.os == 'ubuntu-latest' && matrix.pyv == '3.12'
run: echo 'HF_TOKEN=${{ secrets.HF_TOKEN }}' >> "$GITHUB_ENV"

- name: Run examples
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: nox -s examples -p ${{ matrix.pyv }} -- -m "${{ matrix.group }}"

check:
Expand Down
32 changes: 12 additions & 20 deletions tests/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,9 @@
]
)

llm_and_nlp_examples = sorted(
[
filename
for filename in glob.glob("examples/llm_and_nlp/**/*.py", recursive=True)
# no anthropic token, HF runs against actual API - thus run it only once
if "claude" not in filename
and (
"hf-" not in filename
or (sys.platform == "darwin" and sys.version_info >= (3, 12))
)
]
)
llm_and_nlp_examples = sorted(glob.glob("examples/llm_and_nlp/**/*.py", recursive=True))

multimodal_examples = sorted(
[
filename
for filename in glob.glob("examples/multimodal/**/*.py", recursive=True)
# no OpenAI token
if "openai" not in filename
]
)
multimodal_examples = sorted(glob.glob("examples/multimodal/**/*.py", recursive=True))

computer_vision_examples = sorted(
[
Expand Down Expand Up @@ -84,13 +66,23 @@ def test_get_started_examples(example):
@pytest.mark.llm_and_nlp
@pytest.mark.parametrize("example", llm_and_nlp_examples)
def test_llm_and_nlp_examples(example):
name = os.path.basename(example)
if "hf-" in name:
import huggingface_hub

if not huggingface_hub.get_token():
pytest.skip("Hugging Face token not set")
if "claude" in name and "ANTHROPIC_API_KEY" not in os.environ:
pytest.skip("ANTHROPIC_API_KEY not set")
smoke_test(example)


@pytest.mark.examples
@pytest.mark.multimodal
@pytest.mark.parametrize("example", multimodal_examples)
def test_multimodal(example):
if "openai" in os.path.basename(example) and "OPENAI_API_KEY" not in os.environ:
pytest.skip("OPENAI_API_KEY not set")
smoke_test(
example,
{
Expand Down

0 comments on commit 31c2156

Please sign in to comment.