Skip to content

Commit 39d7f34

Browse files
authored
[Test] Refactor Unit Test Classification and CI Triggers for API Key-Dependent Tests (#170)
1 parent c59cf87 commit 39d7f34

26 files changed

+404
-189
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
name: Unit Tests
2-
1+
name: Integrated Tests
32

43
on:
54
push:
@@ -9,6 +8,8 @@ on:
98

109
jobs:
1110
test:
11+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}
12+
1213
runs-on: ${{ matrix.os }}
1314
strategy:
1415
matrix:
@@ -28,9 +29,8 @@ jobs:
2829
- name: Pull Docker images
2930
run: |
3031
DOCKER_IMAGES=(
31-
"agentscope/runtime-sandbox-bfcl:latest"
32-
"agentscope/runtime-sandbox-appworld:latest"
3332
"agentscope/runtime-sandbox-base:latest"
33+
"agentscope/runtime-sandbox-gui:latest"
3434
"agentscope/runtime-sandbox-browser:latest"
3535
"agentscope/runtime-sandbox-filesystem:latest"
3636
)
@@ -61,14 +61,14 @@ jobs:
6161
- name: Install dependencies
6262
run: |
6363
export PIP_DEFAULT_TIMEOUT=300
64-
pip install -q -e ".[dev,langgraph,agno,a2a,autogen,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext]"
64+
pip install -q -e ".[dev,langgraph,agno,autogen,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext]"
6565
66-
- name: Run tests with coverage
66+
- name: Run integrated tests with coverage
6767
env:
6868
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6969
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
7070
run: |
71-
coverage run -m pytest tests
71+
coverage run -m pytest tests/integrated
7272
7373
- name: Generate coverage report
7474
run: |

.github/workflows/unit_test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
test:
13+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}
14+
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest ]
19+
python-version: [ '3.10' ]
20+
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Cache pip dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pip-
38+
39+
- name: Update setuptools
40+
run: |
41+
pip install --upgrade pip
42+
pip install setuptools==78.1.1 wheel==0.45.1
43+
44+
- name: Set PYTHONPATH
45+
run: |
46+
echo "PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/src" >> $GITHUB_ENV
47+
48+
- name: Install dependencies
49+
run: |
50+
export PIP_DEFAULT_TIMEOUT=300
51+
pip install -q -e ".[dev,langgraph,agno,autogen,langchain_rag,llamaindex_rag,aliyun_tablestore_ext,memory_ext]"
52+
53+
- name: Run tests with coverage
54+
run: |
55+
coverage run -m pytest tests/unit
56+
57+
- name: Generate coverage report
58+
run: |
59+
coverage report -m
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Unit Tests for Sandbox
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
test:
13+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}
14+
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest ]
19+
python-version: [ '3.10' ]
20+
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Pull Docker images
32+
run: |
33+
DOCKER_IMAGES=(
34+
"agentscope/runtime-sandbox-base:latest"
35+
"agentscope/runtime-sandbox-gui:latest"
36+
"agentscope/runtime-sandbox-browser:latest"
37+
"agentscope/runtime-sandbox-filesystem:latest"
38+
)
39+
40+
for img in "${DOCKER_IMAGES[@]}"; do
41+
echo "Pulling image: $img"
42+
docker pull "$img"
43+
done
44+
echo "All Docker images pulled successfully."
45+
46+
- name: Cache pip dependencies
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/pip
50+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
51+
restore-keys: |
52+
${{ runner.os }}-pip-
53+
54+
- name: Update setuptools
55+
run: |
56+
pip install --upgrade pip
57+
pip install setuptools==78.1.1 wheel==0.45.1
58+
59+
- name: Set PYTHONPATH
60+
run: |
61+
echo "PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/src" >> $GITHUB_ENV
62+
63+
- name: Install dependencies
64+
run: |
65+
export PIP_DEFAULT_TIMEOUT=300
66+
pip install -q -e ".[dev]"
67+
68+
- name: Run tests with coverage
69+
run: |
70+
coverage run -m pytest tests/sandbox/test_sandbox.py tests/sandbox/test_tool.py
71+
72+
- name: Generate coverage report
73+
run: |
74+
coverage report -m
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Unit Tests for Training Sandbox
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
test:
13+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}
14+
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest ]
19+
python-version: [ '3.10' ]
20+
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Cleanup disk space before pulling images
32+
run: |
33+
echo "Before cleanup:"
34+
df -h
35+
36+
sudo apt-get clean
37+
sudo rm -rf /var/lib/apt/lists/*
38+
39+
docker system prune -af || true
40+
docker volume prune -f || true
41+
42+
pip cache purge || true
43+
44+
rm -rf /tmp/* || true
45+
46+
echo "After cleanup:"
47+
df -h
48+
49+
- name: Pull Docker images
50+
run: |
51+
DOCKER_IMAGES=(
52+
"agentscope/runtime-sandbox-bfcl:latest"
53+
"agentscope/runtime-sandbox-appworld:latest"
54+
)
55+
56+
for img in "${DOCKER_IMAGES[@]}"; do
57+
echo "Pulling image: $img"
58+
docker pull "$img"
59+
done
60+
echo "All Docker images pulled successfully."
61+
62+
- name: Cache pip dependencies
63+
uses: actions/cache@v4
64+
with:
65+
path: ~/.cache/pip
66+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
67+
restore-keys: |
68+
${{ runner.os }}-pip-
69+
70+
- name: Update setuptools
71+
run: |
72+
pip install --upgrade pip
73+
pip install setuptools==78.1.1 wheel==0.45.1
74+
75+
- name: Set PYTHONPATH
76+
run: |
77+
echo "PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/src" >> $GITHUB_ENV
78+
79+
- name: Install dependencies
80+
run: |
81+
export PIP_DEFAULT_TIMEOUT=300
82+
pip install -q -e ".[dev]"
83+
84+
- name: Run tests with coverage
85+
run: |
86+
coverage run -m pytest tests/sandbox/test_sandbox_appworld.py tests/sandbox/test_sandbox_bfcl.py
87+
88+
- name: Generate coverage report
89+
run: |
90+
coverage report -m

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ dev = [
5050
"pytest-cov>=6.2.1",
5151
"fakeredis>=2.31.0",
5252
"sphinx-autoapi>=3.6.0",
53+
"pytest-mock>=3.15.1",
5354
]
5455

5556
langgraph = [
5657
"langgraph>=0.5.3",
5758
]
5859

5960
agno = [
60-
"agno>=1.7.5,<2.0.0",
61+
"agno>=2.0.0",
6162
]
6263
autogen = [
6364
"autogen-agentchat>=0.7.4",
@@ -111,4 +112,4 @@ deployment = [
111112
"shortuuid>=1.0.13",
112113
"PyYAML",
113114
"oss2>=2.19.1"
114-
]
115+
]

src/agentscope_runtime/engine/services/tablestore_memory_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(
5151
self,
5252
tablestore_client: AsyncTablestoreClient,
5353
search_strategy: SearchStrategy = SearchStrategy.FULL_TEXT,
54-
embedding_model: Optional[Embeddings] = DashScopeEmbeddings(),
54+
embedding_model: Optional[Embeddings] = None,
5555
vector_dimension: int = 1536,
5656
table_name: Optional[str] = "agentscope_runtime_memory",
5757
search_index_schema: Optional[List[tablestore.FieldSchema]] = (
@@ -63,6 +63,9 @@ def __init__(
6363
vector_metric_type: VectorMetricType = VectorMetricType.VM_COSINE,
6464
**kwargs: Any,
6565
):
66+
if embedding_model is None:
67+
embedding_model = DashScopeEmbeddings()
68+
6669
self._search_strategy = search_strategy
6770
self._embedding_model = (
6871
embedding_model # the parameter is None, don't store vector.

src/agentscope_runtime/sandbox/box/training_box/training_box.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -300,45 +300,3 @@ def __init__(
300300
bearer_token,
301301
sandbox_type,
302302
)
303-
304-
305-
@SandboxRegistry.register(
306-
build_image_uri("runtime-sandbox-webshop", arm64_compatible=False),
307-
sandbox_type=SandboxType.WEBSHOP,
308-
runtime_config={"shm_size": "5.06gb"},
309-
security_level="medium",
310-
timeout=30,
311-
description="webshop Sandbox",
312-
)
313-
class WebShopSandbox(TrainingSandbox):
314-
"""
315-
Training Sandbox class for managing and executing training-related tasks.
316-
317-
This class provides methods to create, manage, and interact with
318-
training environment instances using specialized tool calls.
319-
"""
320-
321-
def __init__(
322-
self,
323-
sandbox_id: Optional[str] = None,
324-
timeout: int = 3000,
325-
base_url: Optional[str] = None,
326-
bearer_token: Optional[str] = None,
327-
sandbox_type: SandboxType = SandboxType.WEBSHOP,
328-
):
329-
"""
330-
Initialize the Training Sandbox.
331-
332-
Args:
333-
sandbox_id (Optional[str]): Unique identifier for the sandbox.
334-
timeout (int): Maximum time allowed for sandbox operations.
335-
base_url (Optional[str]): Base URL for sandbox API.
336-
bearer_token (Optional[str]): Authentication token for API access.
337-
"""
338-
super().__init__(
339-
sandbox_id,
340-
timeout,
341-
base_url,
342-
bearer_token,
343-
sandbox_type,
344-
)

src/agentscope_runtime/sandbox/enums.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ class SandboxType(DynamicEnum):
6868
GUI = "gui"
6969
APPWORLD = "appworld"
7070
BFCL = "bfcl"
71-
WEBSHOP = "webshop"

0 commit comments

Comments
 (0)