Skip to content

Commit 76b9d38

Browse files
committed
fix passed options in generatedproject flow
1 parent c85f07b commit 76b9d38

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

apps/microtvm/arduino/template_project/microtvm_api_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class BoardAutodetectFailed(Exception):
6969
) + [
7070
server.ProjectOption(
7171
"arduino_cli_cmd",
72-
required=(["generate_project", "flash", "open_transport"] if not ARDUINO_CLI_CMD else None),
72+
required=(
73+
["generate_project", "build", "flash", "open_transport"]
74+
if not ARDUINO_CLI_CMD
75+
else None
76+
),
7377
optional=(
7478
["generate_project", "build", "flash", "open_transport"] if ARDUINO_CLI_CMD else None
7579
),

python/tvm/micro/project.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
from .transport import Transport, TransportTimeouts
2929

3030

31+
def add_unspecified_options(options: dict, server_project_options: list) -> dict:
32+
"""Adds default value of project template options that are not specified by user."""
33+
if not options:
34+
options = dict()
35+
for option in server_project_options:
36+
name = option["name"]
37+
if name not in options.keys():
38+
options[name] = option["default"]
39+
return options
40+
41+
3142
class ProjectTransport(Transport):
3243
"""A Transport implementation that uses the Project API client."""
3344

@@ -69,10 +80,10 @@ def from_directory(cls, project_dir: Union[pathlib.Path, str], options: dict):
6980

7081
def __init__(self, api_client, options):
7182
self._api_client = api_client
72-
self._options = options
7383
self._info = self._api_client.server_info_query(__version__)
7484
if self._info["is_template"]:
7585
raise TemplateProjectError()
86+
self._options = add_unspecified_options(options, self._info["project_options"])
7687

7788
def build(self):
7889
self._api_client.build(self._options)
@@ -121,19 +132,10 @@ def _check_project_options(self, options: dict):
121132
Here is a list of available options:{list(available_options)}."""
122133
)
123134

124-
def _add_unspecified_options(self, options: dict):
125-
"""Adds default value of project options that are not specified by user."""
126-
if not options:
127-
options = dict()
128-
for option in self._info["project_options"]:
129-
name = option["name"]
130-
if name not in options.keys():
131-
options[name] = option["default"]
132-
133135
def generate_project_from_mlf(self, model_library_format_path, project_dir, options: dict):
134136
"""Generate a project from MLF file."""
135137
self._check_project_options(options)
136-
self._add_unspecified_options(options)
138+
options = add_unspecified_options(options, self._info["project_options"])
137139

138140
self._api_client.generate_project(
139141
model_library_format_path=str(model_library_format_path),

tests/micro/arduino/test_arduino_workflow.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ def project_dir(workflow_workspace_dir):
5454
# We MUST pass workspace_dir, not project_dir, or the workspace will be dereferenced
5555
# too soon. We can't use the board fixture either for the reason mentioned above.
5656
@pytest.fixture(scope="module")
57-
def project(request, arduino_cli_cmd, microtvm_debug, workflow_workspace_dir):
57+
def project(request, microtvm_debug, workflow_workspace_dir):
5858
board = request.config.getoption("--board")
5959
serial_number = request.config.getoption("--serial-number")
60-
return test_utils.make_kws_project(
61-
board, arduino_cli_cmd, microtvm_debug, workflow_workspace_dir, serial_number
62-
)
60+
return test_utils.make_kws_project(board, microtvm_debug, workflow_workspace_dir, serial_number)
6361

6462

6563
def _get_directory_elements(directory):

0 commit comments

Comments
 (0)