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
Add interactive configuration generation #409
Conversation
- Hook this up to a `--quiet` / `-q` flag for each command line tool. - Add new tests.
- Create new `InteractiveField` class - Add docstrings to all methods.
- this makes it easy to test the class
Hello @desilinguist! Thanks for updating this PR.
Comment last updated at 2020-03-27 16:07:56 UTC |
# Conflicts: # rsmtool/rsmcompare.py # rsmtool/rsmeval.py # rsmtool/rsmpredict.py # rsmtool/rsmsummarize.py # rsmtool/rsmtool.py # rsmtool/utils/commandline.py # tests/test_utils.py
- update the default value logic appropriately
When generating file for RSMTool, you get some of the optional fields (e.g. second human score, min, max). In the generated file though these are listed under |
|
|
That's because it defaults to |
Ah, I see. Yes "sc1" will be automatically in the config file so you are saying I just need to display "sc1" in the interactive prompt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor things as I was looking at the code.
This may not be possible because all of the optional fields are generated in sorted order right now and the comment is inserted before the first optional field. Doing this would require extra bookkeeping - perhaps we can just tweak the message in the comment? |
I agree that it's a nice to have - let's see how much people use the functionality. |
- Also link to the configuration file sections for each tool and to the tutorials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! By and large, my comments are superficial. I have a lot of suggestions for things like typos, etc.
Co-Authored-By: Matt Mulholland <mulhodm@gmail.com>
- Fix how field types are quoted in docstrings. - Spell out input and intermediate file extensions in docstrings.
Thanks for the comprehensive review @mulhod! Much appreciated. I have addressed all of your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! This is a really nice functionality. I think it will help a lot of people who might want to use RSMTool but may not know where to start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me - very exciting!
Co-Authored-By: Anastassia Loukina <aloukina@users.noreply.github.com>
…ingService/interactive-config-generation Add interactive configuration generation
This PR closes #354 and #397.
It adds interactive configuration generation for all of the tools. Non-interactive or batch-mode configuration generation was previously added by #398.
To try out interactive generation, just run
X generate --interactive
whereX
is any of the five RSM command line tools. You can also add--subgroups
for X =rsmtool
,rsmeval
, andrsmcompare
.The actual interaction bit is mostly handled by the excellent
prompt_toolkit
library. Here's what this this PR does specifically:The configuration generation (both non-interactive and interactive) is handled by a class called
rsmtool.utils.commandline.ConfigurationGenerator
. Thegenerate()
method handles the non-interactive generation and theinteract()
method handles the interactive generation.All of the required fields for the 5 tools and some of the more important optional fields are displayed to the user to provide inputs for them. The appropriate auto-completion and value validation are attached to each fields so that the user is shown appropriate options just like in interactive IPython sessions (which is where
prompt_toolkit
was spun out of). All of this is handled by the new classrsmtool.utils.commandline.InteractiveField
. Essentially, when theinteract()
method is called, anInteractiveField
instance is created for each of the chosen fields with the appropriate completer and validator attached and shown to the user. The values input by the user and then used to create a configuration dictionary and then eventually output as a string.The chosen fields are contained in
rsmtool.utils.constants.INTERACTIVE_MODE_METADATA
which also defines the metadata for each field. This metadata is used to structure the interaction model (what to display, how to complete, how to validate etc.). The metadata consists of:Testing for this specific functionality was quite tricky. We don't really want to test the
prompt_toolkit
functionality as that is already tested outside of our code. So, in keeping with the best practices of unit testing, we use mocking to mock the functionality provided byprompt_toolkit
and only test that our code is doing the right thing. The new testing classes added here aretest_utils.TestInteractiveField
andtest_utils.TestInteractiveGenerate
. The first class checks thatInteractiveField
works as expected and the second checks that theConfigurationGenerator.interact()
works as expected. Between the two of them, we are covering the whole functionality.This PR also adds documentation as follows: it adds a main page at the top level called "Auto-generating configuration files" that contains documentation for interactive, non-interactive generation (which was previously in each tool's configuration file page), and also API usage. I also added multiple screencasts that illustrate how the interactive generation works. Finally, I added links to this top-level page from the configuration file pages of all 5 tools and also all 5 tutorials. I updated the API documentation to include the documentation for the
ConfigurationGenerator
class and itsgenerate()
method and pointed to that from the top-level page too.This PR also removes all imports from
__init__.py
other than the 5 main API functions. This meant minor changes to the API documentation.