Skip to content

Commit 52bb7b0

Browse files
committed
update smoke test
1 parent cb3ec19 commit 52bb7b0

14 files changed

+143
-163
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"phi-4-mini": "linux.4xlarge.memory",
3434
}
3535
}
36+
EVENT_NAMES = ["pull_request", "push", "schedule"]
3637

3738
DEFAULT_TIMEOUT = 90
3839
CUSTOM_TIMEOUT = {
@@ -64,7 +65,7 @@ def parse_args() -> Any:
6465
"-e",
6566
"--event",
6667
type=str,
67-
choices=["pull_request", "push", "schedule"],
68+
choices=EVENT_NAMES,
6869
required=True,
6970
help="GitHub CI Event. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on",
7071
)
@@ -113,13 +114,17 @@ def model_should_run_on_target_os(model: str, target_os: str) -> bool:
113114
return model not in ["llava"]
114115

115116

116-
def export_models_for_ci() -> dict[str, dict]:
117+
def export_models_for_ci(target_os: str, event: str) -> dict[str, Any]:
117118
"""
118119
This gathers all the example models that we want to test on GitHub OSS CI
119120
"""
120-
args = parse_args()
121-
target_os = args.target_os
122-
event = args.event
121+
122+
if target_os not in DEFAULT_RUNNERS:
123+
print(f"unknown os '{target_os}' provided")
124+
exit(1)
125+
elif event not in EVENT_NAMES:
126+
print(f"unknown event '{event}' provided")
127+
exit(1)
123128

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

177182
models["include"].append(record)
178-
179-
set_output("models", json.dumps(models))
183+
184+
return models
180185

181186

182187
if __name__ == "__main__":
183-
export_models_for_ci()
188+
args = parse_args()
189+
models = export_models_for_ci(
190+
target_os = args.target_os,
191+
event = args.event
192+
)
193+
set_output("models", json.dumps(models))

.ci/scripts/wheel/__init__.py

Whitespace-only changes.

build/packaging/env_var_script_macos.sh renamed to .ci/scripts/wheel/envvar_base.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
# should typically only contain shell variable assignments. Be sure to export
99
# any variables so that subprocesses will see them.
1010

11+
# Define PYTHONPATH if it's not already defined. Needed to run the smoke test
12+
# python script.
13+
if [[ -z "${PYTHONPATH:-}" ]]; then
14+
export PYTHONPATH="${GITHUB_WORKSPACE}/${REPOSITORY}"
15+
fi
16+
17+
# What to build the wheel with.
18+
export BUILD_TOOL="cmake"
19+
1120
# Enable pybindings so that users can execute ExecuTorch programs from python.
1221
export EXECUTORCH_BUILD_PYBIND=1
1322

@@ -18,7 +27,3 @@ export CMAKE_ARGS="${CMAKE_ARGS:-}"
1827
# Link the XNNPACK backend into the pybindings runtime so that users can execute
1928
# ExecuTorch programs that delegate to it.
2029
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_XNNPACK=ON"
21-
22-
# When building for macOS, link additional backends into the pybindings runtime.
23-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"
24-
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_MPS=ON"

.ci/scripts/wheel/envvar_linux.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This file is sourced into the environment before building a pip wheel. It
8+
# should typically only contain shell variable assignments. Be sure to export
9+
# any variables so that subprocesses will see them.
10+
11+
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"

.ci/scripts/wheel/envvar_macos.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This file is sourced into the environment before building a pip wheel. It
8+
# should typically only contain shell variable assignments. Be sure to export
9+
# any variables so that subprocesses will see them.
10+
11+
source "${GITHUB_WORKSPACE}/${REPOSITORY}/.ci/scripts/wheel/envvar_base.sh"
12+
13+
# When building for macOS, link additional backends into the pybindings runtime.
14+
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_COREML=ON"
15+
CMAKE_ARGS="${CMAKE_ARGS} -DEXECUTORCH_BUILD_MPS=ON"

.ci/scripts/wheel/test_base.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
import os
8+
import subprocess
9+
import sys
10+
from functools import lru_cache
11+
12+
13+
@lru_cache()
14+
def _repository_root_dir() -> str:
15+
workspace_dir = os.getenv("GITHUB_WORKSPACE")
16+
if workspace_dir is None:
17+
print("GITHUB_WORKSPACE is not set")
18+
sys.exit(1)
19+
20+
repository_dir = os.getenv("REPOSITORY")
21+
if repository_dir is None:
22+
print("REPOSITORY is not set")
23+
sys.exit(1)
24+
25+
return os.path.join(workspace_dir, repository_dir)
26+
27+
# Since .ci starts with a period, we cannot import it directly.
28+
sys.path.append(os.path.join(_repository_root_dir(), ".ci"))
29+
from scripts import gather_test_models
30+
31+
32+
def run_tests(target_os: str) -> None:
33+
models = gather_test_models.export_models_for_ci(
34+
target_os = target_os,
35+
# Event refers to the type of models that will be downloaded. "pull_request"
36+
# uses higher priority and fast models.
37+
event="pull_request",
38+
).get("include", [])
39+
40+
if len(models) == 0:
41+
print("No models ran")
42+
sys.exit(1)
43+
44+
if os.getenv("PYTHONPATH") == "true":
45+
print("PYTHONPATH is not set")
46+
sys.exit(1)
47+
48+
for model in models:
49+
subprocess.run(
50+
[
51+
os.path.join(_repository_root_dir(), ".ci/scripts/test_model.sh"),
52+
model["model"],
53+
model["build-tool"],
54+
model["backend"],
55+
],
56+
env=os.environ,
57+
check=True,
58+
)

.ci/scripts/wheel/test_linux.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
import test_base
9+
10+
if __name__ == "__main__":
11+
test_base.run_tests(target_os="linux")

.ci/scripts/wheel/test_macos.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
import test_base
9+
10+
if __name__ == "__main__":
11+
test_base.run_tests(target_os="macos")

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Build Linux Wheels
44
on:
55
pull_request:
66
paths:
7-
- build/packaging/**
7+
- .ci/**
88
- .github/workflows/build-wheels-linux.yml
99
push:
1010
branches:
@@ -39,9 +39,9 @@ jobs:
3939
matrix:
4040
include:
4141
- repository: pytorch/executorch
42-
pre-script: build/packaging/pre_build_script.sh
43-
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
42+
pre-script: .ci/scripts/wheel/pre_build_script.sh
43+
post-script: .ci/scripts/wheel/post_build_script.sh
44+
smoke-test-script: .ci/scripts/wheel/test_linux.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
@@ -55,7 +55,7 @@ jobs:
5555
# "recursive" default to do less work, and to give the buck daemon fewer
5656
# files to look at.
5757
submodules: true
58-
env-var-script: build/packaging/env_var_script_linux.sh
58+
env-var-script: .ci/scripts/wheel/envvar_linux.sh
5959
pre-script: ${{ matrix.pre-script }}
6060
post-script: ${{ matrix.post-script }}
6161
package-name: ${{ matrix.package-name }}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Build macOS Wheels
44
on:
55
pull_request:
66
paths:
7-
- build/packaging/**
7+
- .ci/**
88
- .github/workflows/build-wheels-macos.yml
99
push:
1010
branches:
@@ -39,9 +39,9 @@ jobs:
3939
matrix:
4040
include:
4141
- repository: pytorch/executorch
42-
pre-script: build/packaging/pre_build_script.sh
43-
post-script: build/packaging/post_build_script.sh
44-
smoke-test-script: build/packaging/smoke_test.py
42+
pre-script: .ci/scripts/wheel/pre_build_script.sh
43+
post-script: .ci/scripts/wheel/post_build_script.sh
44+
smoke-test-script: .ci/scripts/wheel/test_macos.py
4545
package-name: executorch
4646
name: ${{ matrix.repository }}
4747
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main
@@ -56,7 +56,7 @@ jobs:
5656
# files to look at.
5757
submodules: true
5858
delocate-wheel: false
59-
env-var-script: build/packaging/env_var_script_macos.sh
59+
env-var-script: .ci/scripts/wheel/envvar_macos.sh
6060
pre-script: ${{ matrix.pre-script }}
6161
post-script: ${{ matrix.post-script }}
6262
package-name: ${{ matrix.package-name }}

build/packaging/env_var_script_linux.sh

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

build/packaging/smoke_test.py

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

0 commit comments

Comments
 (0)