Skip to content

Commit c91796f

Browse files
authored
Fix CI bootstrap imports and env activation (#2788)
1 parent 4c84f4f commit c91796f

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

.github/scripts/ci_deps.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
from pathlib import Path
55
from typing import Any
66

7-
import pcre
87
import yaml
98

9+
try:
10+
import pcre as regex
11+
except ModuleNotFoundError:
12+
import re as regex
13+
1014
BASE_DIR = Path(__file__).resolve().parent
11-
_PKG_NAME_RE = pcre.compile(r"^[A-Za-z0-9_.-]+")
15+
_PKG_NAME_RE = regex.compile(r"^[A-Za-z0-9_.-]+")
1216

1317

1418
def resolve_test_path(raw_name: str) -> Path:

.github/scripts/ci_tests.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
import urllib.error
99
from pathlib import Path
1010

11-
import pcre
1211
from ci_gpu import (
1312
build_job_request,
1413
extract_gpu_ids,
1514
normalize_base_url,
1615
request_json,
1716
)
1817

19-
ERROR_PATTERN = pcre.compile(
18+
try:
19+
import pcre as regex
20+
except ModuleNotFoundError:
21+
import re as regex
22+
23+
ERROR_PATTERN = regex.compile(
2024
r"nvcc fatal|error:|fatal error|ModuleNotFoundError|ImportError|AssertionError|Exception|is the correct path|No such file or directory|Repo id must be in"
2125
)
2226

.github/scripts/ci_workflow.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
from pathlib import PurePosixPath
88
from typing import Any
99

10-
import pcre
11-
import requests
12-
import yaml
13-
from packaging.specifiers import SpecifierSet
14-
from packaging.version import Version
10+
try:
11+
import pcre as regex
12+
except ModuleNotFoundError:
13+
import re as regex
1514

1615

1716
def split_csv(raw: str | None) -> list[str]:
@@ -37,6 +36,8 @@ def parse_test_config(
3736
group: str,
3837
test_name: str | None = None,
3938
) -> dict[str, Any]:
39+
import yaml
40+
4041
yaml_path = Path(yaml_file)
4142
with yaml_path.open("r", encoding="utf-8") as fh:
4243
data = yaml.safe_load(fh) or {}
@@ -129,9 +130,9 @@ def is_model_compat_test(rel_path: str, file_path: Path) -> bool:
129130

130131

131132
def matches_test_regex(test_regex: str, rel_path: str) -> bool:
132-
if pcre.match(test_regex, rel_path):
133+
if regex.match(test_regex, rel_path):
133134
return True
134-
return pcre.match(test_regex, PurePosixPath(rel_path).name) is not None
135+
return regex.match(test_regex, PurePosixPath(rel_path).name) is not None
135136

136137

137138
def should_skip_test(yaml_file: str | Path, rel_path: str) -> bool:
@@ -195,6 +196,10 @@ def list_tests(ignored_test_files: str | list[str], test_names: str, test_regex:
195196

196197

197198
def list_matching_versions(package: str, version_spec: str) -> list[str]:
199+
import requests
200+
from packaging.specifiers import SpecifierSet
201+
from packaging.version import Version
202+
198203
specifier = SpecifierSet(version_spec)
199204
response = requests.get(f"https://pypi.org/pypi/{package}/json", timeout=30)
200205
response.raise_for_status()

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,13 @@ jobs:
269269
echo "-- loading unit test's config --"
270270
source /opt/uv/setup_uv_venv.sh unit_test_env
271271
uv pip install requests packaging -U
272-
eval "$(python3 .github/scripts/ci_workflow.py resolve-env \
272+
env_output="$(python3 .github/scripts/ci_workflow.py resolve-env \
273273
--group tests \
274274
--test-name "${{ matrix.test_script }}" \
275275
--cuda-version "${{ needs.check-vm.outputs.cuda_version }}" \
276276
--torch-version "${{ env.TORCH_VERSION }}" \
277277
--shell)"
278+
eval "$env_output"
278279
279280
echo "-- setting up env --"
280281
echo "env_name: $ENV_NAME"
@@ -534,12 +535,13 @@ jobs:
534535
echo "-- loading unit test's config --"
535536
source /opt/uv/setup_uv_venv.sh unit_test_env
536537
uv pip install requests packaging -U
537-
eval "$(python3 .github/scripts/ci_workflow.py resolve-env \
538+
env_output="$(python3 .github/scripts/ci_workflow.py resolve-env \
538539
--group tests \
539540
--test-name "${{ matrix.test_script }}" \
540541
--cuda-version "${{ needs.check-vm.outputs.cuda_version }}" \
541542
--torch-version "${{ env.TORCH_VERSION }}" \
542543
--shell)"
544+
eval "$env_output"
543545
544546
echo "-- setting up env --"
545547
echo "env_name: $ENV_NAME"

0 commit comments

Comments
 (0)