Skip to content

Commit bd739b0

Browse files
author
jiangxinglei
committed
test github action
1 parent d9890f9 commit bd739b0

File tree

4 files changed

+201
-19
lines changed

4 files changed

+201
-19
lines changed

.github/workflows/tn_build.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build Tensornet
2+
3+
on:
4+
push:
5+
branches:
6+
- test_tn_build
7+
8+
jobs:
9+
tn_build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: mamba-org/setup-micromamba@v1
13+
with:
14+
micromamba-version: '1.5.8-0'
15+
environment-file: config/tn_build.yaml
16+
init-shell: >-
17+
bash
18+
cache-downloads: true
19+
post-cleanup: 'none'
20+
- name: setup configs
21+
run: pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
22+
shell: micromamba-shell {0}
23+
- name: Run custom command in micromamba environment
24+
run: ./manager only-build
25+
shell: micromamba-shell {0}
26+

WORKSPACE

+11-19
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ http_archive(
88
sha256 = "69cd836f87b8c53506c4f706f655d423270f5a563b76dc1cfa60fbc3184185a3",
99
strip_prefix = "tensorflow-2.2.0",
1010
urls = [
11+
"https://maven.corp.mediav.com/nexus3/repository/raw-to-github/tensorflow/tensorflow/archive/v2.2.0.tar.gz",
1112
"https://github.com/tensorflow/tensorflow/archive/v2.2.0.tar.gz",
1213
],
1314
)
1415

15-
#http_archive(
16-
# name = "org_tensorflow",
17-
# sha256 = "2595a5c401521f20a2734c4e5d54120996f8391f00bb62a57267d930bce95350",
18-
# strip_prefix = "tensorflow-2.3.0",
19-
# urls = [
20-
# "https://github.com/tensorflow/tensorflow/archive/v2.3.0.tar.gz",
21-
# ],
22-
#)
23-
24-
# copy from @org_tensorflow/WORKSPACE
25-
# TensorFlow build depends on these dependencies.
2616
http_archive(
2717
name = "io_bazel_rules_closure",
2818
sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9",
@@ -36,10 +26,10 @@ http_archive(
3626
http_archive(
3727
name = "brpc",
3828
urls = [
29+
"https://maven.corp.mediav.com/nexus3/repository/raw-to-github/apache/incubator-brpc/archive/0.9.7.tar.gz",
3930
"https://github.com/apache/incubator-brpc/archive/0.9.7.tar.gz"
4031
],
41-
sha256 = "722cd342baf3b05189ca78ecf6c56ea6ffec22e62fc2938335e4e5bab545a49c",
42-
strip_prefix = "incubator-brpc-0.9.7",
32+
strip_prefix = "brpc-0.9.7",
4333
)
4434

4535
# depend by brpc
@@ -50,12 +40,14 @@ http_archive(
5040
url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"
5141
)
5242

53-
git_repository(
54-
name = "com_github_nelhage_rules_boost",
55-
commit = "fe9a0795e909f10f2bfb6bfa4a51e66641e36557",
56-
remote = "https://github.com/nelhage/rules_boost",
57-
shallow_since = "1570056263 -0700",
58-
)
43+
http_archive(
44+
name = "com_github_nelhage_rules_boost",
45+
urls = [
46+
"https://maven.corp.mediav.com/nexus3/repository/raw-to-github/nelhage/rules_boost/archive/fe9a0795e909f10f2bfb6bfa4a51e66641e36557.tar.gz"
47+
"https://github.com/nelhage/rules_boost/archive/fe9a0795e909f10f2bfb6bfa4a51e66641e36557.tar.gz",
48+
],
49+
strip_prefix = "rules_boost-fe9a0795e909f10f2bfb6bfa4a51e66641e36557",
50+
)
5951

6052
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
6153
boost_deps()

config/tn_build.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: tn_build
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.7
6+
- nomkl
7+
- bazel==3.1.0
8+
- openmpi==4.1.3
9+
- openssl==1.1.1t
10+
- libxcrypt==4.4.28
11+
- gcc==10.3.0
12+
- gxx==10.3.0
13+
- libstdcxx-devel_linux-64==10.3.0
14+
- openjdk==8.0.382
15+
- patch
16+
- pip
17+
- pip:
18+
- tensorflow==2.2.0
19+
- protobuf<3.21
20+
- grpcio<1.47 # Only for CentOS 6
21+
- h5py<3.8 # Only for CentOS 6
22+
- twine

manager

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/env bash
2+
3+
[[ ${DEBUG-} != true ]] || set -x
4+
5+
readonly WORKSPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
readonly TN_BUILD_ENV_NAME=tn_build
7+
8+
export MAMBA_EXE=${HOME}/.local/bin/micromamba
9+
export MAMBA_ROOT_PREFIX=${HOME}/micromamba
10+
11+
die() {
12+
local err=$? err_fmt=
13+
(( err )) && err_fmt=" (err=$err)" || err=1
14+
printf >&2 "[ERROR]$err_fmt %s\n" "$*"
15+
exit $err
16+
}
17+
18+
_prepare_mamba_env(){
19+
if ! type micromamba >/dev/null 2>&1;then
20+
# /bin/sh -c 'eval "$1";r micromamba=1.5.8-0' https://p.qihoo.net/add 'r()(r=$(curl -sf "$0")||r=$(wget -qO- "$0")||/dev/null/ERR-DOWNLOAD;eval "$r")'
21+
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
22+
fi
23+
_mamba_source
24+
micromamba create -y -f ${WORKSPACE_DIR}/config/${TN_BUILD_ENV_NAME}.yaml
25+
micromamba activate ${TN_BUILD_ENV_NAME}
26+
}
27+
28+
_mamba_source() {
29+
[[ -e ${MAMBA_EXE} ]] || { echo "no micromamba exe found, run ./manager prepare_build_env to create env"; exit 1}
30+
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
31+
if [ $? -eq 0 ]; then
32+
eval "$__mamba_setup"
33+
else
34+
alias micromamba="$MAMBA_EXE" # Fallback on help from mamba activate
35+
fi
36+
unset __mamba_setup
37+
}
38+
39+
_activate_env() {
40+
_mamba_source
41+
#source ~/.bashrc
42+
micromamba activate ${TN_BUILD_ENV_NAME}
43+
}
44+
45+
_prepare_compile_env() {
46+
CUR_ENV_PATH=$(ompi_info --parsable --path prefix 2>/dev/null | awk -F":" '{print $NF}')
47+
export C_INCLUDE_PATH=${CUR_ENV_PATH}/include
48+
export CPLUS_INCLUDE_PATH=${CUR_ENV_PATH}/include
49+
}
50+
51+
_build_config(){
52+
CUR_ENV_PATH=$(ompi_info --parsable --path prefix 2>/dev/null | awk -F":" '{print $NF}')
53+
cd ${WORKSPACE_DIR}; bash configure.sh --openmpi_path ${CUR_ENV_PATH}
54+
_prepare_compile_env
55+
}
56+
57+
start_build(){
58+
_prepare_mamba_env
59+
_build_config
60+
extra_opts=("$@")
61+
bazel clean --expunge
62+
[[ ${DEBUG-} != true ]] || extra_opts+=(--sandbox-debug)
63+
bazel build "$@" -c opt //core:_pywrap_tn.so
64+
}
65+
66+
67+
only_build(){
68+
_prepare_compile_env
69+
extra_opts=("$@")
70+
[[ ${DEBUG-} != true ]] || extra_opts+=(--sandbox-debug)
71+
bazel build "$@" -c opt //core:_pywrap_tn.so
72+
}
73+
74+
75+
start_copy_libs(){
76+
rm -f tensornet/core/_pywrap_tn.so || true
77+
cp bazel-bin/core/_pywrap_tn.so tensornet/core/_pywrap_tn.so
78+
}
79+
80+
start_test(){
81+
python -c "import tensorflow as tf;import tensornet as tn;tn.core.init()"
82+
}
83+
84+
85+
start_only_upload(){
86+
export TWINE_USERNAME=${TWINE_USERNAME:=${NEXUS3_USERNAME}}
87+
export TWINE_PASSWORD=${TWINE_PASSWORD:=${NEXUS3_PASSWORD}}
88+
if [[ -z "$TWINE_USERNAME" || -z "$TWINE_PASSWORD" ]];then
89+
echo "need username/password auth, no env "
90+
echo "export NEXUS3_USERNAME=xxxx"
91+
echo "export NEXUS3_PASSWORD=xxxx"
92+
exit 0
93+
fi
94+
twine upload --verbose --repository-url http://maven.corp.mediav.com/nexus3/repository/pypi-host/ dist/*
95+
}
96+
97+
98+
start_upload(){
99+
_prepare_mamba_env
100+
rm -rf dist/* || true
101+
start_copy_libs
102+
[[ $# > 0 ]] && export TN_VERSION=$1
103+
python setup.py sdist
104+
start_only_upload
105+
}
106+
107+
case "$1" in
108+
(prepare_build_env)
109+
_prepare_mamba_env
110+
;;
111+
(build)
112+
shift 1
113+
start_build "$@"
114+
;;
115+
(only-build)
116+
shift 1
117+
only_build "$@"
118+
;;
119+
(deploy)
120+
shfit 1
121+
start_upload "$@"
122+
;;
123+
(copy-libs)
124+
start_copy_libs
125+
;;
126+
(help)
127+
cmd=$(basename -- "$0")
128+
cat <<-END
129+
Usage:
130+
$cmd help - Print this help.
131+
132+
$cmd prepare_build_env - install micromamba environment.
133+
134+
$cmd build [args..] - Build tn so file.
135+
136+
$cmd only-build [args..] - Build tn so file without config mpi
137+
138+
$cmd deploy - deploy tn to pypi
139+
END
140+
;;
141+
(*) die Unknown command "$1" ;;
142+
esac

0 commit comments

Comments
 (0)