Skip to content

Commit 5393709

Browse files
authored
Add unit test and daily build (#41)
* Add unit test and daily build
1 parent 205d4cd commit 5393709

File tree

5 files changed

+69
-17
lines changed

5 files changed

+69
-17
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Daily Building Script Execution
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Runs at 1:00 AM every day
7+
- cron: '0 1 * * *'
8+
9+
jobs:
10+
run-shell-script:
11+
runs-on: self-hosted
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Run shell script
18+
run: |
19+
tar_name=chatlearn-$(date +%F).tar.gz
20+
tar czvf /tmp/${tar_name} .
21+
ossutil64 -i ${{ secrets.OSS_AK_ID }} -k ${{ secrets.OSS_AK_SECRET }} -e ${{ secrets.OSS_ENDPOINT }} cp -r /tmp/${tar_name} ${{ secrets.OSS_BUCKET }}/regression/chatlearn/src/
22+

.github/workflows/pylint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10"]
14+
python-version: ["3.10"]
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/unit_test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Unit Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
tags:
10+
- v[0-9]+.[0-9]+.[0-9]+
11+
12+
13+
jobs:
14+
run-shell-script:
15+
runs-on: self-hosted
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Run unit test
22+
run: |
23+
docker pull $UT_IMAGE
24+
docker run -v $PWD:$PWD -w $PWD --net host --ipc host --shm-size 80G -t --rm --gpus all $UT_IMAGE bash -c 'make test'
25+
env:
26+
UT_IMAGE: ${{ secrets.UT_IMAGE }}

tests/run_tests.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#!/bin/bash
2-
set -exo pipefail
32
export PYTHONPATH=$(cd ../ && pwd):${PWD}:${PYTHONPATH}
43
CDIR="$(cd "$(dirname "$0")" ; pwd -P)"
54
LOGFILE=/tmp/pytorch_py_test.log
65
rm -rf core*
7-
MAX_GRAPH_SIZE=500
8-
GRAPH_CHECK_FREQUENCY=100
9-
VERBOSITY=2
106

117
[ -z "$MASTER_ADDR" ] && export MASTER_ADDR=localhost
128
[ -z "$WORLD_SIZE" ] && export WORLD_SIZE=1
@@ -34,12 +30,6 @@ do
3430
L)
3531
LOGFILE=
3632
;;
37-
M)
38-
MAX_GRAPH_SIZE=$OPTARG
39-
;;
40-
C)
41-
GRAPH_CHECK_FREQUENCY=$OPTARG
42-
;;
4333
V)
4434
VERBOSITY=$OPTARG
4535
;;
@@ -49,11 +39,25 @@ shift $(($OPTIND - 1))
4939

5040

5141
function run_test {
42+
attempts=0
43+
while [[ $attempts -lt 3 ]]; do
44+
rm -rf core*
45+
ray stop
46+
"$@"
47+
if [[ $? -eq 0 ]]; then
48+
echo "$@ success"
49+
break
50+
fi
51+
52+
attempts=$((attempts + 1))
53+
if [[ $attempts -lt 3 ]]; then
54+
echo "$file fail, retry ($attempts/3)..."
55+
else
56+
echo "$file fail, exit ..."
57+
exit 1
58+
fi
59+
done
5260
ray stop
53-
"$@"
54-
exit_code=$? ; echo "Exit code: $exit_code"
55-
ray stop
56-
echo $@
5761
}
5862

5963

tests/test_flat_tensors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def run_flat_tensors_test_with_constructor(self, constructor):
2020

2121
measure1 = torch.cuda.memory_allocated()
2222
# Randomly generate some tensors.
23-
n = 64
23+
n = 4
2424
n_dims = [random.randint(1, 4) for _ in range(n)]
2525
shapes = [
26-
[random.randint(0, 1 << 8) for _ in range(dim)]
26+
[random.randint(0, 8) for _ in range(dim)]
2727
for dim in n_dims
2828
]
2929

0 commit comments

Comments
 (0)