Week 6: Modify API, Add logger

As planned for Week 6, the modtool tests have been added in-tree and all the print statements have been replaced by the logger. A major change to the API structure has also been made. All the raw open() statements have been replaced by with open(filename) as f.  The CLI modules have been modified to enhance the developer readability as well as the user experience.


Now, the ModTool API does not have any mandatory positional arguments for any of the in-tree modules. In the function __init__, the parameters are assigned the values passed by the user without any validation. The user has the liberty to pass the values later. The validation of values occur when the run method of a class is called. The run method calls the validate  method followed by the assign method (if required) of the particular class. The validate method initially calls the _validate method of the base module, except for the classes ModToolInfo and ModToolNewModule, for the validation of common parameters and then validates the parameters for the particular modules. The _assign method of the base module and the assign method of other modules assign the values of arguments based on the user input (eg:- fullblockname). The _assign method also calls required methods of the base module. For the CLI commands, the methods _validate and _assign are called from the  __init__ function itself.

The ModTool tests have also been changed as per the above-mentioned changes with tests on API calls via list-unpacking as well as object instantiation. They have been pushed in-tree.

A global logger gnuradio.modtool has been configured in the base module. All the loggers in the core as well as tools are created based on their respective module’s name. Since all the modules are packaged in the package gnuradio.modtool​, they inherit the configuration of the logger in the base module. Currently, the logger level has been set to info for the CLI commands whereas error for the API calls.

The CLI modules have been changed to facilitate the developer experience while changing a particular portion of the CLI interface. Moreover, until the value of block name or the module name is not specified, the user is prompted to fill its value which is followed by the usual regex check.

I have updated the pull request for the grc_xml_generator.

Tasks for Week 7

  1. Run pylint against the generated modules. This involves fixing of current pylint issues in the templates.
  2. Add ANSI colors to the logger as well as the CLI. This involves configuring the logger such that it works differently for the commands through different interfaces.
  3. Fix the issue with the core rename module.
  4. Read for adding a YAML generator in-tree plugin.

I have updated the GitHub project and the code is available at the forked repository core_cli branch.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s