[GitHub] marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, revamp ci scripts and dockerfiles, integrate IoT builds

2018-03-01 Thread GitBox
marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, 
revamp ci scripts and dockerfiles, integrate IoT builds
URL: https://github.com/apache/incubator-mxnet/pull/9943#discussion_r171605100
 
 

 ##
 File path: ci/build_functions.sh
 ##
 @@ -0,0 +1,254 @@
+#!/bin/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.
+
+# build and install are separated so changes to build don't invalidate
+# the whole docker cache for the image
+
+set -ex
+
+clean_repo() {
+set -ex
+git clean -xfd
+git submodule foreach --recursive git clean -xfd
+git reset --hard
+git submodule foreach --recursive git reset --hard
+git submodule update --init --recursive
+}
+
+
+# Build commands: Every platform in docker/Dockerfile.build. should 
have a corresponding
+# function here with the same suffix:
+
+build_jetson() {
+set -ex
+pushd .
+cd /work/build
+cmake\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=OFF\
+-DUSE_OPENMP=ON\
+-DUSE_SIGNAL_HANDLER=ON\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-DUSE_LAPACK=OFF\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-G Ninja /work/mxnet
+ninja
+export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
+cd /work/mxnet/python
+python setup.py bdist_wheel --universal
+cp dist/*.whl /work/build
+popd
+}
+
+build_armv7() {
+set -ex
+pushd .
+cd /work/build
+cmake\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=OFF\
+-DUSE_OPENMP=OFF\
+-DUSE_SIGNAL_HANDLER=ON\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-G Ninja /work/mxnet
+ninja
+export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
+cd /work/mxnet/python
+python setup.py bdist_wheel --universal
+cp dist/*.whl /work/build
+popd
+}
+
+build_ubuntu_cpu() {
+set -ex
+pushd .
+cd /work/build
+cmake\
+-DUSE_CPP_PACKAGE=ON\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=ON\
+-DUSE_OPENMP=ON\
+-DUSE_SIGNAL_HANDLER=ON\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-G Ninja /work/mxnet
+ninja
+popd
+}
+
+test_ubuntu_cpu_python2() {
+set -ex
+pushd .
+export MXNET_LIBRARY_PATH=/work/build/libmxnet.so
+
+VENV=mxnet_py2_venv
+virtualenv -p `which python2` $VENV
+source $VENV/bin/activate
+pip install nose nose-timer
+
+cd /work/mxnet/python
+pip install -e .
+cd /work/mxnet
+python -m "nose" --with-timer --verbose tests/python/unittest
+popd
+}
+
+test_ubuntu_cpu_python3() {
+set -ex
+pushd .
+export MXNET_LIBRARY_PATH=/work/build/libmxnet.so
+VENV=mxnet_py3_venv
+virtualenv -p `which python3` $VENV
+source $VENV/bin/activate
+
+cd /work/mxnet/python
+pip3 install nose nose-timer
+pip3 install -e .
+cd /work/mxnet
+python3 -m "nose" --with-timer --verbose tests/python/unittest
+
+popd
+}
+
+build_amzn_linux_cpu() {
+cd /work/build
+cmake\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=ON\
+-DUSE_OPENMP=ON\
+-DUSE_SIGNAL_HANDLER=ON\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-DUSE_LAPACK=OFF\
+-G Ninja /work/mxnet
+ninja
+export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
+}
+
+build_arm64() {
+cmake\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=OFF\
+-DUSE_OPENMP=OFF\
+-DUSE_SIGNAL_HANDLER=ON\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-G Ninja /work/mxnet
+ninja
+export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
+cd /work/mxnet/python
+python setup.py bdist_wheel --universal
+cp dist/*.whl /work/build
+}
+
+build_android_arm64() {
+set -ex
+cd /work/build
+cmake\
+-DUSE_CUDA=OFF\
+-DUSE_OPENCV=OFF\
+-DUSE_OPENMP=OFF\
+-DUSE_SIGNAL_HANDLER=ON\
+-DCMAKE_BUILD_TYPE=RelWithDebInfo\
+-DUSE_MKL_IF_AVAILABLE=OFF\
+-G Ninja /work/mxnet
+ninja
+export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
+cd /work/mxnet/python
+python setup.py bdist_wheel --universal
+cp dist/*.whl /work/build
+
+
+}
+

[GitHub] marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, revamp ci scripts and dockerfiles, integrate IoT builds

2018-03-01 Thread GitBox
marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, 
revamp ci scripts and dockerfiles, integrate IoT builds
URL: https://github.com/apache/incubator-mxnet/pull/9943#discussion_r171604671
 
 

 ##
 File path: ci/build_functions.sh
 ##
 @@ -0,0 +1,254 @@
+#!/bin/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.
+
+# build and install are separated so changes to build don't invalidate
+# the whole docker cache for the image
+
+set -ex
+
+clean_repo() {
 
 Review comment:
   It shouldn't since the container is running as restricted user


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, revamp ci scripts and dockerfiles, integrate IoT builds

2018-03-01 Thread GitBox
marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, 
revamp ci scripts and dockerfiles, integrate IoT builds
URL: https://github.com/apache/incubator-mxnet/pull/9943#discussion_r171600359
 
 

 ##
 File path: ci/build.py
 ##
 @@ -0,0 +1,181 @@
+#!/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.
+
+"""Multi arch dockerized build tool.
+
+"""
+
+__author__ = 'Marco de Abreu, Kellen Sunderland, Anton Chernov, Pedro Larroy'
+__version__ = '0.1'
+
+import os
+import sys
+import subprocess
+import logging
+import argparse
+from subprocess import check_call, call
+import glob
+import re
+from typing import *
+from itertools import chain
+from copy import deepcopy
+
+
+
+def get_platforms(path: Optional[str]="docker"):
+"""Get a list of architectures given our dockerfiles"""
+dockerfiles = glob.glob(os.path.join(path, "Dockerfile.build.*"))
+dockerfiles = list(filter(lambda x: x[-1] != '~', dockerfiles))
+files = list(map(lambda x: re.sub(r"Dockerfile.build.(.*)", r"\1", x), 
dockerfiles))
+files.sort()
+platforms = list(map(lambda x: os.path.split(x)[1], files))
+return platforms
+
+
+def get_docker_tag(platform: str) -> None:
+return "mxnet/build.{0}".format(platform)
+
+
+def get_dockerfile(platform: str, path="docker"):
+return os.path.join(path, "Dockerfile.build.{0}".format(platform))
+
+def get_docker_binary(use_nvidia_docker: bool):
+if use_nvidia_docker:
+return "nvidia-docker"
+else:
+return "docker"
+
+def build_docker(platform: str, docker_binary: str) -> None:
+"""Build a container for the given platform"""
+tag = get_docker_tag(platform)
+logging.info("Building container tagged '%s' with %s", tag, docker_binary)
+cmd = [docker_binary, "build",
+"-f", get_dockerfile(platform),
+"-t", tag,
+"."]
+logging.info("Running command: '%s'", ' '.join(cmd))
+check_call(cmd)
+
+def get_mxnet_root() -> str:
+curpath = os.path.abspath(os.path.dirname(__file__))
+def is_mxnet_root(path: str) -> bool:
+return os.path.exists(os.path.join(path, ".mxnet_root"))
+while not is_mxnet_root(curpath):
+parent = os.path.abspath(os.path.join(curpath, os.pardir))
+if parent == curpath:
+raise RuntimeError("Got to the root and couldn't find a parent 
folder with .mxnet_root")
+curpath = parent
+return curpath
+
+
+def container_run(platform: str, docker_binary: str, command: List[str]) -> 
None:
+tag = get_docker_tag(platform)
+mx_root = get_mxnet_root()
+local_build_folder = '{}/build_{}'.format(mx_root, platform)
+# We need to create it first, otherwise it will be created by the docker 
daemon with root only permissions
+os.makedirs(local_build_folder, exist_ok=True)
+logging.info("Running %s in container %s", command, tag)
+runlist = [docker_binary, 'run', '--rm',
 
 Review comment:
   Added, thanks


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, revamp ci scripts and dockerfiles, integrate IoT builds

2018-03-01 Thread GitBox
marcoabreu commented on a change in pull request #9943: [Don't MERGE] CI 2.0, 
revamp ci scripts and dockerfiles, integrate IoT builds
URL: https://github.com/apache/incubator-mxnet/pull/9943#discussion_r171594544
 
 

 ##
 File path: ci/build.py
 ##
 @@ -0,0 +1,181 @@
+#!/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.
+
+"""Multi arch dockerized build tool.
+
+"""
+
+__author__ = 'Marco de Abreu, Kellen Sunderland, Anton Chernov, Pedro Larroy'
+__version__ = '0.1'
+
+import os
+import sys
+import subprocess
+import logging
+import argparse
+from subprocess import check_call, call
+import glob
+import re
+from typing import *
+from itertools import chain
+from copy import deepcopy
+
+
+
+def get_platforms(path: Optional[str]="docker"):
+"""Get a list of architectures given our dockerfiles"""
+dockerfiles = glob.glob(os.path.join(path, "Dockerfile.build.*"))
+dockerfiles = list(filter(lambda x: x[-1] != '~', dockerfiles))
+files = list(map(lambda x: re.sub(r"Dockerfile.build.(.*)", r"\1", x), 
dockerfiles))
+files.sort()
+platforms = list(map(lambda x: os.path.split(x)[1], files))
+return platforms
+
+
+def get_docker_tag(platform: str) -> None:
+return "mxnet/build.{0}".format(platform)
+
+
+def get_dockerfile(platform: str, path="docker"):
+return os.path.join(path, "Dockerfile.build.{0}".format(platform))
+
+def get_docker_binary(use_nvidia_docker: bool):
+if use_nvidia_docker:
+return "nvidia-docker"
+else:
+return "docker"
 
 Review comment:
   No, it's not available on instances without GPUs


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services