marcoabreu commented on a change in pull request #13202: Tool to ease 
compilation and reproduction of test results
URL: https://github.com/apache/incubator-mxnet/pull/13202#discussion_r232726853
 
 

 ##########
 File path: tool.py
 ##########
 @@ -0,0 +1,154 @@
+#!/usr/bin/env python3
+
+# 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.
+
+# -*- coding: utf-8 -*-
+"""Tool to ease working with the build system and reproducing test results"""
+
+import os
+import sys
+from subprocess import check_call
+import shlex
+from ci.util import retry, remember_cwd
+from typing import List
+from collections import OrderedDict
+import logging
+import yaml
+
+class Confirm(object):
+    def __init__(self, cmds):
+        self.cmds = cmds
+
+    def __call__(self):
+        resp = input("This will run the following command(s) '{}' are you 
sure? yes / no: ".format(self.cmds))
+        while True:
+            if resp.lower() == 'yes':
+                handle_commands(self.cmds)
+                return
+            elif resp.lower() == 'no':
+                return
+            else:
+                resp = input("Please answer yes or no: ")
+
+class CMake(object):
+    def __init__(self, cmake_options_yaml='cmake/cmake_options.yml'):
+        self.cmake_options_yaml = cmake_options_yaml
+        self.cmake_options = None
+        self.read_config()
+
+    def read_config(self):
+        assert os.path.isfile(self.cmake_options_yaml)
+        with open(self.cmake_options_yaml, 'r') as f:
+            self.cmake_options = yaml.load(f)
+
+    def _cmdlineflags(self):
+        res = []
+        def _bool_ON_OFF(x):
+            if x:
+                return 'ON'
+            else:
+                return 'OFF'
+        for opt,v in self.cmake_options.items():
+            res.append('-D{}={}'.format(opt,_bool_ON_OFF(v)))
+        return res
+
+    def cmake_command(self) -> str:
+        """
+        :return: Cmake command to run given the options
+        """
+        cmd_lst = ['cmake']
+        cmd_lst.extend(self._cmdlineflags())
+        return cmd_lst
+
+    def __call__(self, build_dir='build', generator='Ninja', 
build_cmd='ninja'):
+        logging.info("CMake / {} build in directory {}".format(
+            generator, os.path.abspath(build_dir)))
+        cmd_lst = self.cmake_command()
+        os.makedirs(build_dir, exist_ok=True)
+        with remember_cwd():
+            os.chdir(build_dir)
+            cmd_lst.extend(['-G{}'.format(generator), '..'])
+            logging.info('Executing: {}'.format('\t\n'.join(cmd_lst)))
+            check_call(cmd_lst)
+            logging.info('Now building')
+            check_call(shlex.split(build_cmd))
+
+
+
+COMMANDS = OrderedDict([
+    ('sanity_check',
+        "ci/build.py --platform ubuntu_cpu /work/runtime_functions.sh 
sanity_check"),
+    ('Python3 CPU unittests',
 
 Review comment:
   Can you add the possibility to specify a test name, test seed and number of 
runs so that people can reproduce a single test failure

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to