Skip to content

Commit

Permalink
Add: mac pip publish ci & add aliyun docker push ci (#21)
Browse files Browse the repository at this point in the history
* add macos pip build

* fix ci

* fix ci

* format

* fix macos ut

* fix ut

* update
  • Loading branch information
oeqqwq authored Mar 11, 2024
1 parent 5514ef1 commit 4ba3bc5
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ build:avx --host_copt=-DCHECK_AVX
build --copt=-fPIC
build --copt=-fstack-protector-strong
build:linux --copt=-Wl,-z,noexecstack
build:macos --copt=-Wa,--noexecstack

test --keep_going
test --test_output=errors
Expand All @@ -44,3 +45,8 @@ build:linux --action_env=BAZEL_LINKLIBS=-l%:libstdc++.a:-l%:libgcc.a
# Bazel will automatic pick platform config since we have enable_platform_specific_config set
build:linux --copt=-fopenmp
build:linux --linkopt=-fopenmp
build:macos --copt="-Xpreprocessor -fopenmp"
build:macos --copt=-Wno-unused-command-line-argument
build:macos --features=-supports_dynamic_linker
build:macos --macos_minimum_os=12.0
build:macos --host_macos_minimum_os=12.0
49 changes: 48 additions & 1 deletion .circleci/continue-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
command: |
set +e
declare -i test_status
bazel test //secretflow_serving/... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors | tee test_result.log; test_status=${PIPESTATUS[0]}
bazel test //... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors | tee test_result.log; test_status=${PIPESTATUS[0]}
sh ../devtools/rename-junit-xml.sh
find bazel-bin/ -executable -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz
Expand Down Expand Up @@ -104,6 +104,52 @@ jobs:
- store_artifacts:
path: integration_test.log

macOS_lib_ut:
macos:
xcode: 15.1
resource_class: macos.m1.large.gen1
steps:
- checkout
- run:
name: Checkout devtools
command: git clone https://github.com/secretflow/devtools.git ../devtools
- run:
name: "Install homebrew dependencies"
command: brew install bazelisk cmake ninja libomp wget go md5sha1sum
- run:
name: "Install Miniconda"
command: |
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-MacOSX-arm64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
source $HOME/miniconda/bin/activate
conda init bash zsh
python3 -m pip install -r requirements.txt
python3 -m pip install -r .ci/requirements-ci.txt
- run:
name: Setup GCS
command: |
echo ${gcs_content} > ../gcs.data
../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
- run:
name: "build"
command: |
sh ./build_wheel_entrypoint.sh
- run:
name: "test"
command: |
set +e
declare -i test_status
# only test lib ut
bazel test //secretflow_serving_lib/... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors | tee test_result.log; test_status=${PIPESTATUS[0]}
sh ../devtools/rename-junit-xml.sh
find bazel-bin/ -executable -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz
find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz
exit ${test_status}
workflows:
unittest:
when: << pipeline.parameters.build-and-run >>
Expand All @@ -112,3 +158,4 @@ workflows:
matrix:
parameters:
resource_class: ["2xlarge", "arm.2xlarge"]
- macOS_lib_ut
94 changes: 92 additions & 2 deletions .circleci/release-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,74 @@ jobs:
python3 -m twine upload -r pypi -u __token__ -p ${PYPI_TWINE_TOKEN} dist/*.whl
macOS_arm64_publish:
macos:
xcode: 15.1
resource_class: macos.m1.large.gen1
parameters:
python_ver:
type: string
steps:
- checkout
- run:
name: "Install homebrew dependencies"
command: |
brew install bazelisk cmake ninja libomp wget go
- run:
name: "Install Miniconda"
command: |
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-MacOSX-arm64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
source $HOME/miniconda/bin/activate
conda init zsh bash
- run:
name: "build package and publish"
command: |
set +e
conda create -n build python=<< parameters.python_ver >> -y
conda activate build
sh ./build_wheel_entrypoint.sh
python3 -m pip install twine
ls dist/*.whl
python3 -m twine upload -r pypi -u __token__ -p ${PYPI_TWINE_TOKEN} dist/*.whl
macOS_x64_publish:
macos:
xcode: 15.1
resource_class: macos.x86.medium.gen2
parameters:
python_ver:
type: string
steps:
- checkout
- run:
name: "Install homebrew dependencies"
command: |
brew install bazelisk cmake ninja nasm libomp wget go
- run:
name: "Install Miniconda"
command: |
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_22.11.1-1-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
source $HOME/miniconda/bin/activate
conda init zsh bash
- run:
name: "build package and publish"
command: |
set +e
conda create -n build python=<< parameters.python_ver >> -y
conda activate build
sh ./build_wheel_entrypoint.sh
python3 -m pip install twine
ls dist/*.whl
python3 -m twine upload -r pypi -u __token__ -p ${PYPI_TWINE_TOKEN} dist/*.whl
linux_x64_build_binary:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
Expand Down Expand Up @@ -162,6 +230,9 @@ jobs:
# login docker
docker login -u secretflow -p ${DOCKER_DEPLOY_TOKEN}
# login docker - aliyun
docker login -u ${ALIYUN_DOCKER_USERNAME} -p ${ALIYUN_DOCKER_PASSWORD} secretflow-registry.cn-hangzhou.cr.aliyuncs.com
ls /tmp/binary/linux/amd64/
ls /tmp/binary/linux/arm64/
Expand All @@ -178,11 +249,14 @@ jobs:
TAG=$(grep "version" /tmp/binary/linux/amd64/version.txt | awk -F'"' '{print $2}')
echo $TAG
docker buildx create --name serving-image-builder --platform linux/arm64,linux/amd64 --use
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow/serving:$TAG --push .
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow/serving-anolis8:$TAG --push .
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:$TAG --push .
if [[ $TAG =~ b[0-9]$ ]]; then
echo "tag and push latest image."
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow/serving:latest --push .
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow/serving-anolis8:latest --push .
docker buildx build --platform linux/arm64,linux/amd64 -t secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latest --push .
fi
# Invoke jobs via workflows
Expand All @@ -206,6 +280,22 @@ workflows:
filters:
tags:
only: /.*/
- macOS_x64_publish:
matrix:
parameters:
python_ver: ["3.8", "3.9", "3.10", "3.11"]
# This is mandatory to trigger a pipeline when pushing a tag
filters:
tags:
only: /.*/
- macOS_arm64_publish:
matrix:
parameters:
python_ver: ["3.8", "3.9", "3.10", "3.11"]
# This is mandatory to trigger a pipeline when pushing a tag
filters:
tags:
only: /.*/
- linux_x64_build_binary:
# This is mandatory to trigger a pipeline when pushing a tag
filters:
Expand Down
4 changes: 2 additions & 2 deletions secretflow_serving/feature_adapter/http_adapter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const std::vector<FieldType> kFieldTypes = {
FieldType::FIELD_DOUBLE, FieldType::FIELD_STRING, FieldType::FIELD_BOOL};
const std::vector<int32_t> kI32Values = {1, 2, 3};
const std::vector<int64_t> kI64Values = {4, 5, 6};
const std::vector<float> kFValues = {7.0f, 8.0f, 9.0f};
const std::vector<double> kDValues = {1.1d, 2.2d, 3.3d};
const std::vector<float> kFValues = {7.0F, 8.0F, 9.0F};
const std::vector<double> kDValues = {1.1, 2.2, 3.3};
const std::vector<std::string> kStrValues = {"a", "b", "c"};
const std::vector<bool> kBValues = {true, false, true};
} // namespace
Expand Down
2 changes: 1 addition & 1 deletion secretflow_serving/ops/dot_product.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ REGISTER_OP(DOT_PRODUCT, "0.0.2",
"DT_INT64, DT_FLOAT, DT_DOUBLE",
true, false)
.StringAttr("output_col_name", "Column name of partial y", false, false)
.DoubleAttr("intercept", "Value of model intercept", false, true, 0.0d)
.DoubleAttr("intercept", "Value of model intercept", false, true, 0.0)
.Input("features", "Input feature table")
.Output("partial_ys",
"The calculation results, they have a data type of `double`.");
Expand Down
4 changes: 2 additions & 2 deletions secretflow_serving/ops/node_def_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ TEST_F(NodeDefUtilTest, Works) {
{
float attr_f;
EXPECT_TRUE(GetNodeAttr(node_def, "attr_f", &attr_f));
EXPECT_EQ(attr_f, 3.0f);
EXPECT_EQ(attr_f, 3.0F);
}
{
double attr_d;
EXPECT_TRUE(GetNodeAttr(node_def, "attr_d", &attr_d));
EXPECT_EQ(attr_d, 4.0d);
EXPECT_EQ(attr_d, 4.0);
}
{
std::string attr_s;
Expand Down
8 changes: 4 additions & 4 deletions secretflow_serving/ops/op_factory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,17 @@ TEST_F(OpFactoryTest, WorksDefaultValue) {
.BoolAttr("attr_bs", "attr_bs_desc", true, true,
std::vector<bool>{true, false})
.DoubleAttr("attr_ds", "attr_ds_desc", true, true,
std::vector<double>{1.0d, 2.0d})
std::vector<double>{1.0, 2.0})
.FloatAttr("attr_fs", "attr_fs_desc", true, true,
std::vector<float>{1.1f, 2.2f})
std::vector<float>{1.1F, 2.2F})
.Int64Attr("attr_i64s", "attr_i64s_desc", true, true,
std::vector<int64_t>{3, 4})
.Int32Attr("attr_i32s", "attr_i32s_desc", true, true,
std::vector<int32_t>{1, 2})
.StringAttr("attr_s", "attr_s_desc", false, true, "s")
.BoolAttr("attr_b", "attr_b_desc", false, true, true)
.DoubleAttr("attr_d", "attr_d_desc", false, true, 0.13d)
.FloatAttr("attr_f", "attr_f_desc", false, true, 0.12f)
.DoubleAttr("attr_d", "attr_d_desc", false, true, 0.13)
.FloatAttr("attr_f", "attr_f_desc", false, true, 0.12F)
.Int64Attr("attr_i64", "attr_i64_desc", false, true, 1234)
.Int32Attr("attr_i32", "attr_i32_desc", false, true, 123)
.Input("input_1", "input_1_desc")
Expand Down
2 changes: 1 addition & 1 deletion secretflow_serving_lib/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# get ops
ops = serving.get_all_ops()
assert len(ops) == 3
assert len(ops) > 0

# get ops
op = serving.get_op("MERGE_Y")
Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ def has_ext_modules(self):

# Default Linux platform tag
plat_name = "manylinux2014_x86_64"
if platform.machine() == "aarch64":

if sys.platform == "darwin":
# Due to a bug in conda x64 python, platform tag has to be 10_16 for X64 wheel
if platform.machine() == "x86_64":
plat_name = "macosx_12_0_x86_64"
else:
plat_name = "macosx_12_0_arm64"
elif platform.machine() == "aarch64":
# Linux aarch64
plat_name = "manylinux_2_28_aarch64"

Expand Down

0 comments on commit 4ba3bc5

Please sign in to comment.