Skip to content

Commit 818d8cb

Browse files
authored
Add a script build.sh to build three pip packages (elasticdl/elasticdl_preprocessing/elasticdl_client) (#2093)
* Modify the tile of building models with structured data using ElasticDL * Build wheel files using docker * Format shell scripts * Format shell command * Move go unittests into unit_test.sh * Fix permission to execute shell * Fix by comments * Fix shell * fix shell syntax * fix shell syntax * Fix the shell file name * Fix go unitttest * Split build_and_test to 2 scripts * Split build_and_test to 2 scripts * Set -e for unit_test.sh * Fix by comments
1 parent 56610c3 commit 818d8cb

File tree

4 files changed

+78
-33
lines changed

4 files changed

+78
-33
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ jobs:
5656
-v $HOME/.kube:/root/.kube
5757
-v $HOME/.minikube:/home/$USER/.minikube
5858
-v $PWD:/work -w /work
59-
elasticdl:dev bash -c "K8S_TESTS=True scripts/build_and_test.sh"
59+
elasticdl:dev
60+
bash -c "K8S_TESTS=True scripts/build_and_test.sh"
6061
# Report code coverage to https://codecov.io
6162
- bash <(curl -s https://codecov.io/bash)
6263
# Run unit tests related to ODPS (skipped for pull requests from forks)

scripts/build.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# Copyright 2020 The ElasticDL Authors. All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
set -e
16+
17+
# Build elasticdl.org/elasticdl Go package
18+
GO_PROXY_CN=https://goproxy.cn
19+
GO_PROXY_ALIYUN=https://developer.aliyun.com/mirror/goproxy
20+
go env -w GOPROXY="$GO_PROXY_CN","$GO_PROXY_ALIYUN",direct
21+
22+
# NOTE: The following commands requires that the current working directory is
23+
# the source tree root.
24+
make -f elasticdl/Makefile
25+
26+
# TODO(QiJune): How about we put the go.mod file in elasticdl/elasticdl/go/ in
27+
# the Git repo, so we don't need to create it at building time?
28+
(
29+
cp -r elasticdl/go/ /tmp/elasticdl
30+
cd "$GOPATH"/pkg/mod/github.com/tensorflow
31+
go mod init github.com/tensorflow
32+
cd /tmp/elasticdl
33+
go mod init elasticdl.org/elasticdl
34+
go mod edit -replace \
35+
github.com/tensorflow="${GOPATH}"/pkg/mod/github.com/tensorflow
36+
go get -u -t k8s.io/[email protected]
37+
go mod tidy
38+
GOBIN=/tmp go install ./...
39+
)
40+
41+
# Create elasticdl_preprocessing package
42+
rm -rf ./build/lib
43+
python setup_preprocessing.py --quiet bdist_wheel --dist-dir ./build
44+
# Create elasticdl_client package
45+
rm -rf ./build/lib
46+
python setup_client.py --quiet bdist_wheel --dist-dir ./build
47+
# Create elasticdl package
48+
mkdir -p ./elasticdl/go/bin
49+
cp /tmp/elasticdl_ps ./elasticdl/go/bin/
50+
rm -rf ./build/lib
51+
python setup.py --quiet bdist_wheel --dist-dir ./build

scripts/build_and_test.sh

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
set -e
1615

17-
# Build elasticdl.org/elasticdl Go package
18-
GO_PROXY_CN=https://goproxy.cn
19-
GO_PROXY_ALIYUN=https://developer.aliyun.com/mirror/goproxy
20-
go env -w GOPROXY="$GO_PROXY_CN","$GO_PROXY_ALIYUN",direct
16+
set -e
2117

22-
# NOTE: The following commands requires that the current working directory is
23-
# the source tree root.
24-
make -f elasticdl/Makefile
18+
sh scripts/build.sh
2519

26-
# TODO(QiJune): How about we put the go.mod file in elasticdl/elasticdl/go/ in
27-
# the Git repo, so we don't need to create it at building time?
2820
(
29-
cp -r elasticdl/go/ /tmp/elasticdl
30-
cd "$GOPATH"/pkg/mod/github.com/tensorflow
31-
go mod init github.com/tensorflow
3221
cd /tmp/elasticdl
33-
go mod init elasticdl.org/elasticdl
34-
go mod edit -replace github.com/tensorflow="${GOPATH}"/pkg/mod/github.com/tensorflow
35-
go get -u -t k8s.io/[email protected]
36-
go mod tidy
37-
GOBIN=/tmp go install ./...
3822
go test -v -cover ./...
3923
)
4024

41-
# Run Python unittests
42-
pytest elasticdl/python/tests elasticdl_preprocessing/tests --cov=elasticdl/python --cov-report=xml
25+
pytest elasticdl/python/tests elasticdl_preprocessing/tests \
26+
--cov=elasticdl/python --cov-report=xml
4327
mkdir -p ./build
4428
mv coverage.xml ./build
45-
46-
# Create elasticdl_preprocessing package
47-
rm -rf ./build/lib
48-
python setup_preprocessing.py --quiet bdist_wheel --dist-dir ./build
49-
# Create elasticdl_client package
50-
rm -rf ./build/lib
51-
python setup_client.py --quiet bdist_wheel --dist-dir ./build
52-
# Create elasticdl package
53-
mkdir -p ./elasticdl/go/bin
54-
cp /tmp/elasticdl_ps ./elasticdl/go/bin/
55-
rm -rf ./build/lib
56-
python setup.py --quiet bdist_wheel --dist-dir ./build

scripts/docker_build_wheel.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2020 The ElasticDL Authors. All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
export BASE_IMAGE=tensorflow/tensorflow:2.1.0-py3
16+
17+
docker build --target dev -t elasticdl:dev -f elasticdl/docker/Dockerfile \
18+
--build-arg BASE_IMAGE="$BASE_IMAGE" .
19+
20+
docker run --rm -it --net=host -v "$PWD":/work -w /work elasticdl:dev \
21+
bash -c "scripts/build.sh"

0 commit comments

Comments
 (0)