Skip to content

Commit 17416f0

Browse files
authored
[update] revise Github workflow to fix no space left issue in auto test (OpenDCAI#380)
* [update] revise github workflow to fix issue * fix * fix * fix detailed logger during lazzy import * check if no datasets restriction
1 parent 58eaca2 commit 17416f0

3 files changed

Lines changed: 57 additions & 43 deletions

File tree

.github/workflows/test.yml

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ on:
55
branches: [ "main" ]
66
paths:
77
- "**/*.py"
8-
- "requirements.txt"
8+
- "requirements*.txt"
99
- ".github/workflows/*.yml"
1010
pull_request:
1111
branches: [ "main" ]
1212
paths:
1313
- "**/*.py"
14-
- "requirements.txt"
14+
- "requirements*.txt"
1515
- ".github/workflows/*.yml"
16+
1617
jobs:
1718
test:
1819
name: Run tests on ${{ matrix.os }} with Python ${{ matrix.python }}
@@ -21,51 +22,56 @@ jobs:
2122
fail-fast: false
2223
matrix:
2324
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
24-
torch: [{base: '2.5.1', vision: '0.20.1'}]
2525
python: ["3.10", "3.11", "3.12"]
2626

2727
runs-on: ${{ matrix.os }}
28+
2829
steps:
29-
- uses: actions/checkout@v4
30-
- name: Set up Python ${{ matrix.python }}
31-
uses: actions/setup-python@v3
32-
with:
33-
python-version: ${{ matrix.python }}
34-
- name: Install testing dependencies
35-
run: |
36-
python -m pip install --upgrade pip
37-
pip install wheel
38-
pip install -r requirements.txt
39-
pip install -e .[vllm]
30+
- uses: actions/checkout@v4
4031

41-
- name: Run tests on Windows
42-
if: startsWith(matrix.os, 'windows')
43-
env:
44-
PYTHONDONTWRITEBYTECODE: 1
45-
# torchrun --nproc_per_node=2 -m pytest ./tests/dist
46-
run: |
47-
pytest -m cpu test
32+
- name: Set up Python ${{ matrix.python }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python }}
4836

49-
- name: Run '${{ matrix.testmarker }}' tests on Linux / Mac
50-
if: ${{ !startsWith(matrix.os, 'windows') }}
51-
env:
52-
# LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
53-
PYTHONDONTWRITEBYTECODE: 1
54-
run: |
55-
pytest -m cpu test
37+
# 仅 Linux:释放 GitHub runner 的大块预装组件,立刻回收十几 GB
38+
- name: Free up disk space on Linux
39+
if: runner.os == 'Linux'
40+
run: |
41+
df -h
42+
sudo rm -rf /usr/local/lib/android || true
43+
sudo rm -rf /usr/share/dotnet || true
44+
sudo rm -rf /opt/ghc || true
45+
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
46+
docker system prune -af || true
47+
sudo apt-get clean
48+
sudo rm -rf /var/lib/apt/lists/*
49+
df -h
5650
57-
# big-model-test:
58-
# if: github.repository == 'OpenDCAI/DataFlow-Preview'
59-
# runs-on: [self-hosted] # 跑在你的私有 GPU runner 上
60-
# steps:
61-
# - uses: actions/checkout@v4
51+
# 安装 uv(正确的官方 action)
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v7
54+
with:
55+
enable-cache: true # 远端缓存 uv 自身(对磁盘占用很小)
6256

63-
# - name: Install GPU dependencies
64-
# run: pip install -e .
57+
# 用系统 Python 安装依赖,禁用缓存,避免写入大体积 wheel 缓存
58+
- name: Install dependencies
59+
env:
60+
UV_SYSTEM_PYTHON: "1"
61+
run: |
62+
uv pip install --no-cache -r requirements.txt
63+
uv pip install -e .
6564
66-
# - name: upgrade omegaconf
67-
# run: pip install --upgrade omegaconf
65+
- name: Run tests on Windows
66+
if: startsWith(matrix.os, 'windows')
67+
env:
68+
PYTHONDONTWRITEBYTECODE: 1
69+
run: |
70+
pytest -m cpu test
6871
69-
# - name: Run GPU tests
70-
# run: |
71-
# pytest -m gpu test
72+
- name: Run tests on Linux / macOS
73+
if: ${{ !startsWith(matrix.os, 'windows') }}
74+
env:
75+
PYTHONDONTWRITEBYTECODE: 1
76+
run: |
77+
pytest -m cpu test

dataflow/utils/registry.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,17 @@ def _load_class_from_file(self, file_path, class_name):
323323
logger.debug(f"Module file: {module.__file__}")
324324
logger.debug(f"Module package: {module.__package__}")
325325
spec.loader.exec_module(module)
326+
326327
except Exception as e:
327-
logger.error(f"{e.__str__()}")
328-
raise e
328+
import traceback
329+
logger.exception("Import failed for %s from %s", mod_name, abs_file_path)
330+
# 可选:再打印一份,CI 日志更清楚
331+
print("=== Lazy import traceback ===")
332+
print("Module:", mod_name)
333+
print("File:", abs_file_path)
334+
print("".join(traceback.format_exception(e)))
335+
raise
336+
329337

330338
# 提取类
331339
if not hasattr(module, class_name):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
numpy<2.0.0
2-
datasets<=3.2
2+
datasets
33
scipy
44
torch
55
torchvision

0 commit comments

Comments
 (0)