-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[microTVM] Add platform version check to template project #9274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e8eacd7
a0f771b
bd980a8
007165a
1b0077c
489c699
75ab41d
39e9b76
f3c7be6
bd97931
6ea391b
13df1cf
643fc05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,13 +36,19 @@ | |
| import serial.tools.list_ports | ||
| from tvm.micro.project_api import server | ||
|
|
||
| _LOG = logging.getLogger(__name__) | ||
|
|
||
| MODEL_LIBRARY_FORMAT_RELPATH = pathlib.Path("src") / "model" / "model.tar" | ||
| API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) | ||
| BUILD_DIR = API_SERVER_DIR / "build" | ||
| MODEL_LIBRARY_FORMAT_PATH = API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH | ||
|
|
||
| IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() | ||
|
|
||
| # Used to check Arduino CLI version installed on the host. | ||
| # We only check two levels of the version. | ||
| ARDUINO_CLI_VERSION = 0.18 | ||
|
|
||
|
|
||
| BOARDS = API_SERVER_DIR / "boards.json" | ||
|
|
||
|
|
@@ -77,6 +83,11 @@ class BoardAutodetectFailed(Exception): | |
| server.ProjectOption( | ||
| "verbose", help="True to pass --verbose flag to arduino-cli compile and upload" | ||
| ), | ||
| server.ProjectOption( | ||
| "warning_as_error", | ||
| choices=(True, False), | ||
| help="Treat warnings as errors and raise an Exception.", | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
|
|
@@ -275,7 +286,25 @@ def _find_modified_include_path(self, project_dir, file_path, include_path): | |
| # It's probably a standard C/C++ header | ||
| return include_path | ||
|
|
||
| def _get_platform_version(self, arduino_cli_path: str) -> float: | ||
| version_output = subprocess.check_output([arduino_cli_path, "version"], encoding="utf-8") | ||
| version_output = ( | ||
| version_output.replace("\n", "").replace("\r", "").replace(":", "").lower().split(" ") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly is this line stripping out? Can we use a regex or
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the review. I will add the format as a comment and change it to use regex in the following PR which is waiting for this: |
||
| ) | ||
| full_version = version_output[version_output.index("version") + 1].split(".") | ||
| version = float(f"{full_version[0]}.{full_version[1]}") | ||
|
|
||
| return version | ||
|
|
||
| def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): | ||
| # Check Arduino version | ||
| version = self._get_platform_version(options["arduino_cli_cmd"]) | ||
| if version != ARDUINO_CLI_VERSION: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm not sure we should do an exact match check. cc @guberti do you have a better suggestion as to how loose we should be? i could even just be okay with a warning
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think two levels of version, Major + Minor, is enough. We don't need to check the patch level version since they usually don't change interfaces. I discussed this with @gromero and that seems to be the case for Zephyr. For Arduino I got the same impression based on their release messages: https://github.com/arduino/arduino-cli/releases
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea the Arduino CLI seems to be relatively stable - this looks fine to me. |
||
| message = f"Arduino CLI version found is not supported: found {version}, expected {ARDUINO_CLI_VERSION}." | ||
| if options.get("warning_as_error") is not None and options["warning_as_error"]: | ||
| raise server.ServerError(message=message) | ||
| _LOG.warning(message) | ||
|
|
||
| # Reference key directories with pathlib | ||
| project_dir = pathlib.Path(project_dir) | ||
| project_dir.mkdir() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.