-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
915e5c8
commit 611cc96
Showing
8 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Examples | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 3 * * *' | ||
push: # to remove | ||
|
||
env: | ||
FORCE_COLOR: "1" | ||
|
||
jobs: | ||
run: | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 60 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest-16-cores, macos-latest, windows-latest-8-cores] | ||
pyv: ['3.9', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.pyv }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.pyv }} | ||
cache: 'pip' | ||
|
||
- name: Upgrade nox and uv | ||
run: | | ||
python -m pip install --upgrade 'nox[uv]' | ||
nox --version | ||
uv --version | ||
- name: Run examples | ||
run: nox -s examples -p ${{ matrix.pyv }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import glob | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
import pytest | ||
|
||
get_started_examples = [ | ||
filename | ||
for filename in glob.glob("examples/get_started/**/*.py", recursive=True) | ||
if "torch" not in filename or os.environ.get("RUNNER_OS") != "Linux" | ||
] | ||
llm_and_nlp_examples = [ | ||
filename | ||
for filename in glob.glob("examples/llm_and_nlp/**/*.py", recursive=True) | ||
# no anthropic token | ||
# and cannot install unstructured[all-docs] on most GH action runners | ||
if "claude" not in filename and "unstructured" not in filename | ||
] | ||
multimodal_examples = [ | ||
filename | ||
for filename in glob.glob("examples/multimodal/**/*.py", recursive=True) | ||
# no OpenAI token | ||
# and hf download painfully slow | ||
if "openai" not in filename and "hf" not in filename | ||
] | ||
|
||
|
||
def smoke_test(example: str): | ||
completed_process = subprocess.run( # noqa: S603 | ||
[sys.executable, example], | ||
capture_output=True, | ||
cwd=os.path.abspath(os.path.join(__file__, "..", "..", "..")), | ||
check=True, | ||
) | ||
|
||
assert completed_process.stdout | ||
assert completed_process.stderr | ||
|
||
|
||
@pytest.mark.examples | ||
@pytest.mark.parametrize("example", get_started_examples) | ||
def test_get_started_examples(example): | ||
smoke_test(example) | ||
|
||
|
||
# @pytest.mark.examples | ||
# @pytest.mark.parametrize("example", llm_and_nlp_examples) | ||
# def test_llm_and_nlp_examples(example): | ||
# smoke_test(example) | ||
|
||
|
||
@pytest.mark.examples | ||
@pytest.mark.parametrize("example", multimodal_examples) | ||
def test_multimodal(example): | ||
smoke_test(example) |