This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e88a7b4
commit 97d3405
Showing
11 changed files
with
332 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// -*- mode: groovy -*- | ||
|
||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// Jenkins pipeline | ||
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/ | ||
|
||
// NOTE: | ||
// ci_utils and cd_utils are loaded by the originating Jenkins job, e.g. jenkins/Jenkinsfile_release_job | ||
|
||
def get_pipeline(mxnet_variant) { | ||
def node_type = mxnet_variant.startsWith('cu') ? NODE_LINUX_GPU : NODE_LINUX_CPU | ||
return cd_utils.generic_pipeline(mxnet_variant, this, node_type) | ||
} | ||
|
||
def get_environment(mxnet_variant) { | ||
def environment = "ubuntu_cpu" | ||
if (mxnet_variant.startsWith('cu')) { | ||
environment = "ubuntu_gpu_${mxnet_variant}".replace("mkl", "") | ||
} | ||
return environment | ||
} | ||
|
||
def build(mxnet_variant) { | ||
ws("workspace/python_pypi/${mxnet_variant}/${env.BUILD_NUMBER}") { | ||
ci_utils.init_git() | ||
cd_utils.restore_artifact(mxnet_variant, 'static') | ||
|
||
// create wheel file | ||
def environment = get_environment(mxnet_variant) | ||
def nvidia_docker = mxnet_variant.startsWith('cu') | ||
ci_utils.docker_run(environment, "cd_package_pypi ${mxnet_variant}", nvidia_docker, '500m', "RELEASE_BUILD='${env.RELEASE_BUILD}'") | ||
} | ||
} | ||
|
||
def test(mxnet_variant) { | ||
ws("workspace/python_pypi/${mxnet_variant}/${env.BUILD_NUMBER}") { | ||
// test wheel file | ||
def environment = get_environment(mxnet_variant) | ||
def nvidia_docker = mxnet_variant.startsWith('cu') | ||
ci_utils.docker_run(environment, "cd_integration_test_pypi python ${nvidia_docker}", nvidia_docker) | ||
ci_utils.docker_run(environment, "cd_integration_test_pypi python3 ${nvidia_docker}", nvidia_docker) | ||
} | ||
} | ||
|
||
def push(mxnet_variant) { | ||
ws("workspace/python_pypi/${mxnet_variant}/${env.BUILD_NUMBER}") { | ||
// publish package to pypi | ||
sh "./ci/docker/runtime_functions.sh cd_pypi_publish" | ||
} | ||
} | ||
|
||
return this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!--- Licensed to the Apache Software Foundation (ASF) under one --> | ||
<!--- or more contributor license agreements. See the NOTICE file --> | ||
<!--- distributed with this work for additional information --> | ||
<!--- regarding copyright ownership. The ASF licenses this file --> | ||
<!--- to you under the Apache License, Version 2.0 (the --> | ||
<!--- "License"); you may not use this file except in compliance --> | ||
<!--- with the License. You may obtain a copy of the License at --> | ||
|
||
<!--- http://www.apache.org/licenses/LICENSE-2.0 --> | ||
|
||
<!--- Unless required by applicable law or agreed to in writing, --> | ||
<!--- software distributed under the License is distributed on an --> | ||
<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --> | ||
<!--- KIND, either express or implied. See the License for the --> | ||
<!--- specific language governing permissions and limitations --> | ||
<!--- under the License. --> | ||
|
||
# PyPI CD Pipeline | ||
|
||
The Jenkins pipelines for continuous delivery of the PyPI MXNet packages. | ||
The pipelines for each variant are run, and fail, independently. Each depends | ||
on a successful build of the statically linked libmxet library. | ||
|
||
The pipeline relies on the scripts and resources located in [tools/pip](https://github.com/apache/incubator-mxnet/tree/master/tools/pip) | ||
to build the PyPI packages. | ||
|
||
## Credentials | ||
|
||
The pipeline depends on the following environment variables in order to successfully | ||
retrieve the credentials for the PyPI account: | ||
|
||
* CD_PYPI_SECRET_NAME | ||
* DOCKERHUB_SECRET_ENDPOINT_URL | ||
* DOCKERHUB_SECRET_ENDPOINT_REGION | ||
|
||
The credentials are stored in the Secrets Manager of the AWS account hosting Jenkins. | ||
The [pypi_publish.py](pypi_publish.sh) script is in charge of retrieving the credentials. | ||
|
||
## Mock publishing | ||
|
||
Because of space limitations on PyPI, we don't want to push test packages from Jenkins Dev | ||
everytime the pipeline is run. Therefore, the [pypi_publish.sh](pypi_publish.sh) | ||
script will fake publishing packages if the `username` is *skipPublish*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
set -ex | ||
|
||
# variant = cpu, mkl, cu80, cu80mkl, cu100, etc. | ||
export mxnet_variant=${1:?"Please specify the mxnet variant"} | ||
|
||
# Due to this PR: https://github.com/apache/incubator-mxnet/pull/14899 | ||
# The setup.py expects that mkldnn_version.h be present in | ||
# mxnet-build/3rdparty/mkldnn/build/install/include | ||
# The artifact repository stores this file in the dependencies | ||
# and CD unpacks it to a directory called cd_misc | ||
if [ -f "cd_misc/mkldnn_version.h" ]; then | ||
mkdir -p 3rdparty/mkldnn/build/install/include | ||
cp cd_misc/mkldnn_version.h 3rdparty/mkldnn/build/install/include/. | ||
fi | ||
|
||
# Create wheel workspace | ||
rm -rf wheel_build | ||
mkdir wheel_build | ||
cd wheel_build | ||
|
||
# Setup workspace | ||
# setup.py expects mxnet-build to be the | ||
# mxnet directory | ||
ln -s ../. mxnet-build | ||
|
||
# Copy the setup.py and other package resources | ||
cp -R ../tools/pip/* . | ||
|
||
# Remove comment lines from pip doc files | ||
pushd doc | ||
for file in $(ls); do | ||
sed -i '/<!--/d' ${file} | ||
done | ||
popd | ||
|
||
echo "Building python package with environment:" | ||
printenv | ||
echo "-----------------------------------------" | ||
|
||
# Build wheel file - placed in wheel_build/dist | ||
python setup.py bdist_wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import json | ||
import logging | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
import boto3 | ||
from botocore.exceptions import ClientError | ||
|
||
|
||
def post_wheel(path): | ||
""" | ||
Posts mxnet wheel file to PyPI | ||
""" | ||
logging.info('Posting {} to PyPI'.format(path)) | ||
pypi_credentials = get_secret() | ||
|
||
cmd = 'python3 -m twine upload --username {} --password {} {}'.format( | ||
pypi_credentials['username'], | ||
pypi_credentials['password'], | ||
path) | ||
|
||
# The PyPI credentials for DEV has username set to 'skipPublish' | ||
# This way we do not attempt to publish the PyPI package | ||
# Just print a helpful message | ||
if pypi_credentials['username'] == 'skipPublish': | ||
print('In DEV account, skipping publish') | ||
print('Would have run: {}'.format(cmd)) | ||
return 0 | ||
else: | ||
# DO NOT PRINT CMD IN THIS BLOCK, includes password | ||
p = subprocess.run(cmd.split(' '), | ||
stdout=subprocess.PIPE) | ||
logging.info(p.stdout) | ||
return p.returncode | ||
|
||
def get_secret(): | ||
secret_name = os.environ['CD_PYPI_SECRET_NAME'] | ||
endpoint_url = os.environ['DOCKERHUB_SECRET_ENDPOINT_URL'] | ||
region_name = os.environ['DOCKERHUB_SECRET_ENDPOINT_REGION'] | ||
|
||
session = boto3.Session() | ||
client = session.client( | ||
service_name='secretsmanager', | ||
region_name=region_name, | ||
endpoint_url=endpoint_url | ||
) | ||
|
||
try: | ||
get_secret_value_response = client.get_secret_value(SecretId=secret_name) | ||
except ClientError as e: | ||
if e.response['Error']['Code'] == 'DecryptionFailureException': | ||
raise e | ||
elif e.response['Error']['Code'] == 'InternalServiceErrorException': | ||
raise e | ||
elif e.response['Error']['Code'] == 'InvalidParameterException': | ||
raise e | ||
elif e.response['Error']['Code'] == 'InvalidRequestException': | ||
raise e | ||
elif e.response['Error']['Code'] == 'ResourceNotFoundException': | ||
raise e | ||
else: | ||
return json.loads(get_secret_value_response['SecretString']) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(post_wheel(sys.argv[1])) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.