From 2e1a54089aa3120567d30bc0d1f416488dfde727 Mon Sep 17 00:00:00 2001 From: Spenser Gilliland Date: Wed, 6 May 2020 09:02:54 -0700 Subject: [PATCH] add: sima version information --- Jenkinsfile | 34 ++++++++++++++++++++++++---------- docker/Dockerfile | 12 +----------- python/MANIFEST.in | 1 + python/VERSION.in | 3 +++ python/setup.py | 38 ++++++++++++++++++++++++++++++++++++-- python/tvm/.gitignore | 1 + 6 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 python/MANIFEST.in create mode 100644 python/VERSION.in create mode 100644 python/tvm/.gitignore diff --git a/Jenkinsfile b/Jenkinsfile index 4679844b7e77..fed01ffaf724 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,12 +3,14 @@ library('sima-jenkins-lib') def main() { def job_name = env.JOB_NAME.split('/')[1] - def currentBranchName = env.CHANGE_ID ? env.CHANGE_BRANCH : env.BRANCH_NAME properties([ parameters([ - string(name: "COPY_MLA_BRANCH_PKG", defaultValue: currentBranchName, description: 'Copy specified mla pkg'), - string(name: "COPY_N2A_COMPILER_BRANCH_PKG", defaultValue: currentBranchName, description: 'Copy specified n2a_compiler pkg') + booleanParam( + name: 'SKIP_N2A_COMPILER_BUILD', + description: 'Skips building n2a_compiler', + defaultValue: false + ) ]), ]) @@ -20,9 +22,6 @@ def main() { def image stage("DockerBuild") { image = utils.dockerBuild("docker/Dockerfile", 'simaai/' + job_name, "docker_creds", "docker_build.log", { -> - utils.getPackage('sima-ai','mla', params.COPY_MLA_BRANCH_PKG, '*.deb') - utils.getPackage('sima-ai','n2a_compiler', params.COPY_N2A_COMPILER_BRANCH_PKG, '*.whl') - sh "ls -alh" }) } @@ -34,12 +33,14 @@ def main() { image["image"].inside("-m 32g -c 8") { utils.cmakeBuild("build", "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", {}, { src_dir -> stage("Python Bindings") { - sh """#!/bin/bash -ex -cd .. -make cython -cd python + dir("../python") { + utils.setPythonBuildEnv([]) { + sh """#!/bin/bash -ex +rm -rf dist build python3 setup.py bdist_wheel """ + } + } } }, "../sima-regres.cmake", "clean all") stage("Package") { @@ -48,9 +49,22 @@ python3 setup.py bdist_wheel } } } + + stage("Promotion") { + if (env.BRANCH_NAME=="sima") { + utils.docker_promote(image['image'], 'docker_creds', '') + } + } + + } + + stage("Upstream") { + utils.buildUpstream("n2a_compiler", params.SKIP_N2A_COMPILER_BUILD, []) } } utils.job_wrapper( { main() }) + +return this diff --git a/docker/Dockerfile b/docker/Dockerfile index 90c99483850b..7676ece12a58 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,7 @@ FROM simaai/ubuntu:latest ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get -y install \ build-essential ccache \ - wget curl awscli cmake unzip && \ + wget curl awscli cmake unzip git && \ rm -rf /var/lib/apt/lists/* RUN \ sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \ @@ -21,16 +21,6 @@ RUN \ -o /usr/local/share/ca-certificates/letsencryptx3.crt && \ update-ca-certificates -ARG MLA_BRANCH="master" -ARG MLA_VERSION="0.0.1" -ADD mla-${MLA_VERSION}-Linux.deb /tmp -RUN apt-get update && apt-get install -y /tmp/mla-${MLA_VERSION}-Linux.deb && rm -rf /var/lib/apt/lists/* - -ARG N2A_COMPILER_BRANCH="master" -ARG N2A_COMPILER_VERSION="0.0.1" -ADD sima_mlc-${N2A_COMPILER_VERSION}_${N2A_COMPILER_BRANCH}-py3-none-any.whl /tmp -RUN pip3 install /tmp/sima_mlc-${N2A_COMPILER_VERSION}_${N2A_COMPILER_BRANCH}-py3-none-any.whl - RUN apt-get update && \ apt-get install -y \ libopenblas-dev \ diff --git a/python/MANIFEST.in b/python/MANIFEST.in new file mode 100644 index 000000000000..b4b39b77b3ac --- /dev/null +++ b/python/MANIFEST.in @@ -0,0 +1 @@ +include VERSION.in diff --git a/python/VERSION.in b/python/VERSION.in new file mode 100644 index 000000000000..c5e7504d8b6d --- /dev/null +++ b/python/VERSION.in @@ -0,0 +1,3 @@ +major: 0 +minor: 1 +patch: 0 diff --git a/python/setup.py b/python/setup.py index 51ed04cdebf8..d4ee2457bffe 100644 --- a/python/setup.py +++ b/python/setup.py @@ -149,9 +149,43 @@ def get_package_data_files(): # Relay standard libraries return ['relay/std/prelude.rly', 'relay/std/core.rly'] +import yaml +import subprocess + +def get_version(pkg_dir, main_branch = "master"): + with open("VERSION.in") as fh: + vinfo = yaml.load(fh.read(), Loader=yaml.BaseLoader) + version = '.'.join([vinfo["major"], vinfo["minor"], vinfo["patch"]]) + + if 'GIT_HASH' in os.environ: + # In tox the .git directory is not available so do this instead + vinfo['git_hash'] = os.environ['GIT_HASH'] + else: + proc = subprocess.Popen(['git','log','-1','--format=%h'], stdout=subprocess.PIPE) + proc.wait() + if proc.returncode != 0: + raise RuntimeError("ERROR: unable to execute git log") + vinfo['git_hash'] = proc.stdout.read().decode('utf-8').rstrip() + + with open(pkg_dir + "/VERSION","w") as fh: + fh.write(yaml.dump(vinfo)) + + # This comes from Jenkins for upstream/downstream builds + if 'DEV_VERSION' in os.environ: + version = version + "+" + os.environ['DEV_VERSION'] + + return version + + +def get_package(env, pkg_name, pkg_version): + if env in os.environ and os.environ[env] != "latest": + return "%s==%s+%s" % (pkg_name, pkg_version, os.environ[env]) + else: + return "%s==%s" % (pkg_name, pkg_version) + setup(name='sima-tvm', - version=__version__, + version=get_version('tvm', 'sima'), description="TVM: An End to End Tensor IR/DSL Stack for Deep Learning Systems", zip_safe=False, install_requires=[ @@ -173,7 +207,7 @@ def get_package_data_files(): packages=find_packages(), package_dir={'tvm': 'tvm'}, - package_data={'tvm': get_package_data_files()}, + package_data={'tvm': get_package_data_files() + ["VERSION"]}, distclass=BinaryDistribution, url='https://github.com/apache/incubator-tvm', ext_modules=config_cython(), diff --git a/python/tvm/.gitignore b/python/tvm/.gitignore new file mode 100644 index 000000000000..fd85e3040821 --- /dev/null +++ b/python/tvm/.gitignore @@ -0,0 +1 @@ +VERSION