Samsung / ONE-vscode

Visual Studio Code Extension of ONE compiler toolchain
Apache License 2.0
48 stars 50 forks source link

[UX] Lexical check on .cfg #667

Open dayo09 opened 2 years ago

dayo09 commented 2 years ago

What?

Let's provide a basic lexical checker on .cfg

If a user doesn't use our configuration editor, and imported an improvised .cfg file, it may contain some lexical error that can be checked simply.

Let's run a basic lexical checker and gives a feedback for that cases.

Expected Behavior

[one-build]
one-import-tflite=True

ERROR: 'There is no [onecc] section.' WARNING: 'There is [one-build] section. Do you mean [onecc] section?' (❗ icon for the config file on OneExplorer)

[one-import-tflite]
output_path="B.circle"

ERROR: 'There is no input_path for [one-import-tflite] section' (❗ icon for the config file on OneExplorer)

[one-import-tflite]
input_path="B.tflite"

ERROR: 'There are more than one input_path for [one-import-tflite] section' (❗ icon for the config file on OneExplorer)

Why?

For now, we can only detect an error on model.cfg when we run the cfg directly. And it prints out an error from the specific tools rather than onecc itself.

For example

(When there are no onecc section, only one-build section instead)

onecc: ImportError: [onecc] section is required in configuration file

(When it has no input_path of one-import-tflite)

/usr/lib/python3.8/subprocess.py:848: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
  self.stdout = io.open(c2pread, 'rb', bufsize)
/usr/lib/python3.8/subprocess.py:853: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
  self.stderr = io.open(errread, 'rb', bufsize)
usage: one-import-tflite [-h] [-v] [-V] [-C CONFIG] [-i INPUT_PATH]
                         [-o OUTPUT_PATH]
one-import-tflite: error: the following arguments are required: -i/--input_path

To be considered

Check if it's better to emplace this within onecc.

hyunsik-yoon commented 2 years ago

Check if it's better to emplace this within onecc.

+1 for 'within onecc' because onecc also eventually needs this feature. 😸

/cc @seanshpark

seanshpark commented 2 years ago

in one-cmds, utils.py,

    if not config.has_section(section):
        raise AssertionError('configuration file doesn\'t have \'' + section +
                             '\' section')

onecc / one-build checks for the section.