Skip to content

Commit 50a73ac

Browse files
committed
update smoke test
1 parent 2d47bca commit 50a73ac

File tree

8 files changed

+67
-130
lines changed

8 files changed

+67
-130
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,10 @@ def model_should_run_on_target_os(model: str, target_os: str) -> bool:
113113
return model not in ["llava"]
114114

115115

116-
def export_models_for_ci() -> dict[str, dict]:
116+
def export_models_for_ci(target_os: str, event: str) -> dict[str, Any]:
117117
"""
118118
This gathers all the example models that we want to test on GitHub OSS CI
119119
"""
120-
args = parse_args()
121-
target_os = args.target_os
122-
event = args.event
123120

124121
# This is the JSON syntax for configuration matrix used by GitHub
125122
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
@@ -175,9 +172,14 @@ def export_models_for_ci() -> dict[str, dict]:
175172
record["runner"] = CUSTOM_RUNNERS[target_os][name]
176173

177174
models["include"].append(record)
178-
179-
set_output("models", json.dumps(models))
175+
176+
return models
180177

181178

182179
if __name__ == "__main__":
183-
export_models_for_ci()
180+
args = parse_args()
181+
models = export_models_for_ci(
182+
target_os = args.target_os,
183+
event = args.event
184+
)
185+
set_output("models", json.dumps(models))

.github/workflows/build-wheels-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- repository: pytorch/executorch
4242
pre-script: build/packaging/pre_build_script.sh
4343
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
44+
smoke-test-script: build/util/packaging/wheel_test_linux.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main

.github/workflows/build-wheels-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- repository: pytorch/executorch
4242
pre-script: build/packaging/pre_build_script.sh
4343
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
44+
smoke-test-script: build/util/packaging/wheel_test_macos.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main

build/packaging/smoke_test.py

Lines changed: 0 additions & 121 deletions
This file was deleted.

build/util/packaging/__init__.py

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import sys
2+
import os
3+
import argparse
4+
import subprocess
5+
from typing import List, Any
6+
7+
_PYTHON_PATH = os.getenv("PYTHONPATH")
8+
if _PYTHON_PATH is None:
9+
print("PYTHONPATH is not set")
10+
exit(1)
11+
12+
# Since the .ci folder starts with a period, it is not possible to import it
13+
# directly, so we must use the importlib module to load it.
14+
sys.path.append(os.path.join(_PYTHON_PATH, ".ci"))
15+
from scripts import gather_test_models
16+
17+
18+
def list_models(target_os: str) -> List[Any]:
19+
if target_os not in gather_test_models.DEFAULT_RUNNERS:
20+
print(f"unknown os '{target_os}' provided")
21+
exit(1)
22+
23+
return gather_test_models.export_models_for_ci(
24+
target_os = target_os,
25+
# Event refers to the type of models that will be downloaded. "pull_request"
26+
# uses higher priority and fast models.
27+
event="pull_request",
28+
).get("include", [])
29+
30+
def run_tests(models: List[Any]) -> None:
31+
if len(models) == 0:
32+
print("No models found")
33+
exit(1)
34+
35+
for model in models:
36+
subprocess.run(
37+
[
38+
os.path.join(_PYTHON_PATH, ".ci/scripts/test_model.sh"),
39+
model["model"],
40+
model["build-tool"],
41+
model["backend"],
42+
],
43+
check=True,
44+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import wheel_test_base
2+
3+
if __name__ == "__main__":
4+
wheel_test_base.run_tests(
5+
models=wheel_test_base.list_models("linux")
6+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import wheel_test_base
2+
3+
if __name__ == "__main__":
4+
wheel_test_base.run_tests(
5+
models=wheel_test_base.list_models("macos")
6+
)

0 commit comments

Comments
 (0)