[ 
https://issues.apache.org/jira/browse/MXNET-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16392435#comment-16392435
 ] 

ASF GitHub Bot commented on MXNET-42:
-------------------------------------

szha commented on a change in pull request #9995: [WIP] CI docker revamp; Add 
Jetson, Raspberry and CentOS 7 build [MXNET-42][MXNET-43][MXNET-44][MXNET-57]
URL: https://github.com/apache/incubator-mxnet/pull/9995#discussion_r173367713
 
 

 ##########
 File path: ci/build.py
 ##########
 @@ -0,0 +1,182 @@
+#!/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),
+        "--build-arg", "USER_ID={}".format(os.getuid()),
+        "-t", tag,
+        "docker"]
+    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)
+    local_build_folder = '{}/build'.format(mx_root)
+    # 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',
+        #'-v', "{}:/work/mxnet:ro".format(mx_root), # mount mxnet root
+        '-v', "{}:/work/mxnet".format(mx_root), # mount mxnet root
+        '-v', "{}:/work/build".format(local_build_folder), # mount mxnet/build 
for storing build artifacts
+        #'-w', '/work/build',
 
 Review comment:
   Clean up commented code.

----------------------------------------------------------------
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:
[email protected]


> Make CI failures locally reproducible
> -------------------------------------
>
>                 Key: MXNET-42
>                 URL: https://issues.apache.org/jira/browse/MXNET-42
>             Project: Apache MXNet
>          Issue Type: Improvement
>            Reporter: Marco de Abreu
>            Assignee: Marco de Abreu
>            Priority: Major
>
> At the moment, it's hard to reproduce CI failures. Ideally, every failure 
> could be reproduced by executing a single command.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to