You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/06/08 21:18:51 UTC

[GitHub] [tvm] areusch commented on a change in pull request #8190: [microTVM] Add QEMU build to RVM image

areusch commented on a change in pull request #8190:
URL: https://github.com/apache/tvm/pull/8190#discussion_r646874792



##########
File path: apps/microtvm/reference-vm/base-box-tool.py
##########
@@ -189,20 +196,34 @@ def generate_packer_config(file_path, providers):
             }
         )
 
+    for script in EXTRA_SCRIPTS:
+        filename = os.path.basename(script)
+        provisioners.append({"type": "file", "source": script, "destination": f"~/{filename}"})
+
+    provisioners.append(
+        {
+            "type": "shell",
+            "script": "base_box_provision.sh",
+            "execute_command": f"chmod +x {{{{ .Path }}}}; {{{{ .Vars }}}} {{{{ .Path }}}}",
+        }
+    )
+
     with open(file_path, "w") as f:
         json.dump(
             {
                 "builders": builders,
+                "provisioners": provisioners,
             },
             f,
-            sort_keys=True,
+            sort_keys=False,
             indent=2,
         )
 
 
 def build_command(args):
+    packer_file_name = "packer.json"

Review comment:
       this could be a module-level constant
   
   `PACKER_FILE_NAME = ...`

##########
File path: apps/microtvm/reference-vm/base-box-tool.py
##########
@@ -173,12 +173,19 @@ def attach_vmware(uuid, vid_hex=None, pid_hex=None, serial=None):
     "vmware_desktop": attach_vmware,
 }
 
+EXTRA_SCRIPTS = (
+    "../../../../../docker/install/ubuntu_init_zephyr_project.sh",

Review comment:
       can you fetch repo root with
   `subprocess.check_output(["git", "rev-parse", "--show-toplevel"], cwd=os.path.dirname(__file__))`
   
   and then express these paths relative to that?

##########
File path: apps/microtvm/reference-vm/zephyr/rebuild-tvm.sh
##########
@@ -18,6 +18,13 @@
 
 set -e
 
+# Get number of cores for build
+if [ -n "${TVM_CI_NUM_CORES}" ]; then
+  num_cores=${TVM_CI_NUM_CORES}
+else
+  num_cores=4

Review comment:
       why 4? can you add comment?

##########
File path: apps/microtvm/reference-vm/base-box-tool.py
##########
@@ -189,20 +196,34 @@ def generate_packer_config(file_path, providers):
             }
         )
 
+    for script in EXTRA_SCRIPTS:
+        filename = os.path.basename(script)
+        provisioners.append({"type": "file", "source": script, "destination": f"~/{filename}"})
+
+    provisioners.append(

Review comment:
       rm

##########
File path: apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
##########
@@ -0,0 +1,34 @@
+#!/bin/bash -e
+# 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 -e
+set -x
+
+source ~/.profile
+
+# Init Zephyr
+cd ~
+~/ubuntu_init_zephyr_project.sh ~/zephyrproject v2.5-branch --commit dabf23758417fd041fec2a2a821d8f526afac29d
+
+# Build QEMU
+cd ~

Review comment:
       needed?

##########
File path: apps/microtvm/reference-vm/README.md
##########
@@ -49,10 +49,10 @@ Reference VMs are organized as follows:
 
 ## Creating Releases
 
-1. Build the base box for the given platform: `$ ./base-box-tool.py build <platform>`
+1. Build the base box for the given platform: `$ ./base-box-tool.py <--provider=> build <platform>`

Review comment:
       here i think the standard for optional params is `[--provider=PROVIDER]` or `[--provider=<provider>]`

##########
File path: apps/microtvm/reference-vm/base-box-tool.py
##########
@@ -189,20 +196,34 @@ def generate_packer_config(file_path, providers):
             }
         )
 
+    for script in EXTRA_SCRIPTS:
+        filename = os.path.basename(script)
+        provisioners.append({"type": "file", "source": script, "destination": f"~/{filename}"})
+
+    provisioners.append(
+        {
+            "type": "shell",
+            "script": "base_box_provision.sh",
+            "execute_command": f"chmod +x {{{{ .Path }}}}; {{{{ .Vars }}}} {{{{ .Path }}}}",
+        }
+    )
+
     with open(file_path, "w") as f:
         json.dump(
             {
                 "builders": builders,
+                "provisioners": provisioners,
             },
             f,
-            sort_keys=True,
+            sort_keys=False,

Review comment:
       why not?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org