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



##########
File path: docs/script_convert.py
##########
@@ -0,0 +1,94 @@
+# 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.
+
+import argparse
+import pathlib
+
+BASH = "# bash"
+BASH_IGNORE = "# bash-ignore"
+BASH_MULTILINE_COMMENT_START = ": '"
+BASH_MULTILINE_COMMENT_END = "'"
+
+
+def bash_to_python(src_path: pathlib.Path, dest_path: pathlib.Path):
+    """Convert a bash script file to a Python format compatible with Sphinx 
doc."""
+    with open(src_path, "r") as src_f:
+        with open(dest_path, "w") as dest_f:
+            line = src_f.readline()
+            bash_block = []
+            bash_detected = False
+            bash_ignore_detected = False
+            new_line_required = False
+            while line:
+                line = line.strip("\n").strip("\r")
+                if bash_detected:
+                    if line == BASH:
+                        # write the bash block to destination
+                        if new_line_required:
+                            dest_f.write("\n")
+                        python_code = "# .. code-block:: bash\n#\n"
+                        for bash_line in bash_block:
+                            python_code += f"#\t  {bash_line}\n"
+                        python_code += "#"
+                        dest_f.write(python_code)
+
+                        bash_detected = False
+                        bash_block = []
+                        new_line_required = True
+                    else:
+                        # add new bash command line
+                        bash_block.append(line)
+                elif bash_ignore_detected:
+                    if line == BASH_IGNORE:
+                        bash_ignore_detected = False
+                        new_line_required = True
+                    else:
+                        new_line_required = False
+                        pass
+                else:
+                    if line == BASH:
+                        bash_detected = True
+                    elif line == BASH_IGNORE:
+                        bash_ignore_detected = True
+                    elif line in [BASH_MULTILINE_COMMENT_START, 
BASH_MULTILINE_COMMENT_END]:
+                        if new_line_required:
+                            dest_f.write("\n")
+                        dest_f.write('"""')
+                        new_line_required = True
+                    else:
+                        if new_line_required:
+                            dest_f.write("\n")
+                        dest_f.write(f"{line}")
+                        new_line_required = True
+
+                line = src_f.readline()
+            if new_line_required:
+                dest_f.write("\n")
+
+
+def convert():

Review comment:
       convention is to name this main since it's also the main entry point

##########
File path: tests/scripts/task_python_microtvm.sh
##########
@@ -45,9 +45,10 @@ run_pytest ctypes python-microtvm-stm32 tests/micro/stm32
 run_pytest ctypes python-microtvm-common-qemu_x86 tests/micro/common 
--board=qemu_x86
 run_pytest ctypes python-microtvm-common-due tests/micro/common  
--test-build-only --board=due
 
-# # Tutorials running with host CRT
+# Tutorials
 python3 gallery/how_to/work_with_microtvm/micro_tflite.py
 python3 gallery/how_to/work_with_microtvm/micro_autotune.py
+./gallery/how_to/work_with_microtvm/micro_tvmc.sh

Review comment:
       k, so for this PR the delta is at least that now we test the tvmc 
commands to make sure they don't crash. next it would be great to do what 
@driazati mentioned, where we run script_convert.py in ci-qemu and then forward 
the output to the doc-builder step. let's merge this now though to make 
incremental progress.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to